public void TestFixtureSetUp() { mockContractManagement = new DynamicMock(typeof(LoanManager)); chartOfAccounts = ChartOfAccounts.GetInstance(new User { Id = 5 }); }
public void Flate_BadLoan_42dayslate_BasedOnOLB_KeepExpectedInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = true, AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB, Currency = new Currency { Id = 1 } }; 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 = { OLB = 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 + 1000 * 0.003 * 42 = 386 Assert.AreEqual(386, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2)); }
private static Loan _SetContract(OLoanTypes pLoansType, NonRepaymentPenalties pNonRepaymentPenalties, bool pKeepExpectedInstallment) { var package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = pLoansType, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true }, RoundingType = ORoundingType.Approximate }; package.KeepExpectedInstallment = pKeepExpectedInstallment; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; var 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.AnticipatedTotalRepaymentPenalties = 0.01; myContract.NonRepaymentPenalties = pNonRepaymentPenalties; return(myContract); }
private static Loan _GetLoan(LoanProduct product, OCurrency amount, decimal interestRate, int installments, DateTime startDate) { return(new Loan(product, amount, interestRate, installments, 0, startDate, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()))); }
public void SetUp() { ChartOfAccounts.GetInstance(new User()).Accounts.Clear(); ApplicationSettings dataParam = ApplicationSettings.GetInstance(""); dataParam.DeleteAllParameters(); dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); }
public void testFixtureSetUp() { Loan credit = new Loan(new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); credit.Id = 4; _installmentsOptions = new CalculateInstallmentsOptions(credit.StartDate, OLoanTypes.Flat, true, credit, false); }
public void TestIfLocalAccountNumberCorrectlyRetrievedWhenDisburse() { ChartOfAccounts chartOfAccounts = ChartOfAccounts.GetInstance(User.CurrentUser); CashReceipt cashReceipt = new CashReceipt(contractForAPerson, _person, null, "USD", "en-US", null, new DateTime(2006, 1, 1), false, User.CurrentUser, GeneralSettings.GetInstance(""), ChartOfAccounts.GetInstance(User.CurrentUser), true); Assert.AreEqual(String.Empty, cashReceipt.InterestLocalAccountNumber); Assert.AreEqual(chartOfAccounts.GetAccountByTypeCode("CASH").LocalNumber, cashReceipt.PrincipalLocalAccountNumber); Assert.AreEqual(chartOfAccounts.GetAccountByTypeCode("COMMISSIONS").LocalNumber, cashReceipt.FeesLocalAccountNumber); }
public FundingLine AddGenericFundingLineWithThreeEvents(DateTime startDate) { ChartOfAccounts _chartOfAccounts = ChartOfAccounts.GetInstance(new User { Id = 5 }); AccountManager accountManager = new AccountManager(new User { Id = 5 }); _chartOfAccounts.Accounts = accountManager.SelectAllAccounts(); FundingLineServices service = new FundingLineServices(new User { Id = 5 }); int newFL_ID = AddGenericFundingLine4(); FundingLine fundingLineInitial = service.SelectFundingLineById(newFL_ID, true); FundingLineEvent ev0 = new FundingLineEvent(); ev0.Code = "6012"; ev0.CreationDate = startDate.AddDays(-2); ev0.Amount = 1000; ev0.Movement = OBookingDirections.Credit; ev0.Type = OFundingLineEventTypes.Entry; ev0.FundingLine = fundingLineInitial; ev0.IsDeleted = false; fundingLineInitial.AddEvent(service.AddFundingLineEvent(ev0)); FundingLineEvent ev1 = new FundingLineEvent(); ev1.Code = "6013"; ev1.CreationDate = startDate.AddDays(-1); ev1.Amount = 500; ev1.Movement = OBookingDirections.Debit; ev1.Type = OFundingLineEventTypes.Disbursment; ev1.FundingLine = fundingLineInitial; ev1.IsDeleted = false; fundingLineInitial.AddEvent(service.AddFundingLineEvent(ev1)); FundingLineEvent ev2 = new FundingLineEvent(); ev2.Code = "6014"; ev2.CreationDate = startDate; ev2.Amount = 100; ev2.Movement = OBookingDirections.Credit; ev2.Type = OFundingLineEventTypes.Repay; ev2.FundingLine = fundingLineInitial; ev2.IsDeleted = false; fundingLineInitial.AddEvent(service.AddFundingLineEvent(ev2)); return(fundingLineInitial); }
public void TestIfLocalAccountNumberCorrectlyRetrievedWhenRepayAGoodLoan() { ChartOfAccounts chartOfAccounts = ChartOfAccounts.GetInstance(User.CurrentUser); Credit contract = contractForAPerson.Copy(); contract.Disburse(new DateTime(2006, 1, 1), true, false); CashReceipt cashReceipt = new CashReceipt(contract, _person, 0, "USD", "en-US", new ExchangeRate(new DateTime(2006, 3, 1), 3), new DateTime(2006, 3, 1), false, User.CurrentUser, GeneralSettings.GetInstance(""), ChartOfAccounts.GetInstance(User.CurrentUser), true); Assert.AreEqual(chartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_CASH_CREDIT_INDIVIDUAL_LOAN).LocalNumber, cashReceipt.InterestLocalAccountNumber); Assert.AreEqual(chartOfAccounts.GetAccountByNumber(OAccounts.CASH_CREDIT_INDIVIDUAL_LOAN).LocalNumber, cashReceipt.PrincipalLocalAccountNumber); Assert.AreEqual(chartOfAccounts.GetAccountByTypeCode("COMMISSIONS").LocalNumber, cashReceipt.FeesLocalAccountNumber); }
public double[] CalculateRealPrevisionCurve(DateTime pFirstDate, int pForecastDays) { double[] realAmount = new double[pForecastDays]; double initialAmount = Convert.ToDouble(ChartOfAccounts.GetInstance(_user).GetPivotBalance(OAccounts.CASH).Value); double[] realDisbursment = CalculateRealDisbursmentCurve(pFirstDate, pForecastDays); double[] realRepay = CalculateRealRepayCurve(pFirstDate, pForecastDays); for (int i = 0; i < pForecastDays; i++) { realAmount[i] = initialAmount - realDisbursment[i] + realRepay[i]; } return(realAmount); }
public void WhenICreateALoan(Table table) { _loanProduct.RoundingType = ParseTableValue <ORoundingType>(table, "Rounding"); _loan = new Loan(_loanProduct, ParseTableValue <decimal>(table, "Amount"), ParseTableValue <decimal>(table, "Interest rate") / 1200, ParseTableValue <int>(table, "Installments"), ParseTableValue <int>(table, "Grace period"), ParseTableValue <DateTime>(table, "Start date"), ParseTableValue <DateTime>(table, "First installment date"), new User(), Settings, NonWorkingDays, ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _loan.InstallmentList = ServicesProvider.GetInstance().GetContractServices().SimulateScheduleCreation(_loan); }
public void TestFixtureSetUp() { User.CurrentUser = new User(); User.CurrentUser.Id = 1; GeneralSettings dataParam = GeneralSettings.GetInstance(""); dataParam.DeleteAllParameters(); dataParam.AddParameter(OGeneralSettings.USECENTS, true); ChartOfAccounts chartOfAccounts = ChartOfAccounts.GetInstance(User.CurrentUser); chartOfAccounts.Accounts = chartOfAccounts.DefaultAccounts; ProvisioningTable provisioningTable = ProvisioningTable.GetInstance(User.CurrentUser); provisioningTable.AddProvisioningRate(new ProvisioningRate(1, 0, 0, 2)); }
private static Loan _SetContract(OCurrency amount, decimal rate, OLoanTypes loansType, NonRepaymentPenalties nonRepaymentFees, bool keepExpectedInstallment, int numberOfGracePeriod, DateTime stratDate, int nbInstallment) { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = loansType, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = keepExpectedInstallment; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, amount, rate, nbInstallment, numberOfGracePeriod, stratDate, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = false; myContract.AnticipatedTotalRepaymentPenalties = 0; myContract.NonRepaymentPenalties = nonRepaymentFees; return(myContract); }
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 DecliningRate_FixedInstallment_NoGracePeriod_RoundingProblem() { 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 }; Loan myContract = new Loan(package, 100, 0.01m, 10, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 1, 9.56m, 100, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 0.9m, 9.66m, 90.44m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 0.81m, 9.75m, 80.78m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 0.71m, 9.85m, 71.03m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 0.61m, 9.95m, 61.18m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 0.51m, 10.05m, 51.23m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 0.41m, 10.14m, 41.18m, 10.55m); _AssertSpecifiedInstallment(myContract.GetInstallment(7), 8, new DateTime(2006, 9, 1), 0.31m, 10.24m, 31.04m, 10.55m); _AssertSpecifiedInstallment(myContract.GetInstallment(8), 9, new DateTime(2006, 10, 2), 0.21m, 10.35m, 20.8m, 10.56m); _AssertSpecifiedInstallment(myContract.GetInstallment(9), 10, new DateTime(2006, 11, 1), 0.1m, 10.45m, 10.45m, 10.55m); }
public void TestRepayFlat_GracePeriod_KeepNotExpectedInstallments() { 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, UseCents = true } }; package.KeepExpectedInstallment = false; package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB; Loan myContract = new Loan(package, 50000, 0.01m, 8, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = false; myContract.Repay(1, new DateTime(2006, 2, 1), 1050, true, true); myContract.Repay(2, new DateTime(2006, 6, 1), 40000, true, true); Assert.AreEqual(50000, myContract.CalculateExpectedOlb(1, false).Value); Assert.AreEqual(50000, myContract.CalculateExpectedOlb(2, false).Value); Assert.AreEqual(50000m, myContract.CalculateExpectedOlb(3, false).Value); Assert.AreEqual(41666.67m, myContract.CalculateExpectedOlb(4, false).Value); Assert.AreEqual(33333.34m, myContract.CalculateExpectedOlb(5, false).Value); //Assert.AreEqual(11428m, myContract.CalculateExpectedOLB(6, false).Value); //Assert.AreEqual(7618.67m, myContract.CalculateExpectedOLB(7, false).Value); //Assert.AreEqual(3809.34m, myContract.CalculateExpectedOLB(8, false).Value); }
private static Loan _GetLoan(DateTime pDisburseDate, int pNumberOfInstallments, int pGracePeriod, OLoanTypes pLoanTypes) { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = pLoanTypes, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true } }; return(new Loan(package, 1000, 0.03m, pNumberOfInstallments, pGracePeriod, pDisburseDate, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()))); }
public void OLB_DecliningFixedInstallments_OneRepayment_OneMonthGracePeriod_Overdue_KeepNotExpectedInstallment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true } }; Loan myContract = new Loan(package, 750, 0.03m, 9, 1, new DateTime(2006, 2, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.Repay(1, new DateTime(2006, 3, 1), 740, false, false); Assert.AreEqual(750, myContract.CalculateExpectedOlb(1, false).Value); Assert.AreEqual(32.5m, myContract.CalculateExpectedOlb(2, false).Value); Assert.AreEqual(28.85m, myContract.CalculateExpectedOlb(3, false).Value); Assert.AreEqual(25.09m, myContract.CalculateExpectedOlb(4, false).Value); Assert.AreEqual(21.21m, myContract.CalculateExpectedOlb(5, false).Value); Assert.AreEqual(17.22m, myContract.CalculateExpectedOlb(6, false).Value); Assert.AreEqual(13.11m, myContract.CalculateExpectedOlb(7, false).Value); Assert.AreEqual(8.87m, myContract.CalculateExpectedOlb(8, false).Value); Assert.AreEqual(4.51m, myContract.CalculateExpectedOlb(9, false).Value); }
public void CalculateExpectedOLB2() { 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, 20000, 0.02m, 10, 0, new DateTime(2009, 1, 17), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.BadLoan = false; myContract.Repay(1, new DateTime(2009, 1, 17), 1000, true, false); Assert.AreEqual(19000, myContract.CalculateExpectedOlb(1, false).Value); Assert.AreEqual(17100, myContract.CalculateExpectedOlb(2, false).Value); Assert.AreEqual(15200, myContract.CalculateExpectedOlb(3, false).Value); Assert.AreEqual(13300, myContract.CalculateExpectedOlb(4, false).Value); Assert.AreEqual(11400, myContract.CalculateExpectedOlb(5, false).Value); Assert.AreEqual(9500, myContract.CalculateExpectedOlb(6, false).Value); Assert.AreEqual(7600, myContract.CalculateExpectedOlb(7, false).Value); Assert.AreEqual(5700, myContract.CalculateExpectedOlb(8, false).Value); Assert.AreEqual(3800, myContract.CalculateExpectedOlb(9, false).Value); Assert.AreEqual(1900, myContract.CalculateExpectedOlb(10, false).Value); }
public void DecliningRate_ExoticInstallments_NoGracePeriod_RoundingCapital_RoundingInterest() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, ExoticProduct = new ExoticInstallmentsTable { new ExoticInstallment(1, 0.1, null), new ExoticInstallment(2, 0.1, null), new ExoticInstallment(3, 0.1, null), new ExoticInstallment(4, 0.1, null), new ExoticInstallment(5, 0.1, null), new ExoticInstallment(6, 0.5, null) }, Currency = new Currency { Id = 1, UseCents = true } }; Loan myContract = new Loan(package, 954, 0.03m, 6, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 28.62m, 95.40m, 954); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 25.76m, 95.40m, 858.6m); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 22.90m, 95.40m, 763.2m); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 20.03m, 95.40m, 667.8m); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 17.17m, 95.40m, 572.4m); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 14.31m, 477, 477); }
public void DecliningRate_ExoticInstallments_GracePeriod() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, ExoticProduct = new ExoticInstallmentsTable { new ExoticInstallment(1, 0.1, null), new ExoticInstallment(2, 0.1, null), new ExoticInstallment(3, 0.1, null), new ExoticInstallment(4, 0.1, null), new ExoticInstallment(5, 0.1, null), new ExoticInstallment(6, 0.5, null) }, Currency = new Currency { Id = 1 } }; 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())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 30.00m, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 30.00m, 100.00m, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 27.00m, 100.00m, 900); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 24.00m, 100.00m, 800); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 21.00m, 100.00m, 700); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 18.00m, 100.00m, 600); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 15.00m, 500.00m, 500); }
public void DecliningRate_FixedPrincipal_BiWeeklyInstallmentType_NoGracePeriod() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Bi-Weekly", 14, 0), LoanType = OLoanTypes.DecliningFixedPrincipal, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true } }; Loan myContract = new Loan(package, 1000, 0.03m, 5, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 1, 16), 32.14m, 200, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 1, 30), 24.00m, 200, 800); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 2, 13), 18.00m, 200, 600); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 2, 27), 12.00m, 200, 400); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 3, 13), 6.00m, 200, 200); }
public void DecliningRate_FixedInstallments_GracePeriod() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Bi-Weekly", 14, 0), LoanType = OLoanTypes.DecliningFixedInstallments, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true }, RoundingType = ORoundingType.Approximate }; 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())); Assert.AreEqual(1000, _CheckInstalmentsTotalPrincipal(myContract).Value); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 1, 16), 32.14m, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 1, 30), 30.00m, 154.60m, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 2, 13), 25.36m, 159.24m, 845.40m); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 2, 27), 20.58m, 164.02m, 686.16m); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 3, 13), 15.66m, 168.93m, 522.14m); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 3, 27), 10.60m, 173.99m, 353.21m); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 4, 10), 5.38m, 179.22m, 179.22m); }
public void FlatRate_MonthlyInstallmentType_NoGracePeriod() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true }, RoundingType = ORoundingType.Approximate }; 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())); Assert.AreEqual(6, myContract.InstallmentList.Count); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 30.00m, 166.67m, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 30.00m, 166.67m, 833.33m); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 30.00m, 166.67m, 666.66m); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 30.00m, 166.66m, 499.99m); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 30.00m, 166.67m, 333.33m); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 30.00m, 166.66m, 166.66m); }
protected override void SetUp() { base.SetUp(); _loanManager = (LoanManager)container["LoanManager"]; _loan = new Loan(new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())) { ClientType = OClientTypes.Person, LoanOfficer = new User { Id = 1 }, BranchCode = "DU", CreationDate = DateTime.Today.AddDays(-1), StartDate = DateTime.Today, FirstInstallmentDate = DateTime.Today.AddDays(1), AlignDisbursementDate = DateTime.Today, CloseDate = DateTime.Today.AddDays(1), Product = new LoanProduct { Id = 1, Currency = new Currency { Id = 1 } }, Amount = 1000m, InterestRate = 3, InstallmentType = new InstallmentType { Id = 1 }, NbOfInstallments = 2, FundingLine = new FundingLine { Id = 1 }, InstallmentList = new List <Installment> { _installment1, _installment2 }, EconomicActivityId = 1, EconomicActivity = new EconomicActivity { Id = 1 }, GracePeriodOfLateFees = 0 }; }
public void FlatRate_ExoticInstallments_GracePeriod_50PercentMiddle_50PercentEnd() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, ExoticProduct = new ExoticInstallmentsTable { new ExoticInstallment(1, 0, 0), new ExoticInstallment(2, 0, 0), new ExoticInstallment(3, 0.5, 0.5), new ExoticInstallment(4, 0, 0), new ExoticInstallment(5, 0, 0), new ExoticInstallment(6, 0.5, 0.5) }, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 1000, 0.02m, 7, 1, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 20.00m, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 0, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 0, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 60, 500, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 0, 0, 500); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 0, 0, 500); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 60, 500, 500); }
public void FlatRate_ExoticInstallments_GracePeriod_RoundingInterest() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, ExoticProduct = new ExoticInstallmentsTable { new ExoticInstallment(1, 0.1, 0.1), new ExoticInstallment(2, 0.1, 0.1), new ExoticInstallment(3, 0.1, 0.1), new ExoticInstallment(4, 0.1, 0.1), new ExoticInstallment(5, 0.1, 0.1), new ExoticInstallment(6, 0.5, 0.5) }, Currency = new Currency { Id = 1, UseCents = true } }; Loan myContract = new Loan(package, 900, 0.026m, 9, 3, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 23.4m, 0, 900); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 23.4m, 0, 900); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 23.4m, 0, 900); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 14.04m, 90.00m, 900); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 14.04m, 90.00m, 810); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 14.04m, 90.00m, 720); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 14.04m, 90.00m, 630); _AssertSpecifiedInstallment(myContract.GetInstallment(7), 8, new DateTime(2006, 9, 1), 14.04m, 90.00m, 540); _AssertSpecifiedInstallment(myContract.GetInstallment(8), 9, new DateTime(2006, 10, 2), 70.20m, 450.00m, 450); }
public void FlatRate_MonthlyInstallmentType_ExoticInstallments_GracePeriod_RoundingInterest_RoundingCapital() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, ExoticProduct = new ExoticInstallmentsTable { new ExoticInstallment(1, 0.1, 0.1), new ExoticInstallment(2, 0.1, 0.1), new ExoticInstallment(3, 0.1, 0.5), new ExoticInstallment(4, 0.1, 0.1), new ExoticInstallment(5, 0.1, 0.1), new ExoticInstallment(6, 0.5, 0.1) }, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 987, 0.03m, 8, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 30, 0, 987); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 29, 0, 987); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 18, 99, 987); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 18, 98, 888); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 89, 99, 790); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 18, 99, 691); _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 18, 98, 592); _AssertSpecifiedInstallment(myContract.GetInstallment(7), 8, new DateTime(2006, 9, 1), 17, 494, 494); }
private static Loan GetContract(OCurrency pAmount, int pNumberOfInstallments, decimal pRate, int pGracePeriod, bool pChargeInterestDuringGracePeriod) { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = pChargeInterestDuringGracePeriod, Currency = new Currency { Id = 1 } }; return(new Loan(package, pAmount, pRate, pNumberOfInstallments, pGracePeriod, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()))); }
private static Loan _SetContract(OAnticipatedRepaymentPenaltiesBases pAnticipatedRepaymentBase, double pAnticipated, bool pKeepExpectedInstallment) { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = pKeepExpectedInstallment, AnticipatedTotalRepaymentPenaltiesBase = pAnticipatedRepaymentBase, Currency = new Currency { Id = 1 } }; return(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 = false, AnticipatedTotalRepaymentPenalties = pAnticipated, NonRepaymentPenalties = { InitialAmount = 0.003 } }); }