public void AddContractRuleForLoanProduct()
        {
            Account        genericAccount  = _accountManager.Select(1);
            Account        specificAccount = _accountManager.Select(2);
            LoanProduct    loanProduct     = _loanProductManager.Select(1);
            EventType      eventType       = _eventManager.SelectEventTypeByEventType("RGLE");
            EventAttribute eventAttribute  = _eventManager.SelectEventAttributeByCode("principal");

            ContractAccountingRule rule = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.Loan,
                LoanProduct      = loanProduct,
                ClientType       = OClientTypes.Corporate,
                BookingDirection = OBookingDirections.Credit,
                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);
        }
        public void UpdateProduct_Values_DontUpdateContracts()
        {
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            LoanProduct loanProduct = loanProductManager.Select(_productWithValues.Id);

            loanProduct.GracePeriod = 8;
            loanProduct.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingInterest;
            loanProduct.AnticipatedTotalRepaymentPenalties     = 33;
            loanProduct.ChargeInterestWithinGracePeriod        = true;
            loanProduct.NbOfInstallments = 5;
            loanProduct.NonRepaymentPenalties.InitialAmount    = 111;
            loanProduct.NonRepaymentPenalties.OLB              = 222;
            loanProduct.NonRepaymentPenalties.OverDueInterest  = 333;
            loanProduct.NonRepaymentPenalties.OverDuePrincipal = 444;
            loanProduct.EntryFees = new List <EntryFee>();
            EntryFee fee = new EntryFee();

            fee.Value   = 2;
            fee.IsAdded = true;
            loanProduct.EntryFees.Add(fee);
            loanProductManager.UpdatePackage(loanProduct, false);
            loanProductManager.InsertEntryFees(loanProduct.EntryFees, loanProduct.Id);
            LoanProduct updatedLoanProduct = loanProductManager.Select(loanProduct.Id);

            updatedLoanProduct.EntryFees = loanProductManager.SelectEntryFeesWithoutCycles(updatedLoanProduct.Id, false);

            AssertLoanProduct(loanProduct, updatedLoanProduct, false);
        }
Beispiel #3
0
 public LoanProduct FindPackage(int idPackage)
 {
     try
     {
         LoanProduct package = _productManager.Select(idPackage);
         if (package == null)
         {
             return(null);
         }
         if (package.FundingLine != null)
         {
             package.FundingLine = _fundingLineManager.SelectFundingLineById(package.FundingLine.Id, false);
         }
         if (package.CycleId != null)
         {
             package.LoanAmountCycleParams = _productManager.SelectLoanAmountCycleParams((int)package.CycleId);
             package.RateCycleParams       = _productManager.SelectRateCycleParams((int)package.CycleId);
             package.MaturityCycleParams   = _productManager.SelectMaturityCycleParams((int)package.CycleId);
         }
         GetEntryFees(package);
         return(package);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
        public void DeleteProduct()
        {
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            loanProductManager.DeleteProduct(1);

            LoanProduct deletedProduct = loanProductManager.Select(1);

            Assert.IsTrue(deletedProduct.Delete);
        }
        public void SelectProduct_Values()
        {
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            LoanProduct loanProduct = loanProductManager.Select(_productWithValues.Id);
            EntryFee    entryFee    = new EntryFee();

            entryFee.Value        = 3;
            loanProduct.EntryFees = new List <EntryFee>();
            loanProduct.EntryFees.Add(entryFee);
            AssertLoanProduct(_productWithValues, loanProduct, false);
        }
        public void SelectProduct_Values_ExoticInstallmentsTable_AmountCyclesStock()
        {
            Assert.Ignore();
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            _productWithValues.ExoticProduct = _exoticInstallmentsTable;
//            _productWithValues.AmountCycles = _amountCycleStock;
            _productWithValues.Amount   = null;
            _productWithValues.Name     = "Test";
            _productWithValues.Currency = new Currency {
                Id = 1
            };
            _productWithValues.Id = loanProductManager.Add(_productWithValues);

            LoanProduct selectedProduct = loanProductManager.Select(_productWithValues.Id);

            selectedProduct.EntryFees = new List <EntryFee>();
            EntryFee entryFee = new EntryFee();

            entryFee.Value = 3;
            selectedProduct.EntryFees.Add(entryFee);

            AssertLoanProduct(_productWithValues, selectedProduct, true);
        }
        private ContractAccountingRule SelectContractAccountingRule(int pId)
        {
            const string sqlText = @"SELECT AccountingRules.id,
                                            AccountingRules.debit_account_number_id, 
                                            AccountingRules.credit_account_number_id,
                                            AccountingRules.booking_direction,
                                            AccountingRules.event_type,
                                            AccountingRules.event_attribute_id,
                                            AccountingRules.[order],
                                            AccountingRules.[description] AS rule_description,
                                            EventAttributes.name AS attribute_name,
                                            EventTypes.description AS event_description,
                                            ContractAccountingRules.product_type, 
                                            ContractAccountingRules.loan_product_id, 
                                            ContractAccountingRules.savings_product_id, 
                                            ContractAccountingRules.client_type, 
                                            ContractAccountingRules.activity_id,
                                            ContractAccountingRules.currency_id
                                    FROM AccountingRules
                                    INNER JOIN EventAttributes ON EventAttributes.id = AccountingRules.event_attribute_id
                                    INNER JOIN EventTypes ON AccountingRules.event_type = EventTypes.event_type
                                    LEFT JOIN ContractAccountingRules ON AccountingRules.id = ContractAccountingRules.id                                    
                                    WHERE AccountingRules.id = @id";

            ContractAccountingRule rule;

            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand select = new OpenCbsCommand(sqlText, conn))
                {
                    select.AddParam("@id", pId);

                    using (OpenCbsReader reader = select.ExecuteReader())
                    {
                        if (reader.Empty)
                        {
                            return(null);
                        }

                        reader.Read();
                        rule = GetContractAccountingRule(reader);
                    }
                }
            }

            if (rule.LoanProduct != null)
            {
                rule.LoanProduct = _loanProductManager.Select(rule.LoanProduct.Id);
            }

            if (rule.Currency != null)
            {
                rule.Currency = _currencyManager.SelectCurrencyById(rule.Currency.Id);
            }
            if (rule.Currency == null)
            {
                rule.Currency = null;
            }


            if (rule.SavingProduct != null)
            {
                rule.SavingProduct = _savingProductManager.SelectSavingProduct(rule.SavingProduct.Id);
            }

            if (rule.EconomicActivity != null)
            {
                rule.EconomicActivity = _economicActivityManager.SelectEconomicActivity(rule.EconomicActivity.Id);
            }

            if (rule.PaymentMethod.Id != 0)
            {
                rule.PaymentMethod = _paymentMethodManager.SelectPaymentMethodById(rule.PaymentMethod.Id);
            }

            return(rule);
        }