Search in sources :

Example 21 with Installment

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

the class ScheduleMapperTest method shouldPopulateExtraInterestInLoanScheduleEntities.

@Test
public void shouldPopulateExtraInterestInLoanScheduleEntities() {
    List<Installment> installments = getInstallments(0, 0, 0);
    Schedule schedule = new Schedule(DISBURSEMENT_DATE, DAILY_INTEREST_RATE, LOAN_AMOUNT, installments);
    for (int i = 0; i < installments.size(); i++) {
        installments.get(i).setExtraInterest(new BigDecimal(i));
    }
    Collection<LoanScheduleEntity> loanScheduleEntities = getLoanScheduleEntities(getDate(24, 11, 2010));
    Map<Integer, LoanScheduleEntity> loanScheduleEntityMap = getLoanScheduleEntityMap(loanScheduleEntities);
    scheduleMapper.populateExtraInterestInLoanScheduleEntities(schedule, loanScheduleEntityMap);
    assertExtraInterest(loanScheduleEntityMap.get(1), 0d);
    assertExtraInterest(loanScheduleEntityMap.get(2), 1d);
    assertExtraInterest(loanScheduleEntityMap.get(3), 2d);
}
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)

Example 22 with Installment

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

the class ScheduleCalculatorTest method withTwoInstallmentsAdjusted.

@Test
public void withTwoInstallmentsAdjusted() {
    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(550d), getDate(25, 9, 2010), false);
    assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
    assertInstallmentPrincipals(installment2, 247.67, 0, 247.67);
    assertInstallmentPrincipals(installment3, 252.22, 212.53, 39.69);
    assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
    assertInstallmentInterests(installment1, 20.40, 0, 20.40);
    assertInstallmentInterests(installment2, 9.29, 9.29, 0);
    assertInstallmentInterests(installment3, 9.6, 9.6, 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 23 with Installment

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

the class ScheduleCalculatorTest method withShortPaymentBeforeDueDate.

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

Example 24 with Installment

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

the class ScheduleCalculatorTest method withInitialInstallmentAmountBeforeDueDate.

@Test
public void withInitialInstallmentAmountBeforeDueDate() {
    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.64d), getDate(23, 9, 2010), false);
    assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
    assertInstallmentPrincipals(installment2, 247.67, 246.35, 1.32);
    assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
    assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
    assertInstallmentInterests(installment1, 1, 1, 19.08);
    assertInstallmentInterests(installment2, 14.93, 14.93, 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 25 with Installment

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

the class ScheduleCalculatorTest method withExcessPaymentBeforeDueDate.

@Test
public void withExcessPaymentBeforeDueDate() {
    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(23, 9, 2010), false);
    assertInstallmentPrincipals(installment1, 242.24, 0, 242.24);
    assertInstallmentPrincipals(installment2, 247.67, 228.99, 18.68);
    assertInstallmentPrincipals(installment3, 252.22, 252.22, 0);
    assertInstallmentPrincipals(installment4, 257.87, 257.87, 0);
    assertInstallmentInterests(installment1, 0.97, 0.97, 19.08);
    assertInstallmentInterests(installment2, 14.59, 14.59, 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)

Aggregations

Installment (org.mifos.accounts.loan.schedule.domain.Installment)38 Schedule (org.mifos.accounts.loan.schedule.domain.Schedule)34 Test (org.junit.Test)33 BigDecimal (java.math.BigDecimal)4 RepaymentResultsHolder (org.mifos.accounts.loan.business.RepaymentResultsHolder)4 InstallmentBuilder (org.mifos.accounts.loan.schedule.domain.InstallmentBuilder)2 Money (org.mifos.framework.util.helpers.Money)2 ScheduleCalculator (org.mifos.accounts.loan.schedule.calculation.ScheduleCalculator)1 MifosCurrency (org.mifos.application.master.business.MifosCurrency)1