Search in sources :

Example 36 with Schedule

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

the class ScheduleCalculatorTest method withShortPaymentOnTime.

@Test
public void withShortPaymentOnTime() {
    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(25, 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);
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 37 with Schedule

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

the class ScheduleCalculatorTest method withNoPaymentPaymentAfterDueDate.

@Test
public void withNoPaymentPaymentAfterDueDate() {
    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.computeExtraInterest(schedule, getDate(26, 12, 2010));
    assertInstallmentPrincipals(installment1, 242.24, 242.24, 0);
    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, 20.40, 0);
    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, 14.66, 14.66, 0);
    assertInstallmentForExtraInterests(installment3, 10.1, 10.1, 0);
    assertInstallmentForExtraInterests(installment4, 5.31, 5.31, 0);
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 38 with Schedule

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

the class ScheduleCalculatorTest method shouldComputeExtraInterestAfterPartPay.

@Test
public void shouldComputeExtraInterestAfterPartPay() {
    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(27, 9, 2010));
    assertThat(installment1.getExtraInterest().doubleValue(), is(0.0));
    assertThat(installment2.getExtraInterest().doubleValue(), is(0.32));
    installment1.pay(BigDecimal.valueOf(100), getDate(27, 9, 2010));
    scheduleCalculator.computeExtraInterest(schedule, getDate(28, 9, 2010));
    assertThat(installment1.getExtraInterest().doubleValue(), is(0.0));
    assertThat(installment2.getExtraInterest().doubleValue(), is(0.43));
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 39 with Schedule

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

the class ScheduleCalculatorTest method shouldComputeExtraInterestAfterMultiplePaymentsOnSameDay.

@Test
public void shouldComputeExtraInterestAfterMultiplePaymentsOnSameDay() {
    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.applyPayment(schedule, new BigDecimal(100), getDate(27, 9, 2010), false);
    assertThat(installment2.getExtraInterestPaid().doubleValue(), is(0.0));
    assertThat(installment1.getExtraInterest().doubleValue(), is(0.0));
    assertThat(installment1.getInterest().doubleValue(), is(20.40));
    assertThat(installment1.getApplicableInterest().doubleValue(), is(20.40));
    assertThat(installment2.getExtraInterest().doubleValue(), is(0.32));
    scheduleCalculator.applyPayment(schedule, new BigDecimal(200), getDate(27, 9, 2010), false);
    assertThat(installment2.getExtraInterestPaid().doubleValue(), is(0.32));
    assertThat(installment2.getExtraInterest().doubleValue(), is(0.32));
    assertThat(installment2.getInterestPaid().doubleValue(), is(1.00));
    assertThat(installment2.getPrincipalDue().doubleValue(), is(211.63));
    assertThat(installment2.getInterest().doubleValue(), is(14.96));
    assertThat(installment2.getApplicableInterest().doubleValue(), is(13.30));
}
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