public void AddContractRuleForSavingsProduct()
        {
            Account        genericAccount  = _accountManager.Select(1);
            Account        specificAccount = _accountManager.Select(2);
            ISavingProduct savingsProduct  = _savingProductManager.SelectSavingProduct(1);

            EventType      eventType      = _eventManager.SelectEventTypeByEventType("RGLE");
            EventAttribute eventAttribute = _eventManager.SelectEventAttributeByCode("principal");

            ContractAccountingRule rule = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.Saving,
                SavingProduct    = savingsProduct,
                ClientType       = OClientTypes.Person,
                BookingDirection = OBookingDirections.Both,
                EventAttribute   = eventAttribute,
                EventType        = eventType
            };

            rule.Id = _accountingRuleManager.AddAccountingRule(rule);
            Assert.AreNotEqual(0, rule.Id);

            ContractAccountingRule retrievedRule = _accountingRuleManager.Select(rule.Id) as ContractAccountingRule;

            _compareRules(rule, retrievedRule);
        }
 private void buttonDeletePackage_Click(object sender, EventArgs e)
 {
     if (descriptionListView.SelectedItems.Count != 0)
     {
         string msg = GetString("DeleteConfirmation.Text");
         if (DialogResult.Yes == MessageBox.Show(msg, "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
         {
             try
             {
                 ServicesProvider.GetInstance().GetSavingProductServices().DeleteSavingProduct(retrieveSelectedPackage().Id);
                 refreshListView();
                 _selectedPackage            = null;
                 buttonDeleteProduct.Enabled = false;
                 buttonEditProduct.Enabled   = false;
             }
             catch (Exception ex)
             {
                 new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
             }
         }
     }
     else
     {
         MessageBox.Show(MultiLanguageStrings.GetString(Ressource.PackagesForm, "messageSelection.Text"),
                         MultiLanguageStrings.GetString(Ressource.PackagesForm, "title.Text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 public VillageAddSavingsForm(Village village, ISavingProduct product, NonSolidaryGroupForm nsgForm)
 {
     _village = village;
     _product = product;
     _nsgForm = nsgForm;
     InitializeComponent();
     InitializeControls();
 }
Example #4
0
        private static SavingEvent ReadEvent(OpenCbsReader r, ISavingProduct pProduct)
        {
            string      code = r.GetString("code");
            SavingEvent e    = GetSavingsEvent(code);

            SetSavingsEvent(r, e, pProduct);

            return(e);
        }
 public void SaveProduct(ISavingProduct savingProduct, int clientTypeCounter, bool applyToExistingProduct)
 {
     _clientTypeCounter = clientTypeCounter;
     ValidateProduct(savingProduct, clientTypeCounter);
     _savingProductManager.Update(savingProduct);
     if (applyToExistingProduct)
     {
         _savingProductManager.UpdateExistingSavingBooksContracts(savingProduct);
     }
 }
 private void determineRowColor(ISavingProduct savingsProduct, ListViewItem listViewItem)
 {
     if (savingsProduct.Delete == true)
     {
         listViewItem.BackColor = System.Drawing.Color.LightGray;
     }
     else
     {
         listViewItem.BackColor = System.Drawing.Color.White;
     }
 }
        public int SaveProduct(ISavingProduct savingProduct)
        {
            ValidateProduct(savingProduct, _clientTypeCounter);

            if (savingProduct.Id == 0)
            {
                return(_savingProductManager.Add(savingProduct));
            }

            _savingProductManager.Update(savingProduct);
            return(savingProduct.Id);
        }
        public CloseSavingsForm(ISavingProduct savingBookProduct, OCurrency pBalance, OCurrency pCloseFees)
        {
            InitializeComponent();

            _amount = pBalance;
            _closeFees = pCloseFees;

            if (savingBookProduct is SavingsBookProduct)
                _savingsBookProduct = (SavingsBookProduct)savingBookProduct;
            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled = (_closeFees.Value > 0);

            Initialize();
        }
        public CloseSavingsForm(ISavingProduct savingBookProduct, OCurrency pBalance, OCurrency pCloseFees)
        {
            InitializeComponent();

            _amount    = pBalance;
            _closeFees = pCloseFees;

            if (savingBookProduct is SavingsBookProduct)
            {
                _savingsBookProduct = (SavingsBookProduct)savingBookProduct;
            }
            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled     = (_closeFees.Value > 0);

            Initialize();
        }
        private void EditProduct()
        {
            if (PackageFormId != 0)
            {
                ISavingProduct product = ServicesProvider.GetInstance().GetSavingProductServices().FindSavingProductById(PackageFormId);

                if (product is SavingsBookProduct)
                {
                    EditSavingBookProduct((SavingsBookProduct)product);
                }
            }
            else
            {
                MessageBox.Show(MultiLanguageStrings.GetString(Ressource.PackagesForm, "messageSelection.Text"),
                                MultiLanguageStrings.GetString(Ressource.PackagesForm, "title.Text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void EditProduct()
        {
            if (descriptionListView.SelectedItems.Count != 0)
            {
                ISavingProduct product = retrieveSelectedPackage();

                if (product is SavingsBookProduct)
                {
                    EditSavingBookProduct((SavingsBookProduct)product);
                }
            }
            else
            {
                MessageBox.Show(MultiLanguageStrings.GetString(Ressource.PackagesForm, "messageSelection.Text"),
                                MultiLanguageStrings.GetString(Ressource.PackagesForm, "title.Text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #12
0
        private void SavingsProduct_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (null == item)
            {
                return;
            }
            ISavingProduct product = (ISavingProduct)item.Tag;

            if (null == product)
            {
                return;
            }
            VillageAddSavingsForm frm = new VillageAddSavingsForm(_village, product, this);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                DisplaySavings();
            }
        }
 private void determineRowColor(ISavingProduct savingsProduct, ListViewItem listViewItem)
 {
     if (savingsProduct.Delete == true)
         listViewItem.BackColor = System.Drawing.Color.LightGray;
     else
         listViewItem.BackColor = System.Drawing.Color.White;
 }
 private ISavingProduct retrieveSelectedPackage()
 {
     _package = (ISavingProduct)descriptionListView.SelectedItems[0].Tag;
     _selectedPackage = ServicesProvider.GetInstance().GetSavingProductServices().FindSavingProductById(_package.Id);
     return _selectedPackage;
 }
Example #15
0
        public bool ValidateProduct(ISavingProduct savingsProduct, int clientTypeCounter)
        {
            if (string.IsNullOrEmpty(savingsProduct.Name))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.NameIsEmpty);

            if (string.IsNullOrEmpty(savingsProduct.Code))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CodeIsEmpty);

            if (savingsProduct.Id == 0 && _savingProductManager.IsThisProductNameAlreadyExist(savingsProduct.Name))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.DuplicateProductName);

            if (savingsProduct.Id == 0 && _savingProductManager.IsThisProductCodeAlreadyExist(savingsProduct.Code))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.DuplicateProductCode);

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.InitialAmountMin, savingsProduct.InitialAmountMax, null))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountIsInvalid);

            if (savingsProduct.InitialAmountMin < 0)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMinIsInvalid);

            if (!ServicesHelper.CheckIfValueBetweenMinAndMax(savingsProduct.BalanceMin, savingsProduct.BalanceMax, savingsProduct.InitialAmountMin))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMinNotInBalance);

            if (!ServicesHelper.CheckIfValueBetweenMinAndMax(savingsProduct.BalanceMin, savingsProduct.BalanceMax, savingsProduct.InitialAmountMax))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMaxNotInBalance);

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.BalanceMin, savingsProduct.BalanceMax, null))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.BalanceIsInvalid);

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.InterestRateMin, savingsProduct.InterestRateMax, savingsProduct.InterestRate))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateMinMaxIsInvalid);

            if (savingsProduct.InterestRate.HasValue && savingsProduct.InterestRate < 0)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateIsInvalid);

            if (!savingsProduct.InterestRate.HasValue && savingsProduct.InterestRateMin < 0)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateMinIsInvalid);

            if (savingsProduct.Currency == null)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CurrencyIsEmpty);

            if (savingsProduct.Currency.Id == 0)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CurrencyIsEmpty);

            if (clientTypeCounter < 1)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.ClientTypeIsInvalid);

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.EntryFeesMin, savingsProduct.EntryFeesMax, savingsProduct.EntryFees))
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.EntryFeesMinMaxIsInvalid);

            if (savingsProduct.EntryFees.HasValue && savingsProduct.EntryFees.Value < 0)
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.EntryFeesIsInvalid);

            if (savingsProduct is SavingsBookProduct)
                ValidateSavingBookProduct((SavingsBookProduct)savingsProduct);
               return true;
        }
Example #16
0
        public int SaveProduct(ISavingProduct savingProduct)
        {
            ValidateProduct(savingProduct, _clientTypeCounter);

            if (savingProduct.Id == 0)
                return _savingProductManager.Add(savingProduct);

            _savingProductManager.Update(savingProduct);
            return savingProduct.Id;
        }
Example #17
0
 public VillageAddSavingsForm(Village village, ISavingProduct product, NonSolidaryGroupForm nsgForm)
 {
     _village = village;
     _product = product;
     _nsgForm = nsgForm;
     InitializeComponent();
     InitializeControls();
 }
Example #18
0
        private static void SetSavingsEvent(OpenCbsReader r, SavingEvent e, ISavingProduct pProduct)
        {
            e.Id = r.GetInt("id");
            e.ContracId = r.GetInt("contract_id");
            e.Code = r.GetString("code");
            e.Amount = r.GetMoney("amount");
            e.Description = r.GetString("description");
            e.Deleted = r.GetBool("deleted");
            e.Date = r.GetDateTime("creation_date");
            e.Cancelable = r.GetBool("cancelable");
            e.IsFired = r.GetBool("is_fired");
            e.CancelDate = r.GetNullDateTime("cancel_date");

            if(pProduct != null)
                e.ProductType = pProduct.GetType();

            if (r.GetNullSmallInt("savings_method").HasValue)
                e.SavingsMethod = (OSavingsMethods)r.GetNullSmallInt("savings_method").Value;

            e.IsPending = r.GetBool("pending");
            e.PendingEventId = r.GetNullInt("pending_event_id");
            e.TellerId = r.GetNullInt("teller_id");
            e.LoanEventId = r.GetNullInt("loan_event_id");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (e is SavingTransferEvent)
            {
                ((SavingTransferEvent)e).RelatedContractCode = r.GetString("related_contract_code");
            }

            if (e is ISavingsFees)
            {
                ((ISavingsFees) e).Fee = r.GetMoney("fees");
            }

            e.User = new User
                         {
                             Id = r.GetInt("user_id"),
                             UserName = r.GetString("user_name"),
                             Password = r.GetString("user_pass"),
                             LastName = r.GetString("last_name"),
                             FirstName = r.GetString("first_name")
                         };
            e.User.SetRole(r.GetString("role_code"));

            e.ClientType = OClientTypes.All;

            switch (r.GetString("client_type_code"))
            {
                case "I":
                    e.ClientType = OClientTypes.Person; break;
                case "C":
                    e.ClientType = OClientTypes.Corporate; break;
                case "G":
                    e.ClientType = OClientTypes.Group; break;
                case "V":
                    e.ClientType = OClientTypes.Village; break;
            }

            e.Branch = new Branch { Id = r.GetInt("branch_id") };
            e.Currency = new Currency
                             {
                                 Id = r.GetInt("currency_id"),
                                 Code = r.GetString("currency_code"),
                                 IsPivot = r.GetBool("is_pivot"),
                                 IsSwapped = r.GetBool("is_swapped")
                             };
            e.SavingProduct = new SavingsBookProduct { Id = r.GetInt("product_id") };
        }
Example #19
0
        public void Update(ISavingProduct product)
        {
            const string q = @"UPDATE [SavingProducts] SET
                                      [initial_amount_min] = @initialAmountMin
                                    , [initial_amount_max] = @initialAmountMax
                                    , [balance_min] = @balanceMin
                                    , [balance_max] = @balanceMax
                                    , [deposit_min] = @depositMin
                                    , [deposit_max] = @depositMax
                                    , [withdraw_min] = @withdrawMin
                                    , [withdraw_max] = @withdrawMax
                                    , [transfer_min] = @transferMin
                                    , [transfer_max] = @transferMax
                                    , [interest_rate] = @interestRate
                                    , [interest_rate_min] = @interestRateMin
                                    , [interest_rate_max] = @interestRateMax
                                    , [entry_fees] = @entryFees
                                    , [entry_fees_max] = @entryFeesMax
                                    , [entry_fees_min] = @entryFeesMin
                                    {0}
                                    WHERE id = @productId";

            const string sqlTextProductNotUsed = @",[client_type] = @clientType, [name] = @name, [code] = @code, [currency_id] = @currency_id";

            bool productAlreadyUsed = IsThisProductAlreadyUsed(product.Id);

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(string.Format(q, productAlreadyUsed ? "" : sqlTextProductNotUsed), conn))
            {
                SetProduct(c, product);
                c.ExecuteNonQuery();
            }

            if (product is SavingsBookProduct)
            {
                UpdateBookProduct((SavingsBookProduct)product, productAlreadyUsed);
                DeleteAssignedClientTypes(product.Id);
                AssignClientTypes(((SavingsBookProduct)product).ProductClientTypes, product.Id);
            }
        }
Example #20
0
        private void InitializeTabPageSavingDetails(ISavingProduct product)
        {
            try
            {
                Text = _title;
                _savingsBookProduct = (SavingsBookProduct)product;
                DisplaySavingProduct(product);

                tabControlSavingsDetails.TabPages.Clear();
                tabControlSavingsDetails.TabPages.Add(tabPageSavingsAmountsAndFees);
                tabControlSavingsDetails.TabPages.Add(tabPageSavingsEvents);
                tabControlSavingsDetails.TabPages.Add(tabPageLoans); ;
                _saving =
                    new SavingBookContract(ServicesProvider.GetInstance().GetGeneralSettings(),
                        User.CurrentUser,
                        (SavingsBookProduct)product);
                if (((SavingsBookProduct)product).UseTermDeposit) tabControlSavingsDetails.TabPages.Add(tpTermDeposit);

                groupBoxSaving.Text = string.Format("{0}",
                    MultiLanguageStrings.GetString(Ressource.ClientForm, "SavingsBook.Text"));
                groupBoxSaving.ForeColor = Color.FromArgb(0, 88, 56);

                tabControlPerson.TabPages.Remove(tabPageSavingDetails);
                tabControlPerson.TabPages.Add(tabPageSavingDetails);
                tabControlPerson.SelectedTab = tabPageSavingDetails;

                InitializeSavingsGeneralControls();
                InitializeTabPageTermDeposit();
                InitializeSavingsFees();

                btSavingsUpdate.Visible = false;

                groupBoxSaving.Enabled = true;
                pnlSavingsButtons.Enabled = false;

                groupBoxSaving.Name += string.Format(" {0}", product.Name);
                int numbersOfSavings = SavingServices.GetSavingCount(_client);
                _saving.GenerateSavingCode(_client, numbersOfSavings, ServicesProvider.GetInstance().GetGeneralSettings().SavingsCodeTemplate,
                    ServicesProvider.GetInstance().GetGeneralSettings().ImfCode, _client.Branch.Code);
                int nextSavingsId = SavingServices.GetLastSavingsId() + 1;
                tBSavingCode.Text = _saving.Code + '/' + nextSavingsId.ToString();

                InitializeSavingsOfficersComboBox();
                DisplaySavingEvent(_saving);
                DisplaySavingLoans(_saving);

                //InitializeCustomizableFields(OCustomizableFieldEntities.Savings, null, false);
                LoadSavingsExtensions();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Example #21
0
 public void SaveProduct(ISavingProduct savingProduct, int clientTypeCounter, bool applyToExistingProduct)
 {
     _clientTypeCounter = clientTypeCounter;
     ValidateProduct(savingProduct, clientTypeCounter);
     _savingProductManager.Update(savingProduct);
     if (applyToExistingProduct)
     {
         _savingProductManager.UpdateExistingSavingBooksContracts(savingProduct);
     }
 }
Example #22
0
        public void UpdateExistingSavingBooksContracts(ISavingProduct product)
        {
            bool isItTheFirstStatement=true;
            string updateInterestRate="";
            List<int> contractsId=new List<int>();
            SavingsBookProduct savingsBookProduct = (SavingsBookProduct) product;
            int savingProductId = savingsBookProduct.Id;
            string selectContractsId =
                string.Format(
                    @"SELECT id
                      FROM [dbo].[SavingContracts]
                      WHERE product_id=@product_id");
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(selectContractsId, conn))
            {
                c.AddParam("@product_id", savingProductId);
                using (OpenCbsReader r = c.ExecuteReader())
                {
                    while (r.Read())
                    {
                        contractsId.Add(r.GetInt("id"));
                    }
                }
            }

            string updateExistingContractsSql = @"UPDATE [dbo].[SavingBookContracts]
                                                  SET id=@id ";

            if (savingsBookProduct.ManagementFees.HasValue)
                updateExistingContractsSql += ",[flat_management_fees]=@managment_fees";

            if (savingsBookProduct.CloseFees.HasValue)
                updateExistingContractsSql += ",[flat_close_fees]=@close_fees";

            if (savingsBookProduct.DepositFees.HasValue)
                updateExistingContractsSql += ",[flat_deposit_fees]=@deposit_fees";

            if (savingsBookProduct.FlatWithdrawFees.HasValue)
                updateExistingContractsSql += ",[flat_withdraw_fees]=@flat_withdraw_fees";

            if (savingsBookProduct.FlatTransferFees.HasValue)
                updateExistingContractsSql += ",[flat_transfer_fees]=@flat_transfer_fees";

            if (savingsBookProduct.AgioFees.HasValue)
                updateExistingContractsSql += ",[rate_agio_fees]=@rate_agio_fees";

            if (savingsBookProduct.ChequeDepositFees.HasValue)
                updateExistingContractsSql += ",[cheque_deposit_fees]=@cheque_deposit_fees";

            if (savingsBookProduct.OverdraftFees.HasValue)
                updateExistingContractsSql += ",[flat_overdraft_fees]=@flat_overdraft_fees";

            updateExistingContractsSql += " WHERE id=@id";

            foreach (int contractId in contractsId)
            {
                using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(updateExistingContractsSql, conn))
                {
                    c.AddParam("@id", contractId);
                    if (savingsBookProduct.ManagementFees.HasValue)
                        c.AddParam("@managment_fees", savingsBookProduct.ManagementFees.Value);
                    if (savingsBookProduct.CloseFees.HasValue)
                        c.AddParam("@close_fees", savingsBookProduct.CloseFees.Value);
                    if (savingsBookProduct.DepositFees.HasValue)
                        c.AddParam("@deposit_fees", savingsBookProduct.DepositFees.Value);
                    if (savingsBookProduct.FlatWithdrawFees.HasValue)
                        c.AddParam("@flat_withdraw_fees", savingsBookProduct.FlatWithdrawFees.Value);
                    if (savingsBookProduct.FlatTransferFees.HasValue)
                        c.AddParam("@flat_transfer_fees", savingsBookProduct.FlatTransferFees.Value);
                    if (savingsBookProduct.AgioFees.HasValue)
                        c.AddParam("@rate_agio_fees", savingsBookProduct.AgioFees.Value);
                    if (savingsBookProduct.OverdraftFees.HasValue)
                        c.AddParam("@flat_overdraft_fees", savingsBookProduct.OverdraftFees.Value);
                    if (savingsBookProduct.ChequeDepositFees.HasValue)
                        c.AddParam("@cheque_deposit_fees", savingsBookProduct.ChequeDepositFees);
                    c.ExecuteNonQuery();
                }

                if (savingsBookProduct.InterestRate.HasValue)
                {
                    updateInterestRate = @"UPDATE [dbo].[SavingContracts] SET [interest_rate]=@interest_rate
                                           WHERE id=@id";
                    using (SqlConnection conn = GetConnection())
                    using (OpenCbsCommand c = new OpenCbsCommand(updateInterestRate, conn))
                    {
                        c.AddParam("@id", contractId);
                        c.AddParam("@interest_rate", savingsBookProduct.InterestRate);
                        c.ExecuteNonQuery();
                    }
                }
            }
        }
Example #23
0
        /// <summary>
        /// Method to add a package into database. We use the NullableTypes to make the correspondance between
        /// nullable int, decimal and double types in database and our own objects
        /// </summary>
        /// <param name="product">Package Object</param>
        /// <returns>The id of the package which has been added</returns>
        public int Add(ISavingProduct product)
        {
            const string q = @"INSERT INTO [SavingProducts]
                (
                     [deleted]
                    ,[name]
                    ,[code]
                    ,[client_type]
                    ,[initial_amount_min]
                    ,[initial_amount_max]
                    ,[balance_min]
                    ,[balance_max]
                    ,[deposit_min]
                    ,[deposit_max]
                    ,[withdraw_min]
                    ,[withdraw_max]
                    ,[transfer_min]
                    ,[transfer_max]
                    ,[interest_rate]
                    ,[interest_rate_min]
                    ,[interest_rate_max]
                    ,[entry_fees_max]
                    ,[entry_fees_min]
                    ,[entry_fees]
                    ,[currency_id]
                    ,[product_type]
                )
                VALUES
                (
                     @deleted
                    ,@name
                    ,@code
                    ,@clientType
                    ,@initialAmountMin
                    ,@initialAmountMax
                    ,@balanceMin
                    ,@balanceMax
                    ,@depositMin
                    ,@depositMax
                    ,@withdrawMin
                    ,@withdrawMax
                    ,@transferMin
                    ,@transferMax
                    ,@interestRate
                    ,@interestRateMin
                    ,@interestRateMax
                    ,@entryFeesMax
                    ,@entryFeesMin
                    ,@entryFees
                    ,@currency_id
                    ,@product_type
                )
                SELECT CONVERT(int, SCOPE_IDENTITY())";

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                if (product is SavingsBookProduct)
                    c.AddParam("@product_type", 'B');

                SetProduct(c, product);
                product.Id = Convert.ToInt32(c.ExecuteScalar());
            }

            if (product is SavingsBookProduct)
            {
                AddBookProduct((SavingsBookProduct)product);
                AssignClientTypes(((SavingsBookProduct)product).ProductClientTypes, product.Id);
            }

            return product.Id;
        }
Example #24
0
        private static void SetProduct(OpenCbsCommand c, ISavingProduct product)
        {
            c.AddParam("@deleted", product.Delete);
            c.AddParam("@name", product.Name);
            c.AddParam("@code", product.Code);

            if (product.ClientType == OClientTypes.Corporate)
                c.AddParam("@clientType", 'C');
            else if (product.ClientType == OClientTypes.Group)
                c.AddParam("@clientType", 'G');
            else if (product.ClientType == OClientTypes.Person)
                c.AddParam("@clientType", 'I');
            else
                c.AddParam("@clientType", '-');

            c.AddParam("@initialAmountMin", product.InitialAmountMin);
            c.AddParam("@initialAmountMax", product.InitialAmountMax);

            c.AddParam("@balanceMin", product.BalanceMin);
            c.AddParam("@balanceMax", product.BalanceMax);

            c.AddParam("@depositMin", product.DepositMin);
            c.AddParam("@depositMax", product.DepositMax);

            c.AddParam("@withdrawMin", product.WithdrawingMin);
            c.AddParam("@withdrawMax", product.WithdrawingMax);

            c.AddParam("@transferMin", product.TransferMin);
            c.AddParam("@transferMax", product.TransferMax);

            c.AddParam("@interestRate", product.InterestRate);
            c.AddParam("@interestRateMin", product.InterestRateMin);
            c.AddParam("@interestRateMax", product.InterestRateMax);

            c.AddParam("@entryFees", product.EntryFees);
            c.AddParam("@entryFeesMax", product.EntryFeesMax);
            c.AddParam("@entryFeesMin", product.EntryFeesMin);

            c.AddParam("@productId", product.Id);
            c.AddParam("@currency_id", product.Currency.Id);

            if (product is  SavingsBookProduct)
            {
                c.AddParam("@use_term_deposit", ((SavingsBookProduct)product).UseTermDeposit);
                c.AddParam("@term_deposit_period_min", ((SavingsBookProduct)product).TermDepositPeriodMin);
                c.AddParam("@term_deposit_period_max", ((SavingsBookProduct)product).TermDepositPeriodMax);
                if (((SavingsBookProduct)product).UseTermDeposit)
                {
                    c.AddParam("@posting_frequency", ((SavingsBookProduct)product).Periodicity.Id);
                }
            }
            else
            {
                c.AddParam("@use_term_deposit", null);
                c.AddParam("@term_deposit_period_min", null);
                c.AddParam("@term_deposit_period_max", null);
                c.AddParam("@posting_frequency", null);
            }
        }
Example #25
0
        public List <SavingEvent> SelectEvents(int pSavingId, ISavingProduct pProduct)
        {
            const string q = @"SELECT  
                                        SavingEvents.id ,
                                        SavingEvents.user_id ,
                                        SavingEvents.code ,
                                        SavingEvents.amount ,
                                        SavingEvents.description + '  #' + sc.code + '-' + CONVERT(NVARCHAR(50), SavingEvents.id) AS description,
                                        SavingEvents.creation_date ,
                                        SavingEvents.contract_id,
                                        SavingEvents.cancelable ,
                                        SavingEvents.is_fired ,
                                        SavingEvents.deleted ,
                                        SavingEvents.related_contract_code ,
                                        SavingEvents.fees ,
                                        SavingEvents.savings_method ,
                                        SavingEvents.pending ,
                                        SavingEvents.pending_event_id ,
                                        SavingEvents.teller_id ,
                                        SavingEvents.loan_event_id ,
                                        SavingEvents.cancel_date,
                                        Users.id AS user_id ,
                                        Users.deleted ,
                                        Users.user_name ,
                                        Users.user_pass ,
                                        Users.role_code ,
                                        Users.first_name ,
                                        Users.last_name,
                                        0 AS branch_id,
                                        '' AS client_type_code,
                                        0 AS currency_id,
                                        0 AS product_id,
                                        sc.code AS contract_code,
                                        CAST(0 AS bit) AS is_pivot, 
                                        CAST(0 AS bit) AS is_swapped, 
                                        '' AS currency_code
                                FROM    SavingEvents
                                INNER JOIN Users ON SavingEvents.user_id = Users.id
                                INNER JOIN dbo.SavingContracts sc 
                                  ON SavingEvents.contract_id = sc.id
				                WHERE SavingEvents.contract_id = @id 
                                ORDER BY SavingEvents.id";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@id", pSavingId);

                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r == null || r.Empty)
                        {
                            return(new List <SavingEvent>());
                        }

                        List <SavingEvent> eventList = new List <SavingEvent>();
                        while (r.Read())
                        {
                            eventList.Add(ReadEvent(r, pProduct));
                        }
                        return(eventList);
                    }
                }
        }
 private void buttonDeletePackage_Click(object sender, EventArgs e)
 {
     if (descriptionListView.SelectedItems.Count != 0)
     {
         string msg = GetString("DeleteConfirmation.Text");
         if (DialogResult.Yes == MessageBox.Show(msg, "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
         {
             try
             {
                 ServicesProvider.GetInstance().GetSavingProductServices().DeleteSavingProduct(retrieveSelectedPackage().Id);
                 refreshListView();
                 _selectedPackage = null;
                 buttonDeleteProduct.Enabled = false;
                 buttonEditProduct.Enabled = false;
             }
             catch (Exception ex)
             {
                 new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
             }
         }
     }
     else
     {
         MessageBox.Show(MultiLanguageStrings.GetString(Ressource.PackagesForm, "messageSelection.Text"),
                         MultiLanguageStrings.GetString(Ressource.PackagesForm, "title.Text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #27
0
        public List<SavingEvent> SelectEvents(int pSavingId, ISavingProduct pProduct)
        {
            const string q = @"SELECT
                                        SavingEvents.id ,
                                        SavingEvents.user_id ,
                                        SavingEvents.code ,
                                        SavingEvents.amount ,
                                        SavingEvents.description + '  #' + sc.code + '-' + CONVERT(NVARCHAR(50), SavingEvents.id) AS description,
                                        SavingEvents.creation_date ,
                                        SavingEvents.contract_id,
                                        SavingEvents.cancelable ,
                                        SavingEvents.is_fired ,
                                        SavingEvents.deleted ,
                                        SavingEvents.related_contract_code ,
                                        SavingEvents.fees ,
                                        SavingEvents.savings_method ,
                                        SavingEvents.pending ,
                                        SavingEvents.pending_event_id ,
                                        SavingEvents.teller_id ,
                                        SavingEvents.loan_event_id ,
                                        SavingEvents.cancel_date,
                                        Users.id AS user_id ,
                                        Users.deleted ,
                                        Users.user_name ,
                                        Users.user_pass ,
                                        Users.role_code ,
                                        Users.first_name ,
                                        Users.last_name,
                                        0 AS branch_id,
                                        '' AS client_type_code,
                                        0 AS currency_id,
                                        0 AS product_id,
                                        sc.code AS contract_code,
                                        CAST(0 AS bit) AS is_pivot,
                                        CAST(0 AS bit) AS is_swapped,
                                        '' AS currency_code
                                FROM    SavingEvents
                                INNER JOIN Users ON SavingEvents.user_id = Users.id
                                INNER JOIN dbo.SavingContracts sc
                                  ON SavingEvents.contract_id = sc.id
                                WHERE SavingEvents.contract_id = @id
                                ORDER BY SavingEvents.id";
            using (SqlConnection conn = GetConnection())
            using(OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                c.AddParam("@id", pSavingId);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if(r == null || r.Empty) return new List<SavingEvent>();

                    List<SavingEvent> eventList = new List<SavingEvent>();
                    while (r.Read())
                    {
                        eventList.Add(ReadEvent(r, pProduct));
                    }
                    return eventList;
                }
            }
        }
Example #28
0
        private void DisplaySavingProduct(ISavingProduct product)
        {
            lbInitialAmountMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                "Min ", product.InitialAmountMin.GetFormatedValue(product.Currency.UseCents),
                "Max ", product.InitialAmountMax.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            nudDownInitialAmount.Maximum = product.InitialAmountMax.Value;
            nudDownInitialAmount.Minimum = product.InitialAmountMin.Value;
            nudDownInitialAmount.Value = product.InitialAmountMin.Value;

            if (product.InterestRate.HasValue)
            {
                nudDownInterestRate.Enabled = false;
                lbInterestRateMinMax.Text = string.Format("{0} %", product.InterestRate * 100);
                nudDownInterestRate.Maximum = (decimal)product.InterestRate.Value * 100;
                nudDownInterestRate.Minimum = (decimal)product.InterestRate.Value * 100;
            }
            else
            {
                lbInterestRateMinMax.Text = string.Format("{0}{1} %\r\n{2}{3} %",
                    "Min ", product.InterestRateMin.Value * 100,
                    "Max ", product.InterestRateMax.Value * 100);
                nudDownInterestRate.Maximum = (decimal)product.InterestRateMax.Value * 100;
                nudDownInterestRate.Minimum = (decimal)product.InterestRateMin.Value * 100;
            }

            lbBalanceMinValue.Text = string.Format("{0} {1}", product.BalanceMin.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            lbBalanceMaxValue.Text = string.Format("{0} {1}", product.BalanceMax.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            lbWithdrawMinValue.Text = string.Format("{0} {1}", product.WithdrawingMin.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            lbWithdrawMaxValue.Text = string.Format("{0} {1}", product.WithdrawingMax.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            lbDepositMinValue.Text = string.Format("{0} {1}", product.DepositMin.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            lbDepositMaxValue.Text = string.Format("{0} {1}", product.DepositMax.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            labelSavingTransferMinValue.Text = string.Format("{0} {1}", product.TransferMin.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
            labelSavingTransferMaxValue.Text = string.Format("{0} {1}", product.TransferMax.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);

            if (product is SavingsBookProduct)
            {
                gbDepositInterest.Visible = false;
                gbInterest.Visible = true;

                lbWithdrawFees.Visible = true;
                nudWithdrawFees.Visible = true;
                lbWithdrawFeesMinMax.Visible = true;

                lbEntryFees.Visible = true;
                nudEntryFees.Visible = true;
                lbEntryFeesMinMax.Visible = true;

                lbTransferFees.Visible = true;
                nudTransferFees.Visible = true;
                nudIbtFee.Visible = true;
                lbTransferFeesMinMax.Visible = true;

                lbDepositFees.Visible = true;
                nudDepositFees.Visible = true;
                lbDepositFeesMinMax.Visible = true;

                lbChequeDepositFees.Visible = true;
                nudChequeDepositFees.Visible = true;
                lblChequeDepositFeesMinMax.Visible = true;

                lbCloseFees.Visible = true;
                nudCloseFees.Visible = true;
                lbCloseFeesMinMax.Visible = true;

                lbManagementFees.Visible = true;
                nudManagementFees.Visible = true;
                lbManagementFeesMinMax.Visible = true;

                lbOverdraftFees.Visible = true;
                nudOverdraftFees.Visible = true;
                lbOverdraftFeesMinMax.Visible = true;

                lbAgioFees.Visible = true;
                nudAgioFees.Visible = true;
                lbAgioFeesMinMax.Visible = true;

                lbReopenFees.Visible = true;
                nudReopenFees.Visible = true;
                lbReopenFeesMinMax.Visible = true;

                lbInterestAccrualValue.Text = MultiLanguageStrings.GetString(Ressource.FrmAddSavingProduct, ((SavingsBookProduct)product).InterestBase + ".Text");
                lbInterestPostingValue.Text = MultiLanguageStrings.GetString(Ressource.FrmAddSavingProduct, ((SavingsBookProduct)product).InterestFrequency + ".Text");
                lbInterestBasedOnValue.Text = ((SavingsBookProduct)product).CalculAmountBase.HasValue ? MultiLanguageStrings.GetString(Ressource.FrmAddSavingProduct, ((SavingsBookProduct)product).CalculAmountBase + ".Text") : "------";

                savingDepositToolStripMenuItem.Enabled = true;
                savingWithdrawToolStripMenuItem.Enabled = true;
                savingTransferToolStripMenuItem.Enabled = true;

                // entry fees
                nudEntryFees.DecimalPlaces = 0;
                nudEntryFees.Increment = 1;
                if (((SavingsBookProduct)product).EntryFees.HasValue)
                {
                    nudEntryFees.Enabled = false;
                    nudEntryFees.Minimum = ((SavingsBookProduct)product).EntryFees.Value;
                    nudEntryFees.Maximum = ((SavingsBookProduct)product).EntryFees.Value;
                    lbEntryFeesMinMax.Text = string.Format("{0} {1}", ((SavingsBookProduct)product).EntryFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                }
                else
                {
                    nudEntryFees.Enabled = true;
                    nudEntryFees.Minimum = ((SavingsBookProduct)product).EntryFeesMin.Value;
                    nudEntryFees.Maximum = ((SavingsBookProduct)product).EntryFeesMax.Value;
                    lbEntryFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                        "Min ", ((SavingsBookProduct)product).EntryFeesMin.GetFormatedValue(product.Currency.UseCents),
                        "Max ", ((SavingsBookProduct)product).EntryFeesMax.GetFormatedValue(product.Currency.UseCents),
                        product.Currency.Code);
                }

                // withdraw fees
                if (((SavingsBookProduct)product).WithdrawFeesType == OSavingsFeesType.Flat)
                {
                    nudWithdrawFees.DecimalPlaces = 0;
                    nudWithdrawFees.Increment = 1;
                    if (((SavingsBookProduct)product).FlatWithdrawFees.HasValue)
                    {
                        nudWithdrawFees.Enabled = false;
                        nudWithdrawFees.Minimum = ((SavingsBookProduct)product).FlatWithdrawFees.Value;
                        nudWithdrawFees.Maximum = ((SavingsBookProduct)product).FlatWithdrawFees.Value;
                        lbWithdrawFeesMinMax.Text = string.Format("{0} {1}", ((SavingsBookProduct)product).FlatWithdrawFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                    }
                    else
                    {
                        nudWithdrawFees.Enabled = true;
                        nudWithdrawFees.Minimum = ((SavingsBookProduct)product).FlatWithdrawFeesMin.Value;
                        nudWithdrawFees.Maximum = ((SavingsBookProduct)product).FlatWithdrawFeesMax.Value;
                        lbWithdrawFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                            "Min ", ((SavingsBookProduct)product).FlatWithdrawFeesMin.GetFormatedValue(product.Currency.UseCents),
                            "Max ", ((SavingsBookProduct)product).FlatWithdrawFeesMax.GetFormatedValue(product.Currency.UseCents),
                            product.Currency.Code);
                    }
                }
                else
                {
                    nudWithdrawFees.DecimalPlaces = 4;
                    nudWithdrawFees.Increment = 0.0001m;
                    if (((SavingsBookProduct)product).RateWithdrawFees.HasValue)
                    {
                        nudWithdrawFees.Enabled = false;
                        nudWithdrawFees.Minimum = (decimal)((SavingsBookProduct)product).RateWithdrawFees.Value * 100;
                        nudWithdrawFees.Maximum = (decimal)((SavingsBookProduct)product).RateWithdrawFees.Value * 100;
                        lbWithdrawFeesMinMax.Text = string.Format("{0} {1}", (((SavingsBookProduct)product).RateWithdrawFees * 100), "%");
                    }
                    else
                    {
                        nudWithdrawFees.Enabled = true;
                        nudWithdrawFees.Minimum = (decimal)((SavingsBookProduct)product).RateWithdrawFeesMin.Value * 100;
                        nudWithdrawFees.Maximum = (decimal)((SavingsBookProduct)product).RateWithdrawFeesMax.Value * 100;
                        lbWithdrawFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                            "Min ", (((SavingsBookProduct)product).RateWithdrawFeesMin * 100),
                            "Max ", (((SavingsBookProduct)product).RateWithdrawFeesMax * 100),
                            "%");
                    }
                }

                // Inter-branch tansfer fee
                SavingsBookProduct p = (SavingsBookProduct)product;
                Fee fee = p.InterBranchTransferFee;
                nudIbtFee.DecimalPlaces = fee.IsFlat ? 0 : 2;
                nudIbtFee.Increment = fee.IsFlat ? 1 : 0.01m;
                nudIbtFee.Enabled = !fee.Value.HasValue;
                nudIbtFee.Minimum = fee.GetMin();
                nudIbtFee.Maximum = fee.GetMax();
                if (fee.IsRange)
                {
                    string min = fee.GetMinFormatted(p.Currency);
                    string max = fee.GetMaxFormatted(p.Currency);
                    const string mask = "Min {0}\r\nMax {1}";
                    lblIbtFeeMinMax.Text = string.Format(mask, min, max);
                }
                else
                {
                    lblIbtFeeMinMax.Text = fee.GetValueFormatted(p.Currency);
                }

                if (((SavingsBookProduct)product).TransferFeesType == OSavingsFeesType.Flat)
                {
                    nudTransferFees.DecimalPlaces = 0;
                    nudTransferFees.Increment = 1;
                    if (((SavingsBookProduct)product).FlatTransferFees.HasValue)
                    {
                        nudTransferFees.Enabled = false;
                        nudTransferFees.Minimum = ((SavingsBookProduct)product).FlatTransferFees.Value;
                        nudTransferFees.Maximum = ((SavingsBookProduct)product).FlatTransferFees.Value;
                        lbTransferFeesMinMax.Text = string.Format("{0} {1}", ((SavingsBookProduct)product).FlatTransferFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                    }
                    else
                    {
                        nudTransferFees.Enabled = true;
                        nudTransferFees.Minimum = ((SavingsBookProduct)product).FlatTransferFeesMin.Value;
                        nudTransferFees.Maximum = ((SavingsBookProduct)product).FlatTransferFeesMax.Value;
                        lbTransferFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                            "Min ", ((SavingsBookProduct)product).FlatTransferFeesMin.GetFormatedValue(product.Currency.UseCents),
                            "Max ", ((SavingsBookProduct)product).FlatTransferFeesMax.GetFormatedValue(product.Currency.UseCents),
                            product.Currency.Code);
                    }
                }
                else
                {
                    nudTransferFees.DecimalPlaces = 4;
                    nudTransferFees.Increment = 0.0001m;
                    if (((SavingsBookProduct)product).RateTransferFees.HasValue)
                    {
                        nudTransferFees.Enabled = false;
                        nudTransferFees.Minimum = (decimal)((SavingsBookProduct)product).RateTransferFees.Value * 100;
                        nudTransferFees.Maximum = (decimal)((SavingsBookProduct)product).RateTransferFees.Value * 100;
                        lbTransferFeesMinMax.Text = string.Format("{0} {1}", (((SavingsBookProduct)product).RateTransferFees * 100), "%");
                    }
                    else
                    {
                        nudTransferFees.Enabled = true;
                        nudTransferFees.Minimum = (decimal)((SavingsBookProduct)product).RateTransferFeesMin.Value * 100;
                        nudTransferFees.Maximum = (decimal)((SavingsBookProduct)product).RateTransferFeesMax.Value * 100;
                        lbTransferFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                            "Min ", (((SavingsBookProduct)product).RateTransferFeesMin * 100),
                            "Max ", (((SavingsBookProduct)product).RateTransferFeesMax * 100),
                            "%");
                    }
                }

                //Cash Deposit fees
                nudDepositFees.DecimalPlaces = 0;
                nudDepositFees.Increment = 1;
                if (((SavingsBookProduct)product).DepositFees.HasValue)
                {
                    nudDepositFees.Enabled = false;
                    nudDepositFees.Minimum = ((SavingsBookProduct)product).DepositFees.Value;
                    nudDepositFees.Maximum = ((SavingsBookProduct)product).DepositFees.Value;
                    lbDepositFeesMinMax.Text = string.Format("{0} {1}",
                                                             ((SavingsBookProduct)product).DepositFees.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }
                else
                {
                    nudDepositFees.Enabled = true;
                    nudDepositFees.Minimum = ((SavingsBookProduct)product).DepositFeesMin.Value;
                    nudDepositFees.Maximum = ((SavingsBookProduct)product).DepositFeesMax.Value;
                    lbDepositFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                                                             "Min ", ((SavingsBookProduct)product).DepositFeesMin.GetFormatedValue(product.Currency.UseCents),
                                                             "Max ", ((SavingsBookProduct)product).DepositFeesMax.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }

                //Cheque Deposit fees
                nudChequeDepositFees.DecimalPlaces = 0;
                nudChequeDepositFees.Increment = 1;
                if (((SavingsBookProduct)product).ChequeDepositFees.HasValue)
                {
                    nudChequeDepositFees.Enabled = false;
                    nudChequeDepositFees.Maximum = ((SavingsBookProduct)product).ChequeDepositFees.Value;
                    nudChequeDepositFees.Minimum = ((SavingsBookProduct)product).ChequeDepositFees.Value;
                    lblChequeDepositFeesMinMax.Text = string.Format("{0} {1}",
                                                             ((SavingsBookProduct)product).ChequeDepositFees.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }
                else
                {
                    nudChequeDepositFees.Enabled = true;
                    nudChequeDepositFees.Minimum = ((SavingsBookProduct)product).ChequeDepositFeesMin.Value;
                    nudChequeDepositFees.Maximum = ((SavingsBookProduct)product).ChequeDepositFeesMax.Value;
                    lblChequeDepositFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                                                             "Min ", ((SavingsBookProduct)product).ChequeDepositFeesMin.GetFormatedValue(product.Currency.UseCents),
                                                             "Max ", ((SavingsBookProduct)product).ChequeDepositFeesMax.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }

                // Close fees
                nudCloseFees.DecimalPlaces = 0;
                nudCloseFees.Increment = 1;
                if (((SavingsBookProduct)product).CloseFees.HasValue)
                {
                    nudCloseFees.Enabled = false;
                    nudCloseFees.Minimum = ((SavingsBookProduct)product).CloseFees.Value;
                    nudCloseFees.Maximum = ((SavingsBookProduct)product).CloseFees.Value;
                    lbCloseFeesMinMax.Text = string.Format("{0} {1}",
                        ((SavingsBookProduct)product).CloseFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                }
                else
                {
                    nudCloseFees.Enabled = true;
                    nudCloseFees.Minimum = ((SavingsBookProduct)product).CloseFeesMin.Value;
                    nudCloseFees.Maximum = ((SavingsBookProduct)product).CloseFeesMax.Value;
                    lbCloseFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                        "Min ", ((SavingsBookProduct)product).CloseFeesMin.GetFormatedValue(product.Currency.UseCents),
                        "Max ", ((SavingsBookProduct)product).CloseFeesMax.GetFormatedValue(product.Currency.UseCents),
                        product.Currency.Code);
                }

                // Management fees
                nudManagementFees.DecimalPlaces = 0;
                nudManagementFees.Increment = 1;
                if (((SavingsBookProduct)product).ManagementFees.HasValue)
                {
                    nudManagementFees.Enabled = false;
                    nudManagementFees.Minimum = ((SavingsBookProduct)product).ManagementFees.Value;
                    nudManagementFees.Maximum = ((SavingsBookProduct)product).ManagementFees.Value;
                    lbManagementFeesMinMax.Text = string.Format("{0} {1}",
                        ((SavingsBookProduct)product).ManagementFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                }
                else
                {
                    nudManagementFees.Enabled = true;
                    nudManagementFees.Minimum = ((SavingsBookProduct)product).ManagementFeesMin.Value;
                    nudManagementFees.Maximum = ((SavingsBookProduct)product).ManagementFeesMax.Value;
                    lbManagementFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                        "Min ", ((SavingsBookProduct)product).ManagementFeesMin.GetFormatedValue(product.Currency.UseCents),
                        "Max ", ((SavingsBookProduct)product).ManagementFeesMax.GetFormatedValue(product.Currency.UseCents),
                        product.Currency.Code);
                }

                // Overdraft fees
                nudOverdraftFees.DecimalPlaces = 0;
                nudOverdraftFees.Increment = 1;
                if (((SavingsBookProduct)product).OverdraftFees.HasValue)
                {
                    nudOverdraftFees.Enabled = false;
                    nudOverdraftFees.Minimum = ((SavingsBookProduct)product).OverdraftFees.Value;
                    nudOverdraftFees.Maximum = ((SavingsBookProduct)product).OverdraftFees.Value;
                    lbOverdraftFeesMinMax.Text = string.Format("{0} {1}",
                        ((SavingsBookProduct)product).OverdraftFees.GetFormatedValue(product.Currency.UseCents), product.Currency.Code);
                }
                else
                {
                    nudOverdraftFees.Enabled = true;
                    nudOverdraftFees.Minimum = ((SavingsBookProduct)product).OverdraftFeesMin.Value;
                    nudOverdraftFees.Maximum = ((SavingsBookProduct)product).OverdraftFeesMax.Value;
                    lbOverdraftFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                        "Min ", ((SavingsBookProduct)product).OverdraftFeesMin.GetFormatedValue(product.Currency.UseCents),
                        "Max ", ((SavingsBookProduct)product).OverdraftFeesMax.GetFormatedValue(product.Currency.UseCents),
                        product.Currency.Code);
                }

                // Agio fees
                nudAgioFees.DecimalPlaces = 4;
                nudAgioFees.Increment = 0.0001m;
                if (((SavingsBookProduct)product).AgioFees.HasValue)
                {
                    nudAgioFees.Enabled = false;
                    nudAgioFees.Minimum = (decimal)((SavingsBookProduct)product).AgioFees.Value * 100;
                    nudAgioFees.Maximum = (decimal)((SavingsBookProduct)product).AgioFees.Value * 100;
                    lbAgioFeesMinMax.Text = string.Format("{0} {1}", ((SavingsBookProduct)product).AgioFees * 100, "%");
                }
                else
                {
                    nudAgioFees.Enabled = true;
                    nudAgioFees.Minimum = (decimal)((SavingsBookProduct)product).AgioFeesMin.Value * 100;
                    nudAgioFees.Maximum = (decimal)((SavingsBookProduct)product).AgioFeesMax.Value * 100;
                    lbAgioFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                        "Min ", ((SavingsBookProduct)product).AgioFeesMin * 100,
                        "Max ", ((SavingsBookProduct)product).AgioFeesMax * 100, "%");
                }

                //Reopen fees
                nudReopenFees.DecimalPlaces = 0;
                nudReopenFees.Increment = 1;

                if (((SavingsBookProduct)product).ReopenFees.HasValue)
                {
                    nudReopenFees.Enabled = false;
                    nudReopenFees.Minimum = ((SavingsBookProduct)product).ReopenFees.Value;
                    nudReopenFees.Maximum = ((SavingsBookProduct)product).ReopenFees.Value;
                    lbReopenFeesMinMax.Text = string.Format("{0} {1}",
                                                             ((SavingsBookProduct)product).ReopenFees.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }
                else
                {
                    nudReopenFees.Enabled = true;
                    nudReopenFees.Minimum = ((SavingsBookProduct)product).ReopenFeesMin.Value;
                    nudReopenFees.Maximum = ((SavingsBookProduct)product).ReopenFeesMax.Value;
                    lbReopenFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                                                             "Min ", ((SavingsBookProduct)product).ReopenFeesMin.GetFormatedValue(product.Currency.UseCents),
                                                             "Max ", ((SavingsBookProduct)product).ReopenFeesMax.GetFormatedValue(product.Currency.UseCents),
                                                             product.Currency.Code);
                }

                if (((SavingsBookProduct)product).UseTermDeposit)
                {
                    nudNumberOfPeriods.Enabled = true;
                    btSearchContract2.Enabled = true;
                    cmbRollover2.Enabled = true;
                    nudNumberOfPeriods.Minimum = (decimal)((SavingsBookProduct)product).TermDepositPeriodMin;
                    nudNumberOfPeriods.Maximum = (decimal)((SavingsBookProduct)product).TermDepositPeriodMax;
                    nudNumberOfPeriods.Value = nudNumberOfPeriods.Minimum;
                    tbTargetAccount2.ResetText();
                }

            }
        }
Example #29
0
        private static SavingEvent ReadEvent(OpenCbsReader r, ISavingProduct pProduct)
        {
            string code = r.GetString("code");
            SavingEvent e = GetSavingsEvent(code);
            SetSavingsEvent(r, e, pProduct);

            return e;
        }
        public void SelectAll()
        {
            Account genericAccount  = _accountManager.Select(1);
            Account specificAccount = _accountManager.Select(2);

            EventType      eventType      = _eventManager.SelectEventTypeByEventType("RGLE");
            EventAttribute eventAttribute = _eventManager.SelectEventAttributeByCode("principal");

            #region adding rule 1
            ContractAccountingRule ruleOne = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.All,
                ClientType       = OClientTypes.All,
                BookingDirection = OBookingDirections.Both,
                EventType        = eventType,
                EventAttribute   = eventAttribute
            };
            ruleOne.Id = _accountingRuleManager.AddAccountingRule(ruleOne);
            Assert.AreNotEqual(0, ruleOne.Id);
            #endregion

            #region adding rule 2
            LoanProduct            loanProduct = _loanProductManager.Select(1);
            ContractAccountingRule ruleTwo     = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.Loan,
                LoanProduct      = loanProduct,
                ClientType       = OClientTypes.Corporate,
                BookingDirection = OBookingDirections.Credit,
                EventType        = eventType,
                EventAttribute   = eventAttribute
            };
            ruleTwo.Id = _accountingRuleManager.AddAccountingRule(ruleTwo);
            Assert.AreNotEqual(0, ruleTwo.Id);

            #endregion

            #region adding rule 3
            ContractAccountingRule ruleThree = new ContractAccountingRule
            {
                DebitAccount  = genericAccount,
                CreditAccount = specificAccount,
                //ProductType = OProductTypes.Guarantee,
                ClientType       = OClientTypes.Group,
                BookingDirection = OBookingDirections.Debit,
                EventType        = eventType,
                EventAttribute   = eventAttribute
            };

            ruleThree.Id = _accountingRuleManager.AddAccountingRule(ruleThree);
            Assert.AreNotEqual(0, ruleThree.Id);
            #endregion

            #region adding rule 4
            ISavingProduct         savingsProduct = _savingProductManager.SelectSavingProduct(1);
            ContractAccountingRule ruleFour       = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.Saving,
                SavingProduct    = savingsProduct,
                ClientType       = OClientTypes.Person,
                BookingDirection = OBookingDirections.Both,
                EventType        = eventType,
                EventAttribute   = eventAttribute
            };
            ruleFour.Id = _accountingRuleManager.AddAccountingRule(ruleFour);
            Assert.AreNotEqual(0, ruleFour.Id);
            #endregion

            #region adding rule 5
            EconomicActivity       economicActivty = _economicActivityManager.SelectEconomicActivity(1);
            ContractAccountingRule ruleFive        = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.All,
                ClientType       = OClientTypes.Village,
                EconomicActivity = economicActivty,
                BookingDirection = OBookingDirections.Credit,
                EventType        = eventType,
                EventAttribute   = eventAttribute
            };

            ruleFive.Id = _accountingRuleManager.AddAccountingRule(ruleFive);
            Assert.AreNotEqual(0, ruleFive.Id);
            #endregion

            AccountingRuleCollection rules = _accountingRuleManager.SelectAll();
            Assert.AreEqual(5, rules.Count);

            _compareRules(ruleOne, rules[0] as ContractAccountingRule);
            _compareRules(ruleTwo, rules[1] as ContractAccountingRule);
            _compareRules(ruleThree, rules[2] as ContractAccountingRule);
            _compareRules(ruleFour, rules[3] as ContractAccountingRule);
            _compareRules(ruleFive, rules[4] as ContractAccountingRule);
        }
Example #31
0
        private static void SetSavingsEvent(OpenCbsReader r, SavingEvent e, ISavingProduct pProduct)
        {
            e.Id          = r.GetInt("id");
            e.ContracId   = r.GetInt("contract_id");
            e.Code        = r.GetString("code");
            e.Amount      = r.GetMoney("amount");
            e.Description = r.GetString("description");
            e.Deleted     = r.GetBool("deleted");
            e.Date        = r.GetDateTime("creation_date");
            e.Cancelable  = r.GetBool("cancelable");
            e.IsFired     = r.GetBool("is_fired");
            e.CancelDate  = r.GetNullDateTime("cancel_date");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (r.GetNullSmallInt("savings_method").HasValue)
            {
                e.SavingsMethod = (OSavingsMethods)r.GetNullSmallInt("savings_method").Value;
            }

            e.IsPending      = r.GetBool("pending");
            e.PendingEventId = r.GetNullInt("pending_event_id");
            e.TellerId       = r.GetNullInt("teller_id");
            e.LoanEventId    = r.GetNullInt("loan_event_id");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (e is SavingTransferEvent)
            {
                ((SavingTransferEvent)e).RelatedContractCode = r.GetString("related_contract_code");
            }

            if (e is ISavingsFees)
            {
                ((ISavingsFees)e).Fee = r.GetMoney("fees");
            }

            e.User = new User
            {
                Id        = r.GetInt("user_id"),
                UserName  = r.GetString("user_name"),
                Password  = r.GetString("user_pass"),
                LastName  = r.GetString("last_name"),
                FirstName = r.GetString("first_name")
            };
            e.User.SetRole(r.GetString("role_code"));

            e.ClientType = OClientTypes.All;

            switch (r.GetString("client_type_code"))
            {
            case "I":
                e.ClientType = OClientTypes.Person; break;

            case "C":
                e.ClientType = OClientTypes.Corporate; break;

            case "G":
                e.ClientType = OClientTypes.Group; break;

            case "V":
                e.ClientType = OClientTypes.Village; break;
            }

            e.Branch = new Branch {
                Id = r.GetInt("branch_id")
            };
            e.Currency = new Currency
            {
                Id        = r.GetInt("currency_id"),
                Code      = r.GetString("currency_code"),
                IsPivot   = r.GetBool("is_pivot"),
                IsSwapped = r.GetBool("is_swapped")
            };
            e.SavingProduct = new SavingsBookProduct {
                Id = r.GetInt("product_id")
            };
        }
 private ISavingProduct retrieveSelectedPackage()
 {
     _package         = (ISavingProduct)descriptionListView.SelectedItems[0].Tag;
     _selectedPackage = ServicesProvider.GetInstance().GetSavingProductServices().FindSavingProductById(_package.Id);
     return(_selectedPackage);
 }
        public bool ValidateProduct(ISavingProduct savingsProduct, int clientTypeCounter)
        {
            if (string.IsNullOrEmpty(savingsProduct.Name))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.NameIsEmpty);
            }

            if (string.IsNullOrEmpty(savingsProduct.Code))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CodeIsEmpty);
            }

            if (savingsProduct.Id == 0 && _savingProductManager.IsThisProductNameAlreadyExist(savingsProduct.Name))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.DuplicateProductName);
            }

            if (savingsProduct.Id == 0 && _savingProductManager.IsThisProductCodeAlreadyExist(savingsProduct.Code))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.DuplicateProductCode);
            }

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.InitialAmountMin, savingsProduct.InitialAmountMax, null))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountIsInvalid);
            }

            if (savingsProduct.InitialAmountMin < 0)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMinIsInvalid);
            }

            if (!ServicesHelper.CheckIfValueBetweenMinAndMax(savingsProduct.BalanceMin, savingsProduct.BalanceMax, savingsProduct.InitialAmountMin))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMinNotInBalance);
            }

            if (!ServicesHelper.CheckIfValueBetweenMinAndMax(savingsProduct.BalanceMin, savingsProduct.BalanceMax, savingsProduct.InitialAmountMax))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InitialAmountMaxNotInBalance);
            }

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.BalanceMin, savingsProduct.BalanceMax, null))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.BalanceIsInvalid);
            }

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.InterestRateMin, savingsProduct.InterestRateMax, savingsProduct.InterestRate))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateMinMaxIsInvalid);
            }

            if (savingsProduct.InterestRate.HasValue && savingsProduct.InterestRate < 0)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateIsInvalid);
            }

            if (!savingsProduct.InterestRate.HasValue && savingsProduct.InterestRateMin < 0)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.InterestRateMinIsInvalid);
            }

            if (savingsProduct.Currency == null)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CurrencyIsEmpty);
            }

            if (savingsProduct.Currency.Id == 0)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.CurrencyIsEmpty);
            }

            if (clientTypeCounter < 1)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.ClientTypeIsInvalid);
            }

            if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(savingsProduct.EntryFeesMin, savingsProduct.EntryFeesMax, savingsProduct.EntryFees))
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.EntryFeesMinMaxIsInvalid);
            }

            if (savingsProduct.EntryFees.HasValue && savingsProduct.EntryFees.Value < 0)
            {
                throw new OpenCbsSavingProductException(OpenCbsSavingProductExceptionEnum.EntryFeesIsInvalid);
            }

            if (savingsProduct is SavingsBookProduct)
            {
                ValidateSavingBookProduct((SavingsBookProduct)savingsProduct);
            }
            return(true);
        }
 public int SaveProduct(ISavingProduct savingProduct, int clientTypeCounter)
 {
     _clientTypeCounter = clientTypeCounter;
     return(SaveProduct(savingProduct));
 }
Example #35
0
 public int SaveProduct(ISavingProduct savingProduct,  int clientTypeCounter)
 {
     _clientTypeCounter = clientTypeCounter;
     return SaveProduct(savingProduct);
 }