use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.
the class ScheduleCalculatorTest method shortPaymentBeforeDueDateWithFeesAndPenalty.
@Test
public void shortPaymentBeforeDueDateWithFeesAndPenalty() {
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);
Installment installment3 = getInstallment(3, getDate(25, 11, 2010), 252.22, 10.40, 0);
Installment installment4 = getInstallment(4, getDate(25, 12, 2010), 257.87, 5.09, 0);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3, installment4));
scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(240d), getDate(23, 9, 2010), false);
assertInstallmentPrincipals(installment1, 242.24, 21.32, 220.92);
assertInstallmentPrincipals(installment2, 247.67, 247.67, 0);
assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
assertInstallmentInterests(installment1, 1.03, 1.03, 19.08);
assertInstallmentInterests(installment2, 14.96, 14.96, 0);
assertInstallmentInterests(installment3, 10.40, 10.40, 0);
assertInstallmentInterests(installment4, 5.09, 5.09, 0);
}
use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.
the class ScheduleCalculatorTest method withExcessPaymentAfterDueDate.
@Test
public void withExcessPaymentAfterDueDate() {
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);
Installment installment3 = getInstallment(3, getDate(25, 11, 2010), 252.22, 10.40, 0);
Installment installment4 = getInstallment(4, getDate(25, 12, 2010), 257.87, 5.09, 0);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3, installment4));
scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(280d), getDate(29, 9, 2010), false);
assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
assertInstallmentPrincipals(installment2, 247.67, 232.94, 14.73);
assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
assertInstallmentInterests(installment1, 20.40, 0, 20.40);
assertInstallmentInterests(installment2, 12.71, 12.71, 1.99);
assertInstallmentInterests(installment3, 10.40, 10.40, 0);
assertInstallmentInterests(installment4, 5.09, 5.09, 0);
assertInstallmentForExtraInterests(installment1, 0, 0, 0);
assertInstallmentForExtraInterests(installment2, 0.64, 0, 0.64);
assertInstallmentForExtraInterests(installment3, 0, 0, 0);
assertInstallmentForExtraInterests(installment4, 0, 0, 0);
}
use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.
the class ScheduleCalculatorTest method shouldComputeRepaymentAmountWhenNoPastPaymentsMade.
@Test
public void shouldComputeRepaymentAmountWhenNoPastPaymentsMade() {
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);
Installment installment3 = getInstallment(3, getDate(25, 11, 2010), 252.22, 10.40, 0);
Installment installment4 = getInstallment(4, getDate(25, 12, 2010), 257.87, 5.09, 0);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3, installment4));
RepaymentResultsHolder repaymentResultsHolder = scheduleCalculator.computeRepaymentAmount(schedule, getDate(30, 11, 2010));
assertThat(repaymentResultsHolder.getTotalRepaymentAmount().doubleValue(), is(1063.83));
assertThat(repaymentResultsHolder.getWaiverAmount().doubleValue(), is(0.85));
}
use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.
the class ScheduleCalculatorTest method withOneInstallmentAdjusted.
@Test
public void withOneInstallmentAdjusted() {
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);
Installment installment3 = getInstallment(3, getDate(25, 11, 2010), 252.22, 10.40, 0);
Installment installment4 = getInstallment(4, getDate(25, 12, 2010), 257.87, 5.09, 0);
schedule = new Schedule(getDate(25, 8, 2010), 0.000658, BigDecimal.valueOf(1000d), asList(installment1, installment2, installment3, installment4));
scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(280d), getDate(25, 9, 2010), false);
assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
assertInstallmentPrincipals(installment2, 247.67, 230.31, 17.36);
assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
assertInstallmentInterests(installment1, 20.40, 0, 20.40);
assertInstallmentInterests(installment2, 14.62, 14.62, 0);
assertInstallmentInterests(installment3, 10.40, 10.40, 0);
assertInstallmentInterests(installment4, 5.09, 5.09, 0);
}
use of org.mifos.accounts.loan.schedule.domain.Schedule 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);
}
Aggregations