Search in sources :

Example 36 with Installment

use of org.mifos.accounts.loan.schedule.domain.Installment 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)

Example 37 with Installment

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

the class ScheduleMapper method populatePaymentDetails.

public void populatePaymentDetails(Schedule schedule, LoanBO loanBO, Date paymentDate, PersonnelBO personnel, AccountPaymentEntity accountPaymentEntity) {
    Map<Integer, Installment> installments = schedule.getInstallments();
    MifosCurrency currency = loanBO.getCurrency();
    for (LoanScheduleEntity loanScheduleEntity : loanBO.getLoanScheduleEntities()) {
        if (loanScheduleEntity.isNotPaid()) {
            Installment installment = installments.get(Integer.valueOf(loanScheduleEntity.getInstallmentId()));
            Money originalInterest = loanScheduleEntity.getInterest();
            Money extraInterestPaid = new Money(currency, installment.getCurrentExtraInterestPaid());
            Money interestDueTillPaid = new Money(currency, installment.getCurrentInterestPaid());
            loanScheduleEntity.payComponents(installment, currency, paymentDate);
            if (loanScheduleEntity.getPaymentAllocation().hasAllocation()) {
                LoanTrxnDetailEntity loanTrxnDetailEntity = loanScheduleEntity.updateSummaryAndPerformanceHistory(accountPaymentEntity, personnel, paymentDate);
                loanTrxnDetailEntity.computeAndSetCalculatedInterestOnPayment(originalInterest, extraInterestPaid, interestDueTillPaid);
            }
        }
    }
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Money(org.mifos.framework.util.helpers.Money) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 38 with Installment

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

the class ScheduleMapper method populateExtraInterestInLoanScheduleEntities.

public void populateExtraInterestInLoanScheduleEntities(Schedule schedule, Map<Integer, LoanScheduleEntity> loanScheduleEntities) {
    for (Installment installment : schedule.getInstallments().values()) {
        LoanScheduleEntity loanScheduleEntity = loanScheduleEntities.get(installment.getId());
        loanScheduleEntity.setExtraInterest(new Money(loanScheduleEntity.getCurrency(), installment.getExtraInterest()));
    }
}
Also used : Installment(org.mifos.accounts.loan.schedule.domain.Installment) Money(org.mifos.framework.util.helpers.Money)

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