use of org.mifos.accounts.loan.schedule.domain.Installment in project head by mifos.
the class ScheduleCalculatorTest method multiplePaymentsOnDisbursementDate.
@Test
public void multiplePaymentsOnDisbursementDate() {
Installment installment1 = getInstallment(1, getDate(18, 10, 2010), 332.2, 3.8, 0);
Installment installment2 = getInstallment(2, getDate(25, 10, 2010), 333.4, 2.6, 0);
Installment installment3 = getInstallment(3, getDate(1, 11, 2010), 334.4, 1.3, 0);
schedule = new Schedule(getDate(11, 10, 2010), 0.000548, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3));
scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(337d), getDate(11, 10, 2010), false);
assertInstallmentPrincipals(installment1, 332.2, 0, 332.2);
assertInstallmentPrincipals(installment2, 333.4, 328.6, 4.8);
assertInstallmentPrincipals(installment3, 334.4, 334.4, 0);
assertInstallmentInterests(installment1, 2.54, 2.54, 0);
assertInstallmentInterests(installment2, 2.54, 2.54, 0);
assertInstallmentInterests(installment3, 1.3, 1.3, 0);
scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(10d), getDate(11, 10, 2010), false);
assertInstallmentPrincipals(installment1, 332.2, 0, 332.2);
assertInstallmentPrincipals(installment2, 333.4, 318.6, 14.8);
assertInstallmentPrincipals(installment3, 334.4, 334.4, 0);
assertInstallmentInterests(installment1, 2.54, 2.54, 0);
assertInstallmentInterests(installment2, 2.5, 2.5, 0);
assertInstallmentInterests(installment3, 1.3, 1.3, 0);
}
use of org.mifos.accounts.loan.schedule.domain.Installment in project head by mifos.
the class ScheduleCalculatorTest method getInstallment.
private Installment getInstallment(int id, Date dueDate, double principal, double interest, double extraInterest) {
Installment installment = new Installment(id, dueDate, BigDecimal.valueOf(principal), BigDecimal.valueOf(interest), BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
installment.setExtraInterest(BigDecimal.valueOf(extraInterest));
return installment;
}
use of org.mifos.accounts.loan.schedule.domain.Installment in project head by mifos.
the class ScheduleCalculatorTest method shouldComputeExtraInterestOnDisbursement.
@Test
public void shouldComputeExtraInterestOnDisbursement() {
Installment installment1 = getInstallment(1, getDate(25, 9, 2010), 242.24, 20.40, 0);
Installment installment2 = getInstallment(2, getDate(25, 10, 2010), 247.67, 14.96, 0);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2));
scheduleCalculator.computeExtraInterest(schedule, getDate(25, 8, 2010));
assertThat(installment1.getExtraInterest().doubleValue(), is(0.0));
assertThat(installment2.getExtraInterest().doubleValue(), is(0.0));
}
use of org.mifos.accounts.loan.schedule.domain.Installment in project head by mifos.
the class ScheduleCalculatorTest method computeRepaymentAmountShouldConsiderFeesAndPenaltyOfCurrentInstallmentAndDues.
@Test
public void computeRepaymentAmountShouldConsiderFeesAndPenaltyOfCurrentInstallmentAndDues() {
Installment installment1 = getInstallment(1, getDate(25, 9, 2010), 242.24, 20.40, 0, 1, 2, 3, 4);
Installment installment2 = getInstallment(2, getDate(25, 10, 2010), 247.67, 14.96, 0, 1, 2, 3, 4);
Installment installment3 = getInstallment(3, getDate(25, 11, 2010), 252.22, 10.40, 0, 1, 2, 3, 4);
Installment installment4 = getInstallment(4, getDate(25, 12, 2010), 257.87, 5.09, 0, 1, 2, 3, 4);
Installment installment5 = getInstallment(5, getDate(25, 1, 2011), 257.87, 5.09, 0, 1, 2, 3, 4);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3, installment4, installment5));
RepaymentResultsHolder repaymentResultsHolder = scheduleCalculator.computeRepaymentAmount(schedule, getDate(30, 11, 2010));
assertThat(repaymentResultsHolder.getTotalRepaymentAmount().doubleValue(), is(1361.7));
assertThat(repaymentResultsHolder.getWaiverAmount().doubleValue(), is(0.85));
}
use of org.mifos.accounts.loan.schedule.domain.Installment in project head by mifos.
the class ScheduleCalculatorAdaptorTest method computeExtraInterestAndPopulateInLoanScheduleEntities.
@Test
public void computeExtraInterestAndPopulateInLoanScheduleEntities() {
List<Installment> installments = getInstallments(0, 0, 0);
Schedule schedule = new Schedule(DISBURSEMENT_DATE, DAILY_INTEREST_RATE, LOAN_AMOUNT, installments);
new ScheduleCalculator().computeExtraInterest(schedule, getDate(30, 10, 2010));
Set<LoanScheduleEntity> loanScheduleEntities = getLoanScheduleEntities();
Map<Integer, LoanScheduleEntity> loanScheduleEntityMap = getLoanScheduleEntityMap(loanScheduleEntities);
assertThat(schedule.getInstallments().get(2).getExtraInterest().doubleValue(), is(0.46));
scheduleCalculatorAdaptor.populateExtraInterestInLoanScheduleEntities(schedule, loanScheduleEntityMap);
for (Installment installment : installments) {
LoanScheduleEntity loanScheduleEntity = loanScheduleEntityMap.get(installment.getId());
assertExtraInterest(loanScheduleEntity, installment.getExtraInterest().doubleValue());
}
}
Aggregations