public CreditContractRepayment(Loan contract, CreditContractOptions creditOptions, DateTime pDate, int pInstallmentNumber, User user, ApplicationSettings pGeneralSettings, NonWorkingDateSingleton pNonWorkingDate) { _generalSettings = pGeneralSettings; _nWds = pNonWorkingDate; _date = pDate.Date; _installmentNumber = pInstallmentNumber; PaidIstallments = new List <Installment>(); _amountToRepayTotalyLoan = new CalculateMaximumAmountToRepayStrategy(creditOptions, contract.Copy(), user, _generalSettings, _nWds); _amountToRegradingLoan = new CalculateMaximumAmountToRegradingLoanStrategy(creditOptions, contract.Copy(), user, _generalSettings, _nWds); _amountToRepayInstallment = new CalculateAmountToRepaySpecifiedInstallmentStrategy(creditOptions, contract.Copy(), user, _generalSettings, _nWds); _calculateInstallments = new Repayment.RepayLateInstallments.CalculateInstallments(creditOptions, contract, user, _generalSettings, _nWds); _calculateRealInterestInstallments = new CalculateRealInterestInstallments(creditOptions, _amountToRepayTotalyLoan, contract, _generalSettings, _nWds); _feesForAnticipatedRepayment = new CalculateAnticipatedFeesStrategy(creditOptions, contract, _generalSettings); _repayNextInstallments = new RepayNextInstallmentsStrategy(contract, creditOptions, user, _generalSettings); _repaymentMethod = new RepaymentMethod(contract, creditOptions); _loan = contract; CalculateMaximumAmountAuthorizedToRepay(); CalculateAmountToRegradingLoan(); CalculateMaximumAmountForEscapedMember(); LoanOptions = creditOptions; }
public CreditContractRepayment(Loan contract, CreditContractOptions creditOptions, DateTime pDate,int pInstallmentNumber, User user, ApplicationSettings pGeneralSettings,NonWorkingDateSingleton pNonWorkingDate) { _generalSettings = pGeneralSettings; _nWds = pNonWorkingDate; _date = pDate.Date; _installmentNumber = pInstallmentNumber; PaidIstallments = new List<Installment>(); _amountToRepayTotalyLoan = new CalculateMaximumAmountToRepayStrategy(creditOptions, contract.Copy(), user, _generalSettings,_nWds); _amountToRegradingLoan = new CalculateMaximumAmountToRegradingLoanStrategy(creditOptions, contract.Copy(), user, _generalSettings, _nWds); _amountToRepayInstallment = new CalculateAmountToRepaySpecifiedInstallmentStrategy(creditOptions, contract.Copy(), user, _generalSettings, _nWds); _calculateInstallments = new Repayment.RepayLateInstallments.CalculateInstallments(creditOptions, contract, user, _generalSettings, _nWds); _calculateRealInterestInstallments = new CalculateRealInterestInstallments(creditOptions, _amountToRepayTotalyLoan, contract, _generalSettings, _nWds); _feesForAnticipatedRepayment = new CalculateAnticipatedFeesStrategy(creditOptions, contract, _generalSettings); _repayNextInstallments = new RepayNextInstallmentsStrategy(contract, creditOptions, user, _generalSettings); _repaymentMethod = new RepaymentMethod(contract,creditOptions); _loan = contract; CalculateMaximumAmountAuthorizedToRepay(); CalculateAmountToRegradingLoan(); CalculateMaximumAmountForEscapedMember(); LoanOptions = creditOptions; }
public void DecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepNotExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true}, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType,package.KeepExpectedInstallment,false,0,0,false,0,package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 218.35 + 1000 * 0.003 * 42 Assert.AreEqual(374.35m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value); }
public void TestCalculateMaximumAmountWithFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepNotExpectedInstallment() { Assert.Ignore(); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase, false, false); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1194, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); Assert.AreEqual(386.00m, Math.Round(cCR.MaximumAmountToRegradingLoan.Value, 2)); RepaymentEvent rPE = myContract.Repay(1, new DateTime(2006, 3, 15), 386.00m, false, false); Assert.AreEqual(0m, rPE.Fees.Value); Assert.AreEqual(30m, rPE.Interests.Value); Assert.AreEqual(356m, rPE.Principal.Value); CreditContractRepayment cCR2 = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 4, 3), 3, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(932.09, Math.Round(cCR2.MaximumAmountAuthorizeToRepay.Value, 2)); RepaymentEvent rPE2 = myContract.Repay(1, new DateTime(2006, 4, 3), 836, false, false); Assert.AreEqual(4, rPE2.Fees.Value); Assert.AreEqual(90, rPE2.Interests.Value); Assert.AreEqual(742, rPE2.Principal.Value); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); }
private static OpenCBS.CoreDomain.Contracts.Loans.LoanRepayment.Repayment.RepayLateInstallments.CalculateInstallments _SetRepaymentOptions(Loan pContract, bool pCancelFees) { CreditContractOptions cCO = new CreditContractOptions(pContract.Product.LoanType, pContract.Product.KeepExpectedInstallment, pCancelFees, 0, 0, false, 0, pContract.Product.AnticipatedTotalRepaymentPenaltiesBase); return new OpenCBS.CoreDomain.Contracts.Loans.LoanRepayment.Repayment.RepayLateInstallments.CalculateInstallments(cCO, pContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); }
public void TestCalculateMaximumAmountWithDecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithoutInterestAndKeepExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true}, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = true; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0,package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1129.68m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); }
public void CalculateEvent_RepayTotallyDecliningBadLoan_42dayslate_NonRepaymentFeesBaseOnInitialAmount_KeepExpectedInstallment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct{ InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency {Id = 1, UseCents = true}, KeepExpectedInstallment = true, AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB, RoundingType = ORoundingType.Approximate }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0,package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1247.77m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); RepaymentEvent bLRE = myContract.Repay(1, new DateTime(2006, 3, 15), 1247.77m, false, true); Assert.AreEqual(126m, bLRE.Fees.Value); Assert.AreEqual(121.77m, bLRE.Interests.Value); Assert.AreEqual(1000.00m, bLRE.Principal.Value); }
/// <summary> /// This method manages all the repayment cases implemented in the software /// </summary> /// <param name="pNumber">pNumber of the installment paid</param> /// <param name="pDate">pDate of the payment</param> /// <param name="pAmountPaid">amount paid by the client which can be lower, equal or greater than the expected amount for an installment</param> /// <param name="cancelFees">when true, cancel anticipated payment Commission</param> /// <param name="manualFeesAmount">manual amount of commission (when anticipated payment commission are cancelled)</param> /// <returns>A RepaymentEvent or null if : /// - repayment amount lower than 0 /// - repayment amount greater than olb + interestsToPay + commission /// - installment already repaid /// - bad loan and past due days greater than 180 /// </returns> /// <param name="manualCommissionAmount"></param> /// <param name="disableInterests"></param> /// <param name="manualInterests"></param> /// <param name="keepExpectedInstallment"></param> /// <param name="payProportion"></param> /// <param name="paymentMethod"></param> /// <param name="comment"></param> /// <param name="pending"></param> public RepaymentEvent Repay(int pNumber, DateTime pDate, OCurrency pAmountPaid, bool cancelFees, OCurrency manualFeesAmount, OCurrency manualCommissionAmount, bool disableInterests, OCurrency manualInterests, bool keepExpectedInstallment, bool payProportion, PaymentMethod paymentMethod, string comment, bool pending) { OCurrency anticipatePayment = CalculateAnticipateInteresAmountForClosure(pDate, OPaymentType.PartialPayment, payProportion) + CalculateTotalNonRepaymentPenalties(pDate); if (anticipatePayment >= pAmountPaid || (anticipatePayment == 0 && GetInstallment(pNumber - 1).ExpectedDate <= pDate)) { keepExpectedInstallment = true; payProportion = false; } var cCo = new CreditContractOptions(Product.LoanType, keepExpectedInstallment, cancelFees, manualFeesAmount, manualCommissionAmount, disableInterests, manualInterests, Product.AnticipatedTotalRepaymentPenaltiesBase, Product.IsExotic, payProportion); var cCr = new CreditContractRepayment(this, cCo, pDate, pNumber, _user, _generalSettings, _nwdS); if (AmountComparer.Compare(pAmountPaid, cCr.MaximumAmountAuthorizeToRepay, pNumber) > 0) { return null; } OCurrency principalEvent = 0; OCurrency interestEvent = 0; OCurrency interestPrepayment = 0; OCurrency penaltiesEvent = 0; OCurrency commissionsEvent = 0; OCurrency manualInterestEvent = cCo.ManualInterestsAmount; int pastDueDays = CalculatePastDueSinceLastRepayment(pDate); OPaymentType paymentType = OPaymentType.StandardPayment; foreach (Installment installment in InstallmentList) { if (!installment.IsRepaid && installment.Number == pNumber && !keepExpectedInstallment) { paymentType = OPaymentType.PartialPayment; } } //we have total repayment for a person if(EscapedMember != null) { paymentType = OPaymentType.PartialPayment; keepExpectedInstallment = false; cCo.KeepExpectedInstallments = false; } if (AmountComparer.Compare(pAmountPaid, cCr.MaximumAmountAuthorizeToRepay, pNumber) == 0 && !keepExpectedInstallment) { paymentType = OPaymentType.TotalPayment; } if (payProportion && _product.LoanType == OLoanTypes.DecliningFixedPrincipal) { paymentType = OPaymentType.ProportionalPayment; keepExpectedInstallment = false; cCo.KeepExpectedInstallments = false; } if (_product.LoanType == OLoanTypes.DecliningFixedPrincipalWithRealInterest) paymentType = OPaymentType.StandardPayment; // We have to calculate penalties here because // once the repayment is done it is impossible to do // reliably afterward. These values are later used (see below) // during the event generation. cCr.Repay(pAmountPaid, ref penaltiesEvent, ref commissionsEvent, ref interestEvent, ref interestPrepayment, ref principalEvent, ref manualInterestEvent, ref paymentType); //this part of code to correct calculation of principal OCurrency principalAmount = principalEvent; foreach (RepaymentEvent rPayment in Events.GetRepaymentEvents()) { if (!rPayment.Deleted) principalAmount += rPayment.Principal; if (principalAmount > Amount) { principalEvent -= Math.Round(principalAmount.Value, 2) - Amount; } } // when we keep initial schedule and total payment if (AmountComparer.Compare(pAmountPaid, cCr.MaximumAmountAuthorizeToRepay, pNumber) == 0 && (pNumber != InstallmentList.Count) && AllInstallmentsRepaid) { paymentType = OPaymentType.TotalPayment; } ////////////////////////////////////////////////////////////// RepaymentEvent rPe = CreateRepaymentEvent(pNumber, pDate, penaltiesEvent, commissionsEvent, interestEvent, interestPrepayment, principalEvent, pastDueDays, _clientType == OClientTypes.Group, paymentType, pending); if (AllInstallmentsRepaid && !pending) { if (ContractStatus != OContractStatus.WrittenOff) { _closed = true; ContractStatus = OContractStatus.Closed; CloseDate = pDate; } // check if Client has other 'active' loans if so, mark him as active client if (Project != null) foreach (var loan in Project.Credits) Project.Client.Active = loan.ContractStatus == OContractStatus.Active; } //Event identification Events.Add(GenerateRepaymentEvents(cCr, pDate, penaltiesEvent, commissionsEvent, interestEvent, interestPrepayment, principalEvent, pastDueDays, paymentType, pending, pNumber, paymentMethod, cancelFees, manualFeesAmount, manualInterestEvent, ref rPe)); if (paymentType == OPaymentType.TotalPayment) { int installmentNumber = penaltiesEvent > 0 ? 0 : 1; Events.Add(GenerateCreditInsuranceEvent(installmentNumber)); if (HasCompulsoryAmount()) { SavingBlockCompulsarySavingsEvent savingBlockEvent = CompulsorySavings.GetBlockCompulsorySavingEvent(); if (savingBlockEvent != null) CompulsorySavings.GenerateUnblockCompulsoruSavingEvent(_user, true); } } //principal amount correction in case of shit which is taken place when we do big prepayment //please remove it when all shity contracts will be closed OCurrency paidPrincipal = 0; foreach (RepaymentEvent repaymentEvent in Events.GetLoanRepaymentEvents()) { if(repaymentEvent.Deleted == false) { paidPrincipal += repaymentEvent.Principal; } if(paidPrincipal > Amount) { repaymentEvent.Principal += Amount - paidPrincipal; } } ////////////////////////////////////////////////////////////////////////////////////////////// _installmentList.Sort((x, y) => x.ExpectedDate.CompareTo(y.ExpectedDate)); foreach (Installment installment in InstallmentList) { //setup paid date for installments if (installment.IsRepaid && installment.Number > pNumber) { installment.PaidDate = pDate; installment.Comment = comment; installment.IsPending = pending; } else if (installment.Number == pNumber) { installment.PaidDate = pDate; installment.Comment = comment; installment.IsPending = pending; } installment.OLB = CalculateExpectedOlb(installment.Number, keepExpectedInstallment); } EscapedMember = null; return rPe; }
public void TestRepayFlatLoanWhenCalculateFeesWithDelta2() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency {Id = 1}, KeepExpectedInstallment = false }; Loan myContract = new Loan(package, 600, 0.03m, 6, 0, new DateTime(2006, 1, 4), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())) { BadLoan = false, NonRepaymentPenalties = {OverDueInterest = 0.02, OverDuePrincipal = 0.02}, AnticipatedTotalRepaymentPenalties = 0 }; Assert.AreEqual(new DateTime(2006, 2, 6), myContract.GetInstallment(0).ExpectedDate); RepaymentEvent rPE = myContract.Repay(1, new DateTime(2006, 3, 6), 50, false, false); Assert.AreEqual(50m, rPE.Fees.Value); Assert.AreEqual(0m, rPE.Interests.Value); Assert.AreEqual(0m, rPE.Principal.Value); CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 4, 4), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(414m, cCR.MaximumAmountToRegradingLoan.Value); }
private static CreditContractRepayment _SetRepaymentOptions(Loan pContract, DateTime pDate, int pInstallmentNumber, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pCancelInterest, OCurrency pManualInterestAmount) { CreditContractOptions cCO = new CreditContractOptions(pContract.Product.LoanType, pContract.Product.KeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pCancelInterest, pManualInterestAmount, pContract.Product.AnticipatedTotalRepaymentPenaltiesBase); return new CreditContractRepayment(pContract, cCO, pDate, pInstallmentNumber, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); }
public void FlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepNotExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDueInterest = 0.003; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", true); CreditContractOptions cCO = new CreditContractOptions(package.LoanType,package.KeepExpectedInstallment,false, 0, 0, false,0,package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 230 + 30 * 0.003 * 42 + 230 * 0.003 *14 Assert.AreEqual(273.44m, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); //NOT CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", false); //30 + 230 + 30 * 0.003 * 36 + 230 * 0.003 *12 Assert.AreEqual(270.74m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value); }
public void Flate_BadLoan_42dayslate_OnOLB_KeepNotExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OLB = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType,package.KeepExpectedInstallment,false,0,0,false,0,package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 230 + 1000 * 0.003 * 42 = 386 Assert.AreEqual(386, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); }
public void TestCalculateMaximumAmountWithFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithoutInterestAndKeepExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = true; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); this.repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, false); //30 + 230 + 200 * 0.003 * 12 = 268.4 => 267 // Assert.AreEqual(267, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); Assert.AreEqual(267, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 0)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); //30 + 230 + 200 * 0.003 * 14 = 268.4 => 268 Assert.AreEqual(268, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); }
public void DecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithoutInterestAndKeepExpectedInstallment2() { ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true}, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = true; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(256.26m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value); //30 + 218.35 + 188.35 * 1.003 * 14 //30+218.3546 ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", false); cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(254.57m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value); }
public void TestCalculateMaximumAmountWithFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepNotExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDueInterest = 0.003; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); this.repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 230 + 30 * 0.003 * 42 + 230 * 0.003 *14 = 30 + 230 + 3.78 + 9.66 = 273.44=> 30 + 230 + 4 + 10 = 274 Assert.AreEqual(273, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); }
public void TestCalculateMaximumAmountWithFlateBadLoanWith42DaysLateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepExpectedInstallmentAndCancelFeesSetToFalse() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = true; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package,1000,0.03m,6,1,new DateTime(2006,1,1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.0123; myContract.AnticipatedTotalRepaymentPenalties = 0.01; //42 days late CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); this.repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 230 + 1000 * 0.0123 * 42 = 776.6 => 777 // Assert.AreEqual(777, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); Assert.AreEqual(777, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 0)); }
public OCurrency CalculateAmountToRepaySpecifiedInstallment(int pNumber, DateTime pDate, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pDisableInterests, OCurrency pManualInterests, bool pKeepExpectedInstallment) { CreditContractOptions cCo = new CreditContractOptions(Product.LoanType, pKeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pDisableInterests, pManualInterests, Product.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCr = new CreditContractRepayment(this, cCo, pDate, pNumber, _user, _generalSettings, _nwdS); return cCr.AmountToRepayInstallment; }
public void TestRepayDecliningLoanWhenKeepExpectedInstallmentButEntirlyPaidButNoCancelFees() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = true, Currency = new Currency { Id = 1, UseCents = true} }; Loan myContract = new Loan(package, 1000, 0.03m, 7, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())) { AnticipatedTotalRepaymentPenalties = 0.003, NonRepaymentPenalties = { InitialAmount = 0.003 } }; myContract.Repay(1, new DateTime(2006, 2, 1), 30, true, false); CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 1), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1107.58m, cCR.MaximumAmountAuthorizeToRepay.Value); RepaymentEvent repayEvent = myContract.Repay(2, new DateTime(2006, 3, 1), 1107.58m, false, true); Assert.AreEqual(0m, repayEvent.Fees.Value); Assert.AreEqual(107.58m, repayEvent.Interests.Value); Assert.AreEqual(1000m, repayEvent.Principal.Value); Assert.AreEqual(30m, myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(0m, myContract.GetInstallment(0).CapitalRepayment.Value); Assert.AreEqual(1000m, myContract.GetInstallment(0).OLB.Value); Assert.AreEqual(0m, myContract.GetInstallment(0).PaidCapital.Value); Assert.AreEqual(30m, myContract.GetInstallment(0).PaidInterests.Value); Assert.AreEqual(30m, myContract.GetInstallment(1).InterestsRepayment.Value); Assert.AreEqual(154.60m, myContract.GetInstallment(1).CapitalRepayment.Value); Assert.AreEqual(1000m, myContract.GetInstallment(1).OLB.Value); Assert.AreEqual(154.60m, myContract.GetInstallment(1).PaidCapital.Value); Assert.AreEqual(30m, myContract.GetInstallment(1).PaidInterests.Value); Assert.AreEqual(25.36m, myContract.GetInstallment(2).InterestsRepayment.Value); Assert.AreEqual(159.24m, myContract.GetInstallment(2).CapitalRepayment.Value); Assert.AreEqual(845.40m, myContract.GetInstallment(2).OLB.Value); Assert.AreEqual(159.24m, myContract.GetInstallment(2).PaidCapital.Value); Assert.AreEqual(25.36m, myContract.GetInstallment(2).PaidInterests.Value); Assert.AreEqual(20.58m, myContract.GetInstallment(3).InterestsRepayment.Value); Assert.AreEqual(164.02m, myContract.GetInstallment(3).CapitalRepayment.Value); Assert.AreEqual(686.16m, myContract.GetInstallment(3).OLB.Value); Assert.AreEqual(164.02m, myContract.GetInstallment(3).PaidCapital.Value); Assert.AreEqual(20.58m, myContract.GetInstallment(3).PaidInterests.Value); Assert.AreEqual(15.66m, myContract.GetInstallment(4).InterestsRepayment.Value); Assert.AreEqual(168.93m, myContract.GetInstallment(4).CapitalRepayment.Value); Assert.AreEqual(522.14m, myContract.GetInstallment(4).OLB.Value); Assert.AreEqual(168.93m, myContract.GetInstallment(4).PaidCapital.Value); Assert.AreEqual(15.66m, myContract.GetInstallment(4).PaidInterests.Value); Assert.AreEqual(10.60m, myContract.GetInstallment(5).InterestsRepayment.Value); Assert.AreEqual(173.99m, myContract.GetInstallment(5).CapitalRepayment.Value); Assert.AreEqual(353.21m, myContract.GetInstallment(5).OLB.Value); Assert.AreEqual(173.99m, myContract.GetInstallment(5).PaidCapital.Value); Assert.AreEqual(10.60m, myContract.GetInstallment(5).PaidInterests.Value); Assert.AreEqual(5.38m, myContract.GetInstallment(6).InterestsRepayment.Value); Assert.AreEqual(179.22m, myContract.GetInstallment(6).CapitalRepayment.Value); Assert.AreEqual(179.22m, myContract.GetInstallment(6).OLB.Value); Assert.AreEqual(179.22m, myContract.GetInstallment(6).PaidCapital.Value); Assert.AreEqual(5.38m, myContract.GetInstallment(6).PaidInterests.Value); }
public void _Flate_BadLoan_42dayslate_BasedOnOverDueWithoutInterest_KeepExpectedInstallment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency {Id = 1, UseCents = true}, KeepExpectedInstallment = true, AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())) { BadLoan = true, NonRepaymentPenalties = {OverDuePrincipal = 0.003}, AnticipatedTotalRepaymentPenalties = 0.01 }; CreditContractOptions cCO = new CreditContractOptions(package.LoanType,package.KeepExpectedInstallment,false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 230 + 200 * 0.003 * 14 Assert.AreEqual(268.4m, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); //NOT CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, false); //30 + 230 + 200 * 0.003 * 12 Assert.AreEqual(266.60m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value); }
public void TestRepayFlatLoan2() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1194,Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value,2)); Assert.AreEqual(386,Math.Round(cCR.MaximumAmountToRegradingLoan.Value,2)); Assert.AreEqual(42, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 3, 15))); RepaymentEvent rPE = myContract.Repay(1,new DateTime(2006,3,15),386,false,false); Assert.AreEqual(126m,rPE.Fees.Value); Assert.AreEqual(60m,rPE.Interests.Value); Assert.AreEqual(200m,rPE.Principal.Value); Assert.IsFalse(myContract.BadLoan); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 3, 15))); CreditContractRepayment cCR2 = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 3, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(0, Math.Round(cCR2.MaximumAmountToRegradingLoan.Value,2)); Assert.AreEqual(808, Math.Round(cCR2.MaximumAmountAuthorizeToRepay.Value,2)); RepaymentEvent rPE2 = myContract.Repay(3,new DateTime(2006,3,15), 808m, false, false); Assert.AreEqual(8m, rPE2.Fees.Value); Assert.AreEqual(0m, rPE2.Interests.Value); Assert.AreEqual(800m, rPE2.Principal.Value); Assert.IsTrue(myContract.AllInstallmentsRepaid); }
public void TestCalculateMaximumAmountWhenRepayFlatLoanWith1MonthLate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = false; myContract.AnticipatedTotalRepaymentPenalties = 0.03; myContract.Repay(1, new DateTime(2006, 2, 1), 30, false, false); CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 4, 3), 2, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1078, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); }
public void TestTotalAnticipatedRepaymentFormerPrepaymentSameDayDecliningCash() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, GracePeriod = 0, Currency = new Currency { Id = 1, UseCents = true} }; package.KeepExpectedInstallment = true; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 1, 1), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1107.58m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); RepaymentEvent bLRE = myContract.Repay(1, new DateTime(2006, 1, 1), 194.60m, false, true); Assert.AreEqual(0, bLRE.Fees.Value); Assert.AreEqual(40m, bLRE.Interests.Value); Assert.AreEqual(154.60, bLRE.Principal.Value); cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 1, 1), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(912.98m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); bLRE = myContract.Repay(2, new DateTime(2006, 1, 1), 912.98m, true, true); Assert.AreEqual(0, bLRE.Fees.Value); Assert.AreEqual(67.58m, bLRE.Interests.Value); Assert.AreEqual(845.40m, bLRE.Principal.Value); }
private static OpenCBS.CoreDomain.Contracts.Loans.LoanRepayment.Repayment.RepayLateInstallments.CalculateInstallments _SetRepaymentOptions(Loan pContract, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pCancelInterest, OCurrency pManualInterestAmount) { var cCO = new CreditContractOptions(pContract.Product.LoanType, pContract.Product.KeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pCancelInterest, pManualInterestAmount, pContract.Product.AnticipatedTotalRepaymentPenaltiesBase); return new OpenCBS.CoreDomain.Contracts.Loans.LoanRepayment.Repayment.RepayLateInstallments.CalculateInstallments(cCO, pContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); }
public void DecliningRate_OneMonthlate_FeesBasedOnOverdueAmountAndInterest_KeepNotExpectedInstallment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true}, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = false; Loan myContract = new Loan(package, 600, 0.03m, 6, 0, new DateTime(2006, 1, 4), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.0016277; myContract.NonRepaymentPenalties.OverDueInterest = 0.0016277; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0,package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 6), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(227.78m, cCR.MaximumAmountToRegradingLoan.Value); }
public OCurrency CalculateMaximumAmountAuthorizedToRepay(int pNumber, DateTime pDate, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pDisableInterests, OCurrency pManualInterests, bool pKeepExpectedInstallment, bool pIsForExoticProduct) { Loan fakeLoan = Copy(); if (_generalSettings.AccountingProcesses == OAccountingProcesses.Accrual && !pKeepExpectedInstallment) { fakeLoan.CreateLoanInterestAccruingEvent(pDate); } CreditContractOptions cCo = new CreditContractOptions(Product.LoanType, pKeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pDisableInterests, pManualInterests, Product.AnticipatedTotalRepaymentPenaltiesBase, pIsForExoticProduct, false); CreditContractRepayment cCr = new CreditContractRepayment(fakeLoan, cCo, pDate, pNumber, _user, _generalSettings, _nwdS); return cCr.MaximumAmountAuthorizeToRepay; }
public void TestCalculateEventWhenRepayTotallyFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithoutIntereestAndKeepNotExpectedInstallment() { Assert.Ignore(); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1076.4m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); RepaymentEvent bLRE = myContract.Repay(1, new DateTime(2006, 3, 15), 1076.4m, false, false); Assert.AreEqual(16.40m, bLRE.Fees.Value); Assert.AreEqual(60, bLRE.Interests.Value); Assert.AreEqual(1000, bLRE.Principal.Value); }
public OCurrency CalculateMaximumAmountForEscapedMember(int pNumber, DateTime pDate, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pDisableInterests, OCurrency pManualInterests, bool pKeepExpectedInstallment, OCurrency pLoanShareAmount) { var cCo = new CreditContractOptions(Product.LoanType, pKeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pDisableInterests, pManualInterests, Product.AnticipatedTotalRepaymentPenaltiesBase, Product.IsExotic, false); var cCr = new CreditContractRepayment(this, cCo, pDate, pNumber, _user, _generalSettings, _nwdS); return cCr.MaximumAmountForEscapedMember; }
public void TestCalculateMaximumAmountWithDecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepNotExpectedInstallment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true }, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.InitialAmount = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0,package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1194.12m, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); }
private static CalculateMaximumAmountToRepayStrategy _MaximumAmountToRepay(Loan pContract, bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount, bool pCancelInterest, OCurrency pManualInterestAmount) { CreditContractOptions cCO = new CreditContractOptions(pContract.Product.LoanType, pContract.Product.KeepExpectedInstallment, pCancelFees, pManualFeesAmount, pManualCommissionAmount, pCancelInterest, pManualInterestAmount, pContract.Product.AnticipatedTotalRepaymentPenaltiesBase); return new CalculateMaximumAmountToRepayStrategy(cCO, pContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); }
public void TestBadLoanAndGoBackToNormal() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = true; myContract.NonRepaymentPenalties.OLB = 0.003; myContract.AnticipatedTotalRepaymentPenalties = 0.01; CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase); CreditContractRepayment cCR = new CreditContractRepayment(myContract, cCO, new DateTime(2006, 3, 15), 1, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); Assert.AreEqual(1194, Math.Round(cCR.MaximumAmountAuthorizeToRepay.Value, 2)); Assert.AreEqual(386.00m, Math.Round(cCR.MaximumAmountToRegradingLoan.Value, 2)); RepaymentEvent rPE = myContract.Repay(1,new DateTime(2006,3,15),386,false,true); Assert.AreEqual(126,rPE.Fees.Value); Assert.AreEqual(60,rPE.Interests.Value); Assert.AreEqual(200,rPE.Principal.Value); }
private static CalculateAnticipatedFeesStrategy _SetFeesCalculationOptions(Loan pContract, bool pCancelFees) { CreditContractOptions cCO = new CreditContractOptions(pContract.Product.LoanType, pContract.Product.KeepExpectedInstallment, pCancelFees, 0, 0, false, 0, pContract.Product.AnticipatedTotalRepaymentPenaltiesBase); return new CalculateAnticipatedFeesStrategy(cCO, pContract, ApplicationSettings.GetInstance("")); }