use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class InstallmentRulesValidatorTest method shouldValidateForDueDateFallingOnHoliday.
@Test
public void shouldValidateForDueDateFallingOnHoliday() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("01-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).build();
Calendar holiday = installment1.getDueDateValueAsCalendar();
when(holidayServiceFacade.isFutureRepaymentHoliday(officeId, holiday)).thenReturn(true);
List<ErrorEntry> errorEntries = installmentRulesValidator.validateForHolidays(asList(installment1, installment2), holidayServiceFacade, officeId);
assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_IS_HOLIDAY, "1");
verify(holidayServiceFacade, times(1)).isFutureRepaymentHoliday(officeId, holiday);
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class ListOfInstallmentsValidatorTest method shouldValidateInstallmentsForInvalidOrderOfDueDates.
@Test
public void shouldValidateInstallmentsForInvalidOrderOfDueDates() {
RepaymentScheduleInstallment installment0 = installmentBuilder.reset(locale).withInstallment(0).build();
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withDueDateValue("29-Nov-2010").build();
RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).build();
RepaymentScheduleInstallment installment4 = installmentBuilder.reset(locale).withInstallment(4).withDueDateValue("01-Jan-2011").build();
List<ErrorEntry> errorEntries = listOfInstallmentsValidator.validateOrderingOfDueDates(asList(installment0, installment1, installment2, installment3, installment4));
assertThat(errorEntries.get(0).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_INVALID_ORDER));
assertThat(errorEntries.get(0).getArgs(), is(Arrays.asList("2")));
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class ListOfInstallmentsValidatorTest method shouldValidateInstallmentsForDuplicateDueDates.
@Test
public void shouldValidateInstallmentsForDuplicateDueDates() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).build();
RepaymentScheduleInstallment installment4 = installmentBuilder.reset(locale).withInstallment(4).withDueDateValue("01-Jan-2011").build();
RepaymentScheduleInstallment installment5 = installmentBuilder.reset(locale).withInstallment(5).withDueDateValue("31-Dec-2010").build();
RepaymentScheduleInstallment installment6 = installmentBuilder.reset(locale).withInstallment(6).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment7 = installmentBuilder.reset(locale).withInstallment(7).withDueDateValue("31-Dec-2010").build();
List<ErrorEntry> errorEntries = listOfInstallmentsValidator.validateDuplicateDueDates(asList(installment1, installment2, installment3, installment4, installment5, installment6, installment7));
assertThat(errorEntries.size(), is(2));
assertThat(errorEntries.get(0).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_DUPLICATE));
assertThat(errorEntries.get(0).getArgs(), is(Arrays.asList("[1, 2, 6]")));
assertThat(errorEntries.get(1).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_DUPLICATE));
assertThat(errorEntries.get(1).getArgs(), is(Arrays.asList("[5, 7]")));
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class LoanBusinessServiceTest method shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabled.
@Test
public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabled() throws Exception {
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
when(loanAccountActionForm.getInterestRate()).thenReturn("24");
when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(true);
when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);
when(loanBO.toRepaymentScheduleDto(locale)).thenReturn(installments);
loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010), loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(), loanAccountActionForm.getInterestDoubleValue()), locale);
verify(loanBO).updateInstallmentSchedule(installments);
verify(loanBO).toRepaymentScheduleDto(locale);
}
use of org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment in project head by mifos.
the class InstallmentFormatValidatorTest method shouldValidateVariableInstallmentScheduleForInvalidDueDate.
@Test
public void shouldValidateVariableInstallmentScheduleForInvalidDueDate() {
RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDate("abcd").withPrincipal(new Money(rupeeCurrency, "499.9")).withInterest(new Money(rupeeCurrency, "22.1")).withFees(new Money(rupeeCurrency, "0.0")).withTotal("522.0").build();
assertForValidDueDate(installment, "3");
}
Aggregations