Search in sources :

Example 16 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule 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 17 with Schedule

use of org.mifos.accounts.loan.schedule.domain.Schedule 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 18 with Schedule

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

the class ScheduleCalculatorAdaptor method computeExtraInterest.

public void computeExtraInterest(LoanBO loan, Date asOfDate) {
    if (configurationBusinessService.isRecalculateInterestEnabled() && loan.isDecliningBalanceEqualPrincipleCalculation()) {
        Schedule schedule = scheduleMapper.mapToSchedule(new ArrayList<LoanScheduleEntity>(loan.getLoanScheduleEntities()), loan.getDisbursementDate(), getDailyInterest(loan.getInterestRate()), loan.getLoanAmount().getAmount());
        scheduleCalculator.computeExtraInterest(schedule, asOfDate);
        populateExtraInterestInLoanScheduleEntities(schedule, loan.getLoanScheduleEntityMap());
    } else if (loan.isDecliningBalanceInterestRecalculation()) {
        Schedule schedule = scheduleMapper.mapToSchedule(new ArrayList<LoanScheduleEntity>(loan.getLoanScheduleEntities()), loan.getDisbursementDate(), getDailyInterest(loan.getInterestRate()), loan.getLoanAmount().getAmount());
        scheduleCalculator.computeExtraInterest(schedule, asOfDate);
        populateExtraInterestInLoanScheduleEntities(schedule, loan.getLoanScheduleEntityMap());
    }
}
Also used : Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) ArrayList(java.util.ArrayList)

Example 19 with Schedule

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

the class ScheduleCalculatorAdaptor method applyPayment.

public void applyPayment(LoanBO loanBO, Money amount, Date paymentDate, PersonnelBO personnel, AccountPaymentEntity accountPaymentEntity, boolean adjustment) {
    Schedule schedule = scheduleMapper.mapToSchedule(loanBO.getLoanScheduleEntities(), loanBO.getDisbursementDate(), getDailyInterest(loanBO.getInterestRate()), loanBO.getLoanAmount().getAmount());
    scheduleCalculator.applyPayment(schedule, amount.getAmount(), paymentDate, adjustment);
    scheduleMapper.populatePaymentDetails(schedule, loanBO, paymentDate, personnel, accountPaymentEntity);
}
Also used : Schedule(org.mifos.accounts.loan.schedule.domain.Schedule)

Example 20 with Schedule

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

the class ScheduleCalculatorAdaptorTest method shouldComputeExtraInterestForDecliningPrincipalBalance.

@Test
public void shouldComputeExtraInterestForDecliningPrincipalBalance() {
    Set<LoanScheduleEntity> loanScheduleEntities = getLoanScheduleEntities();
    when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
    when(loanBO.getLoanScheduleEntities()).thenReturn(loanScheduleEntities);
    when(loanBO.getDisbursementDate()).thenReturn(DISBURSEMENT_DATE);
    when(loanBO.getLoanAmount()).thenReturn(new Money(rupee, LOAN_AMOUNT));
    when(loanBO.getInterestRate()).thenReturn(ANNUAL_INTEREST_RATE);
    when(loanBO.getLoanScheduleEntityMap()).thenReturn(getLoanScheduleEntityMap(loanScheduleEntities));
    scheduleCalculatorAdaptor.computeExtraInterest(loanBO, getDate(30, 10, 2010));
    Schedule expectedSchedule = getSchedule(DISBURSEMENT_DATE, LOAN_AMOUNT, getInstallments(0, .46, 0));
    verify(scheduleCalculator).computeExtraInterest(argThat(new ScheduleMatcher(expectedSchedule)), Mockito.eq(getDate(30, 10, 2010)));
    verify(loanBO, times(1)).isDecliningBalanceInterestRecalculation();
    verify(loanBO, times(1)).getLoanScheduleEntities();
    verify(loanBO, times(1)).getDisbursementDate();
    verify(loanBO, times(1)).getLoanAmount();
    verify(loanBO, times(1)).getInterestRate();
    verify(loanBO, times(1)).getLoanScheduleEntityMap();
    ArrayList<LoanScheduleEntity> loanScheduleEntitiesWithExtraInterest = new ArrayList<LoanScheduleEntity>(loanBO.getLoanScheduleEntities());
    assertExtraInterest(loanScheduleEntitiesWithExtraInterest.get(0), 0.0);
    assertExtraInterest(loanScheduleEntitiesWithExtraInterest.get(1), 0.46);
    assertExtraInterest(loanScheduleEntitiesWithExtraInterest.get(2), 0.0);
}
Also used : Money(org.mifos.framework.util.helpers.Money) Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) ScheduleMatcher(org.mifos.accounts.loan.schedule.domain.ScheduleMatcher) ArrayList(java.util.ArrayList) 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