public FrmAvalaibleLoanProducts() { InitializeComponent(); InitializePackages(); _package = new LoanProduct(); _selectedPackage = new LoanProduct(); }
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 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 FrmAvalaibleLoanProducts() { InitializeComponent(); _package = new LoanProduct(); InitializePackages(); webBrowserPackage.ObjectForScripting = this; }
public void Package_Click(object sender, HtmlElementEventArgs e) { var tag = (HtmlElement)(sender); this.PackageFormId = Convert.ToInt32(tag.Id); _package = ServicesProvider.GetInstance().GetProductServices().FindPackage(PackageFormId); buttonDeletePackage.Enabled = true; buttonEditProduct.Enabled = true; }
public VillageAddLoanForm(Village village, LoanProduct product, NonSolidaryGroupForm nsgForm) { _village = village; _product = product; _nsgForm = nsgForm; _product.EntryFees = ServicesProvider.GetInstance().GetProductServices().GetProductEntryFees(_product, village); _fLServices = new FundingLineServices(User.CurrentUser); _accumulatedAmount = 0; InitializeComponent(); InitializeControls(); }
public void SetUp() { _rules = new AccountingRuleCollection(); _accounts = DefaultAccounts.DefaultAccount(1); Account cashSavings = new Account("1020", "CASH_SAVINGS", 0, "CASH_SAVIGNS", true, OAccountCategories.BalanceSheetAsset, 1); _accounts.Add(cashSavings); _rules.Add(new ContractAccountingRule { DebitAccount = _accounts[0], CreditAccount = cashSavings, ProductType = OProductTypes.Saving, SavingProduct = null, ClientType = OClientTypes.All, EconomicActivity = null, BookingDirection = OBookingDirections.Both }); _loanProductEde34 = new LoanProduct { Id = 1, Code = "EDE34", Name = "EDEN 34", Currency = new Currency { Id = 1} }; Account cashEDE34 = new Account("1051", "CASH_EDE34", 0, "CASH_EDE34", true, OAccountCategories.BalanceSheetAsset, 1); _accounts.Add(cashEDE34); _rules.Add(new ContractAccountingRule { DebitAccount = _accounts[0], CreditAccount = cashEDE34, ProductType = OProductTypes.Loan, LoanProduct = _loanProductEde34, ClientType = OClientTypes.Person, EconomicActivity = new EconomicActivity(1, "Agriculture", null, false), BookingDirection = OBookingDirections.Both }); _loanProductEde60 = new LoanProduct { Id = 2, Code = "EDE60", Name = "EDEN 60", Currency = new Currency { Id = 1 } }; Account cashEDE60 = new Account("1052", "CASH_EDE60", 0, "CASH_EDE60", true, OAccountCategories.BalanceSheetAsset, 1); _accounts.Add(cashEDE60); _rules.Add(new ContractAccountingRule { DebitAccount = _accounts[0], CreditAccount = cashEDE60, ProductType = OProductTypes.Loan, LoanProduct = _loanProductEde60, ClientType = OClientTypes.Person, EconomicActivity = new EconomicActivity(1, "Agriculture", null, false), BookingDirection = OBookingDirections.Credit }); }
public void FlatRate_BiWeeklyInstallmentType_GracePeriod() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Bi-Weekly", 14, 0), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1, UseCents = true} }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 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, 1, 16), 32.14m, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 1, 30), 30.00m, 0, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 2, 13), 30.00m, 250, 1000); _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 2, 27), 30.00m, 250, 750); _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 3, 13), 30.00m, 250, 500); _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 3, 27), 30.00m, 250, 250); }
public void CalculateRemainingInterest_AccrualAccounting() { 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} }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 0, new DateTime(2009, 12, 25), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.Repay(1, new DateTime(2010, 1, 25), 196.67m, false, true); Assert.AreEqual(17.42m, Math.Round(myContract.CalculateRemainingInterests(new DateTime(2010, 2, 12)).Value, 2)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); }
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 CalculateRemainingInterest_CashAccounting_AfterFirstInstallment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, 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())); Assert.AreEqual(30, Math.Round(myContract.CalculateRemainingInterests(new DateTime(2006, 2, 14)).Value, 2)); }
public void TestDisburseWhenDisableFeesTrue() { ApplicationSettings pDataParam = ApplicationSettings.GetInstance(""); pDataParam.DeleteAllParameters(); pDataParam.AddParameter("ALIGN_INSTALLMENTS_ON_REAL_DISBURSEMENT_DATE", false); pDataParam.AddParameter("PAY_FIRST_INSTALLMENT_REAL_VALUE", true); pDataParam.AddParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, false); pDataParam.AddParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Bi-Weelky", 14, 0), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package,1000,0.02m,6,1,new DateTime(2006,1,2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); EntryFee productFee = new EntryFee(); productFee.Value = 5; productFee.IsRate = true; LoanEntryFee entryFee = new LoanEntryFee(); entryFee.FeeValue = 5; entryFee.ProductEntryFee = productFee; myContract.LoanEntryFeesList = new List<LoanEntryFee>(); myContract.LoanEntryFeesList.Add(entryFee); LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,6),false,true); Assert.AreEqual(new DateTime(2006,1,2),myContract.StartDate); Assert.AreEqual(14.29m,myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(1000m,lDE.Amount.Value); Assert.AreEqual(null, lDE.Commissions); }
public void TestCountFeesWithSmallPrepayment() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.STOP_WRITEOFF_PENALTY, true); 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, 1000, 0.03m, 6, 1, new DateTime(2010, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.NonRepaymentPenalties.OverDuePrincipal = 0.01; Assert.AreEqual(new DateTime(2010, 2, 1), myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(new DateTime(2010, 3, 1), myContract.GetInstallment(1).ExpectedDate); myContract.Repay(1, new DateTime(2010, 2, 1), 30, true, false); myContract.Repay(2, new DateTime(2010, 2, 26), 30, true, false); RepaymentEvent rPE = myContract.Repay(2, new DateTime(2010, 3, 4), 196.58m, false, false); Assert.AreEqual(5.63m, rPE.Fees.Value); Assert.AreEqual(3.2m, rPE.Interests.Value); Assert.AreEqual(187.75m, rPE.Principal.Value); Assert.AreEqual(myContract.GetInstallment(1).IsRepaid, true); }
public void TestCalculateTotalInterests() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package,1000,0.03m,6,1,new DateTime(2006,6,30), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); Assert.AreEqual(181m, myContract.CalculateTotalInterests().Value); }
public void TestCalculateRemainingInterestsWithDateTimeParameter() { 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,6,22), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); Assert.AreEqual(46.5m, Math.Round(myContract.CalculateRemainingInterests(new DateTime(2006, 8, 22)).Value, 2)); }
public void TestCalculatePastDueSinceLastRepaymentWhenSameYearAndLimitBypassed() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 }, KeepExpectedInstallment = false }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.Repay(1, new DateTime(2006, 2, 1), 30, true, false); DateTime limit = new DateTime(2006, 5, 1); Assert.AreEqual(61, myContract.CalculatePastDueSinceLastRepayment(limit)); }
public void TestCalculatePastDueSinceLastRepayment2() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = false, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); PaymentMethod paymentMethod = new PaymentMethod(1, "Cash", "", false); myContract.Repay(1, new DateTime(2006, 6, 1), 30, true, 0, 0, false, 0, true, false, false, paymentMethod); Assert.IsTrue(myContract.GetInstallment(0).IsRepaid); Assert.AreEqual(122, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 7, 1))); }
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); }
public void TestCalculatePendingRepayment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = false, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); PaymentMethod paymentMethod = new PaymentMethod(2, "Voucher", "", true); RepaymentEvent pEvent = myContract.Repay(1, new DateTime(2006, 6, 1), 30, true, 0, 0, false, 0, true, false, true, paymentMethod); Assert.IsTrue(myContract.GetInstallment(0).IsRepaid); Assert.AreEqual(pEvent.Code, "PBLR"); Assert.IsTrue(myContract.GetInstallment(0).IsPending); myContract.ConfirmPendingRepayment(); Assert.IsFalse(myContract.GetInstallment(0).IsPending); }
public void TestCalculateInstallmentWhenChangeDateSetToFalse() { ApplicationSettings pDataParam = ApplicationSettings.GetInstance(""); pDataParam.DeleteAllParameters(); pDataParam.AddParameter("ALIGN_INSTALLMENTS_ON_REAL_DISBURSEMENT_DATE", false); pDataParam.AddParameter("PAY_FIRST_INSTALLMENT_REAL_VALUE", true); pDataParam.AddParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); pDataParam.AddParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, false); pDataParam.AddParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package,1000,0.02m,6,1,new DateTime(2006,1,2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); Assert.AreEqual(new DateTime(2006,2,2),myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(new DateTime(2006,3,2),myContract.GetInstallment(1).ExpectedDate); myContract.Disburse(new DateTime(2006,1,6),false,false); Assert.AreEqual(new DateTime(2006,1,2),myContract.StartDate); Assert.AreEqual(new DateTime(2006,2,2),myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(new DateTime(2006,3,2),myContract.GetInstallment(1).ExpectedDate); myContract.Repay(1,new DateTime(2006,2,2),100,true,false); Assert.AreEqual(new DateTime(2006,2,2),myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(new DateTime(2006,3,2),myContract.GetInstallment(1).ExpectedDate); }
public void TestCalculateTotalExpectedAmountWithoutEntryFees() { 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 } }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 1, new DateTime(2006, 6, 30), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); Assert.AreEqual(1181m, myContract.CalculateTotalExpectedAmount().Value); }
public void TestCalculateMaximumAmountForExoticProductTypeForInstallment3() { 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.NonRepaymentPenalties.OLB = 0.01; Loan myContract = new Loan(package, 1000, 0.01m, 3, 0, new DateTime(2008, 12, 17), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.Repay(1, new DateTime(2008, 12, 19), 103, true, true); myContract.Repay(2, new DateTime(2008, 12, 19), 618, true, true); OCurrency amountToRetreived = Math.Round(myContract.CalculateMaximumAmountAuthorizedToRepay(3, new DateTime(2007, 3, 28), false, 0, 0, false, 0, true, true).Value); Assert.AreEqual(310m, amountToRetreived.Value); }
public void TestContract9InstallmentsDecliningRateWhenLittleOverPaid() { 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 } }; package.KeepExpectedInstallment = false; Loan myContract = new Loan(package,1500,0.03m,9,1,new DateTime(2006,1,1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.AnticipatedTotalRepaymentPenalties = 0.02; Assert.AreEqual(45m,myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(0,myContract.GetInstallment(0).CapitalRepayment.Value); Assert.AreEqual(new DateTime(2006,2,1),myContract.GetInstallment(0).ExpectedDate); RepaymentEvent rPE = myContract.Repay(1,new DateTime(2006,2,1),45m,false,false); Assert.AreEqual(45,myContract.GetInstallment(0).PaidInterests.Value); Assert.AreEqual(0,myContract.GetInstallment(0).PaidCapital.Value); Assert.AreEqual(0m,rPE.Fees.Value); Assert.AreEqual(45m,rPE.Interests.Value); Assert.AreEqual(0m,rPE.Principal.Value); }
public void TestCalculateMaximumAmountToRegradingLoan() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; package.KeepExpectedInstallment = false; 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; Assert.AreEqual(30m, myContract.CalculateMaximumAmountToRegradingLoan(1, new DateTime(2006, 2, 1), true, 0, 0, false, 0, false).Value); }
public void TestDisburseWhenBiWeeklyInstallmentType() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Bi-Weelky", 14, 0), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 1000, 0.02m, 6, 1, new DateTime(2006, 1, 2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); EntryFee entryFee = new EntryFee(); entryFee.Value = 5; entryFee.IsRate = true; entryFee.Id = 21; LoanEntryFee loanEntryFee = new LoanEntryFee(); loanEntryFee.FeeValue = 5; loanEntryFee.ProductEntryFee = entryFee; loanEntryFee.ProductEntryFeeId = 21; myContract.LoanEntryFeesList = new List<LoanEntryFee>(); myContract.LoanEntryFeesList.Add(loanEntryFee); LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006, 1, 6), false, false); Assert.AreEqual(new DateTime(2006,1,2), myContract.StartDate); Assert.AreEqual(14.29m, myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(1000m, lDE.Amount.Value); Assert.AreEqual(50m, lDE.Commissions[0].Fee.Value); }
public void TestCalculateOverDueAmountWithInterest() { 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, 1000, 0.03m, 12, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); myContract.NonRepaymentPenalties.OLB = 0.0016; Assert.AreEqual(30m,myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(70.46m,myContract.GetInstallment(0).CapitalRepayment.Value); Assert.AreEqual(new DateTime(2006,2,1),myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(1000, _CheckInstalmentsTotalPrincipal(myContract).Value); Assert.AreEqual(27.89m,myContract.GetInstallment(1).InterestsRepayment.Value); Assert.AreEqual(72.57m,myContract.GetInstallment(1).CapitalRepayment.Value); Assert.AreEqual(new DateTime(2006,3,1),myContract.GetInstallment(1).ExpectedDate); Assert.AreEqual(new DateTime(2006,4,3),myContract.GetInstallment(2).ExpectedDate); Assert.AreEqual(new DateTime(2006,5,1),myContract.GetInstallment(3).ExpectedDate); Assert.AreEqual(new DateTime(2006,6,1),myContract.GetInstallment(4).ExpectedDate); Assert.AreEqual(new DateTime(2006,7,3),myContract.GetInstallment(5).ExpectedDate); }
public void TestDisburseWhenDisburseDateEqualsToContractStartDate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true); LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, 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())); EntryFee entryFee = new EntryFee(); entryFee.Value = 5; entryFee.IsRate = true; entryFee.Id = 21; LoanEntryFee loanEntryFee = new LoanEntryFee(); loanEntryFee.FeeValue = 5; loanEntryFee.ProductEntryFee = entryFee; loanEntryFee.ProductEntryFeeId = 21; myContract.LoanEntryFeesList = new List<LoanEntryFee>(); myContract.LoanEntryFeesList.Add(loanEntryFee); LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,1),false,false); Assert.AreEqual(new DateTime(2006,1,1),myContract.StartDate); Assert.AreEqual(30m,myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(1000m,lDE.Amount.Value); Assert.AreEqual(50m,lDE.Commissions[0].Fee.Value); }
public void TestCalculateOverDueAmountWithoutInterest() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, 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())); Assert.AreEqual(30m, myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(0m, myContract.GetInstallment(0).CapitalRepayment.Value); Assert.AreEqual(new DateTime(2006, 2, 1), myContract.GetInstallment(0).ExpectedDate); Assert.AreEqual(30m, myContract.GetInstallment(1).InterestsRepayment.Value); Assert.AreEqual(200m, myContract.GetInstallment(1).CapitalRepayment.Value); Assert.AreEqual(new DateTime(2006, 3, 1), myContract.GetInstallment(1).ExpectedDate); Assert.AreEqual(new DateTime(2006, 4, 3), myContract.GetInstallment(2).ExpectedDate); Assert.AreEqual(0m, myContract.CalculateOverduePrincipal(new DateTime(2006, 1, 9)).Value); Assert.AreEqual(400m, myContract.CalculateOverduePrincipal(new DateTime(2006, 4, 9)).Value); Assert.AreEqual(400m, myContract.CalculateOverduePrincipal(new DateTime(2006, 4, 9)).Value); myContract.Repay(1, new DateTime(2006, 2, 1), 30, true, false); Assert.AreEqual(400m, myContract.CalculateOverduePrincipal(new DateTime(2006, 4, 9)).Value); myContract.Repay(2, new DateTime(2006, 3, 1), 230, true, false); Assert.AreEqual(200m, myContract.CalculateOverduePrincipal(new DateTime(2006, 4, 9)).Value); myContract.Repay(3, new DateTime(2006, 4, 3), 130, true, false); Assert.AreEqual(100m, myContract.CalculateOverduePrincipal(new DateTime(2006, 4, 9)).Value); }
public void TestDisburseWhenDisburseDateGreaterThanContractStartDate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true); //startdate = 1/1/2006 //expectedFirstInstallment = 1/2/2006 //real startdate = 6/1/2006 LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, Currency = new Currency { Id = 1 } }; EntryFee productEntryFee = new EntryFee(); productEntryFee.IsRate = true; productEntryFee.Value = 5;//5% of an amount productEntryFee.Id = 21; productEntryFee.Name = "Test entry fee"; package.EntryFees = new List<EntryFee>(); package.EntryFees.Add(productEntryFee); 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()) ); LoanEntryFee fee = new LoanEntryFee(); fee.ProductEntryFee = package.EntryFees[0]; fee.FeeValue = (decimal)fee.ProductEntryFee.Value; fee.ProductEntryFeeId = (int) package.EntryFees[0].Id; myContract.LoanEntryFeesList=new List<LoanEntryFee>(); myContract.LoanEntryFeesList.Add(fee); LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,6),false,false); Assert.AreEqual(new DateTime(2006,1,1),myContract.StartDate); Assert.AreEqual(25m,myContract.GetInstallment(0).InterestsRepayment.Value); Assert.AreEqual(1000m,lDE.Amount.Value); Assert.AreEqual(50m, lDE.Commissions[0].Fee.Value); }
public void TestCalculatePastDueSinceLastRepayment() { LoanProduct package = new LoanProduct { InstallmentType = new InstallmentType(1, "Monthly", 0, 1), LoanType = OLoanTypes.Flat, ChargeInterestWithinGracePeriod = true, KeepExpectedInstallment = false, Currency = new Currency { Id = 1 } }; Loan myContract = new Loan(package, 1000, 0.03m, 6, 2, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())); //before repayment Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 1))); Assert.AreEqual(14, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 15))); Assert.AreEqual(59, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 4, 1))); Assert.AreEqual(152, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 7, 3))); //partially repayment PaymentMethod paymentMethod = new PaymentMethod(1, "Cash", "", false); myContract.Repay(1, new DateTime(2006, 2, 1), 30, true, 0, 0, false, 0, false, false, false, paymentMethod); myContract.Repay(2, new DateTime(2006, 3, 6), 10, true, 0, 0, false, 0, false, false, false, paymentMethod); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 1))); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 15))); Assert.AreEqual(28, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 4, 3))); Assert.AreEqual(119, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 7, 3))); //totally repayment myContract.Repay(2, new DateTime(2006, 3, 6), 20, true, 0, 0, false, 0, false, false, false, paymentMethod); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 1))); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 2, 15))); Assert.AreEqual(0, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 4, 3))); Assert.AreEqual(91, myContract.CalculatePastDueSinceLastRepayment(new DateTime(2006, 7, 3))); }