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));
}
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);
}
}
}
}
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()));
}
}
Aggregations