Search in sources :

Example 16 with Installment

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

Example 17 with Installment

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;
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment)

Example 18 with 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));
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) Test(org.junit.Test)

Example 19 with Installment

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));
}
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 20 with Installment

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());
    }
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) ScheduleCalculator(org.mifos.accounts.loan.schedule.calculation.ScheduleCalculator) 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