Search in sources :

Example 1 with ScheduleMatcher

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

Example 2 with ScheduleMatcher

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

the class ScheduleMapperTest method shouldMapLoanScheduleEntityToSchedule.

@Test
public void shouldMapLoanScheduleEntityToSchedule() {
    Collection<LoanScheduleEntity> loanScheduleEntities = getLoanScheduleEntities(getDate(24, 11, 2010));
    Schedule schedule = scheduleMapper.mapToSchedule(loanScheduleEntities, DISBURSEMENT_DATE, DAILY_INTEREST_RATE, LOAN_AMOUNT);
    assertThat(schedule, new ScheduleMatcher(getSchedule()));
}
Also used : Schedule(org.mifos.accounts.loan.schedule.domain.Schedule) ScheduleMatcher(org.mifos.accounts.loan.schedule.domain.ScheduleMatcher) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Schedule (org.mifos.accounts.loan.schedule.domain.Schedule)2 ScheduleMatcher (org.mifos.accounts.loan.schedule.domain.ScheduleMatcher)2 ArrayList (java.util.ArrayList)1 Money (org.mifos.framework.util.helpers.Money)1