Search in sources :

Example 6 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.

the class ScheduleCalculatorTest method exactPaymentOnTimeWithFeesAndPenalty.

@Test
public void exactPaymentOnTimeWithFeesAndPenalty() {
    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(272.64d), getDate(25, 9, 2010), false);
    assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
    assertInstallmentPrincipals(installment2, 247.67, 247.67, 0);
    assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
    assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
    assertInstallmentInterests(installment1, 20.40, 0, 20.40);
    assertInstallmentInterests(installment2, 14.96, 14.96, 0);
    assertInstallmentInterests(installment3, 10.40, 10.40, 0);
    assertInstallmentInterests(installment4, 5.09, 5.09, 0);
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 7 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.

the class ScheduleCalculatorTest method withShortPaymentAfterDueDate.

@Test
public void withShortPaymentAfterDueDate() {
    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(240d), getDate(29, 9, 2010), false);
    assertInstallmentPrincipals(installment1, 242.24, 22.64, 219.6);
    assertInstallmentPrincipals(installment2, 247.67, 247.67, 0);
    assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
    assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
    assertInstallmentInterests(installment1, 20.40, 0, 20.40);
    assertInstallmentInterests(installment2, 14.96, 14.96, 0);
    assertInstallmentInterests(installment3, 10.40, 10.40, 0);
    assertInstallmentInterests(installment4, 5.09, 5.09, 0);
    assertInstallmentForExtraInterests(installment1, 0, 0, 0);
    assertInstallmentForExtraInterests(installment2, 0.64, 0.64, 0);
    assertInstallmentForExtraInterests(installment3, 0, 0, 0);
    assertInstallmentForExtraInterests(installment4, 0, 0, 0);
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 8 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.

the class ScheduleMapperTest method getSchedule.

public Schedule getSchedule() {
    Installment installment1 = new InstallmentBuilder("1").withDueDate(getDate(23, 10, 2010)).withPrincipal(100).withPrincipalPaid(100).withInterest(10).withInterestPaid(10).withExtraInterest(9).withExtraInterestPaid(9).withMiscFees(8).withMiscFeesPaid(8).withPenalty(7).withPenaltyPaid(7).withMiscPenalty(6).withMiscPenaltyPaid(6).withFees(5).withFeesPaid(5).build();
    Installment installment2 = new InstallmentBuilder("2").withDueDate(getDate(23, 11, 2010)).withPrincipal(1000).withPrincipalPaid(100).withInterest(100).withInterestPaid(10).withExtraInterest(90).withExtraInterestPaid(9).withMiscFees(80).withMiscFeesPaid(8).withPenalty(70).withPenaltyPaid(7).withMiscPenalty(60).withMiscPenaltyPaid(6).withFees(50).withFeesPaid(5).build();
    Installment installment3 = new InstallmentBuilder("3").withDueDate(getDate(23, 12, 2010)).withPrincipal(1000).withPrincipalPaid(0).withInterest(100).withInterestPaid(0).withExtraInterest(90).withExtraInterestPaid(0).withMiscFees(80).withMiscFeesPaid(0).withPenalty(70).withPenaltyPaid(0).withMiscPenalty(60).withMiscPenaltyPaid(0).withFees(50).withFeesPaid(0).build();
    List<Installment> installments = Arrays.asList(installment1, installment2, installment3);
    return new Schedule(DISBURSEMENT_DATE, DAILY_INTEREST_RATE, LOAN_AMOUNT, installments);
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) InstallmentBuilder(org.mifos.accounts.loan.schedule.domain.InstallmentBuilder) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule)

Example 9 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.

the class ScheduleCalculatorTest method shouldComputeRepaymentAmountWhenLateExcessPaymentMade.

@Test
public void shouldComputeRepaymentAmountWhenLateExcessPaymentMade() {
    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(500d), getDate(30, 10, 2010), false);
    RepaymentResultsHolder repaymentResultsHolder = scheduleCalculator.computeRepaymentAmount(schedule, getDate(30, 11, 2010));
    assertThat(repaymentResultsHolder.getTotalRepaymentAmount().doubleValue(), is(554.46));
    assertThat(repaymentResultsHolder.getWaiverAmount().doubleValue(), is(0.85));
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) RepaymentResultsHolder(org.mifos.accounts.loan.business.RepaymentResultsHolder) Test(org.junit.Test)

Example 10 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule in project head by mifos.

the class ScheduleCalculatorTest method shouldComputeRepaymentAmountForOnTimePaymentsAndRepaymentDoneOnInstallmentDueDate.

@Test
public void shouldComputeRepaymentAmountForOnTimePaymentsAndRepaymentDoneOnInstallmentDueDate() {
    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(262.64), getDate(25, 9, 2010), false);
    scheduleCalculator.applyPayment(schedule, BigDecimal.valueOf(262.63), getDate(25, 10, 2010), false);
    BigDecimal repaymentAmount = scheduleCalculator.computeRepaymentAmount(schedule, getDate(25, 11, 2010)).getTotalRepaymentAmount();
    assertThat(repaymentAmount.doubleValue(), is(520.49));
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Schedule (org.mifos.accounts.loan.schedule.domain.Schedule)39 Test (org.junit.Test)36 Installment (org.mifos.accounts.loan.schedule.domain.Installment)34 BigDecimal (java.math.BigDecimal)4 RepaymentResultsHolder (org.mifos.accounts.loan.business.RepaymentResultsHolder)4 ArrayList (java.util.ArrayList)2 ScheduleMatcher (org.mifos.accounts.loan.schedule.domain.ScheduleMatcher)2 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 LoanScheduleEntityMatcher (org.mifos.accounts.loan.business.matchers.LoanScheduleEntityMatcher)1 ScheduleCalculator (org.mifos.accounts.loan.schedule.calculation.ScheduleCalculator)1 InstallmentBuilder (org.mifos.accounts.loan.schedule.domain.InstallmentBuilder)1 TestUtils.getDate (org.mifos.framework.TestUtils.getDate)1 Money (org.mifos.framework.util.helpers.Money)1