Search in sources :

Example 46 with RepaymentScheduleInstallment

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);
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Calendar(java.util.Calendar) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Example 47 with RepaymentScheduleInstallment

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")));
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Example 48 with RepaymentScheduleInstallment

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]")));
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Example 49 with RepaymentScheduleInstallment

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);
}
Also used : LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Test(org.junit.Test)

Example 50 with RepaymentScheduleInstallment

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");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) Test(org.junit.Test)

Aggregations

RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)66 Test (org.junit.Test)44 Money (org.mifos.framework.util.helpers.Money)34 Date (java.util.Date)27 ArrayList (java.util.ArrayList)19 ErrorEntry (org.mifos.platform.validations.ErrorEntry)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)7 VariableInstallmentDetailsBO (org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)7 OriginalScheduleInfoDto (org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto)6 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)6 Errors (org.mifos.platform.validations.Errors)6 MifosCurrency (org.mifos.application.master.business.MifosCurrency)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 BigDecimal (java.math.BigDecimal)4 ActionErrors (org.apache.struts.action.ActionErrors)4 Ignore (org.junit.Ignore)4 HashSet (java.util.HashSet)3 LocalDate (org.joda.time.LocalDate)3 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)3 MessageLookup (org.mifos.application.master.MessageLookup)3