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 CalculateInstallmentsStrategy(CalculateInstallmentsOptions pCio, OCurrency pStartAmount, int pNumberOfInstallments, ApplicationSettings pGeneralSettings) { _generalSettings = pGeneralSettings; OCurrency initialOlbOfContractBeforeRescheduling = Loan.InitialOlbOfContractBeforeRescheduling; if (pCio.IsExotic) { if (pCio.LoanType == OLoanTypes.Flat) { _iCi = new Flat.ExoticStrategy(pCio.Contract, _generalSettings); } else { _iCi = new Declining.ExoticStrategy(pCio.Contract, _generalSettings); } } else { if (pCio.Contract.InterestRate == 0) { _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling); } else { switch (pCio.LoanType) { case OLoanTypes.Flat: _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling); break; case OLoanTypes.DecliningFixedInstallments: _iCi = new FixedInstallmentStrategy(pCio.Contract, pStartAmount, pNumberOfInstallments, _generalSettings); break; case OLoanTypes.DecliningFixedPrincipal: _iCi = new FixedPrincipalStrategy(pCio.Contract, _generalSettings); break; case OLoanTypes.DecliningFixedPrincipalWithRealInterest: _iCi = new FixedPrincipalWithRealInterest(pCio.Contract, _generalSettings); break; } } } }
public CalculateInstallmentsStrategy(CalculateInstallmentsOptions pCio, OCurrency pStartAmount, int pNumberOfInstallments, ApplicationSettings pGeneralSettings) { _generalSettings = pGeneralSettings; OCurrency initialOlbOfContractBeforeRescheduling = Loan.InitialOlbOfContractBeforeRescheduling; if (pCio.IsExotic) { if (pCio.LoanType == OLoanTypes.Flat) _iCi = new Flat.ExoticStrategy(pCio.Contract, _generalSettings); else _iCi = new Declining.ExoticStrategy(pCio.Contract, _generalSettings); } else { if (pCio.Contract.InterestRate == 0) { _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling); } else { switch (pCio.LoanType) { case OLoanTypes.Flat: _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling); break; case OLoanTypes.DecliningFixedInstallments: _iCi = new FixedInstallmentStrategy(pCio.Contract, pStartAmount, pNumberOfInstallments, _generalSettings); break; case OLoanTypes.DecliningFixedPrincipal: _iCi = new FixedPrincipalStrategy(pCio.Contract, _generalSettings); break; case OLoanTypes.DecliningFixedPrincipalWithRealInterest: _iCi = new FixedPrincipalWithRealInterest(pCio.Contract, _generalSettings); break; } } } }
/// <summary> /// This method calculates the correct set of installments for a contract. /// 4 cases are treated : /// - Flat rate non exotic /// - Flat rate exotic /// - Declining rate non exotic /// - Declining rate exotic /// </summary> /// <param name="pChangeDate">must be set to true when creation of the contract (here in constructor), must be false in all others cases</param> public List<Installment> CalculateInstallments(bool pChangeDate) { CalculateInstallmentsOptions cIo = new CalculateInstallmentsOptions(_startDate, Product.LoanType, Product.IsExotic, this, pChangeDate); CalculateInstallmentsStrategy cIs = new CalculateInstallmentsStrategy(cIo, _amount, _nbOfInstallments, _generalSettings); List<Installment> installments = cIs.CalculateInstallments(pChangeDate); for (int i = 0; i < installments.Count; i++) { installments[i].StartDate = 0 == i ? StartDate : installments[i - 1].ExpectedDate; } return installments; }