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 TestCalculateMaximumAmountWithDecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepNotExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 }, 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.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); repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance("")); //30 + 218.35 + 30 * 0.003 * 42 + 218.35 * 0.003 * 14 = 30 + 218 + 4 + 9 = 261 Assert.AreEqual(261, Math.Round(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 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 Declining_BadLoanWith42dayslateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepExpectedInstallment() { 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.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 FlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepExpectedInstallment() { 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 = 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.NonRepaymentPenalties.OverDueInterest = 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 _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); }