Search in sources :

Example 26 with ErrorEntry

use of org.mifos.platform.validations.ErrorEntry 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 27 with ErrorEntry

use of org.mifos.platform.validations.ErrorEntry 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 28 with ErrorEntry

use of org.mifos.platform.validations.ErrorEntry 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 29 with ErrorEntry

use of org.mifos.platform.validations.ErrorEntry in project head by mifos.

the class InstallmentFormatValidatorTest method shouldValidateVariableInstallmentScheduleForValidDueDate.

@Test
public void shouldValidateVariableInstallmentScheduleForValidDueDate() {
    RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDate("30-Nov-2010").withPrincipal(new Money(rupeeCurrency, "499.9")).withInterest(new Money(rupeeCurrency, "22.1")).withFees(new Money(rupeeCurrency, "0.0")).withTotal("522.0").build();
    List<ErrorEntry> errorEntries = installmentFormatValidator.validateDueDateFormat(installment);
    assertThat(errorEntries.isEmpty(), is(true));
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Example 30 with ErrorEntry

use of org.mifos.platform.validations.ErrorEntry in project head by mifos.

the class InstallmentFormatValidatorTest method shouldNotValidateInstallmentScheduleForTotalAmountLessThanZero.

@Test
public void shouldNotValidateInstallmentScheduleForTotalAmountLessThanZero() {
    RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDate("30-Nov-2010").withPrincipal(new Money(rupeeCurrency, "499.9")).withInterest(new Money(rupeeCurrency, "22.1")).withFees(new Money(rupeeCurrency, "0.0")).withTotal("-499.9").build();
    List<ErrorEntry> errorEntries = installmentFormatValidator.validateTotalAmountFormat(installment);
    assertThat(errorEntries.isEmpty(), is(true));
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Aggregations

ErrorEntry (org.mifos.platform.validations.ErrorEntry)42 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)19 Test (org.junit.Test)17 Date (java.util.Date)14 ArrayList (java.util.ArrayList)8 Money (org.mifos.framework.util.helpers.Money)8 DateTime (org.joda.time.DateTime)6 LocalDate (org.joda.time.LocalDate)6 VariableInstallmentDetailsBO (org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO)5 BigDecimal (java.math.BigDecimal)4 Errors (org.mifos.platform.validations.Errors)4 Calendar (java.util.Calendar)2 LoanCreationProductDetailsDto (org.mifos.dto.screen.LoanCreationProductDetailsDto)2 MessageBuilder (org.springframework.binding.message.MessageBuilder)2 MessageContext (org.springframework.binding.message.MessageContext)2 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 VariableInstallmentWithFeeValidationResult (org.mifos.clientportfolio.newloan.applicationservice.VariableInstallmentWithFeeValidationResult)1 CustomerBO (org.mifos.customers.business.CustomerBO)1