Search in sources :

Example 6 with ErrorEntry

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

the class InstallmentRulesValidatorTest method shouldValidateForMinimumInstallmentAmount.

@Test
public void shouldValidateForMinimumInstallmentAmount() {
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "194.4", "4.6", "1", "5");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "195.3", "3.7", "1", "4");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "196.2", "2.8", "1", "3");
    RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("22-Sep-2010", 4, "414.1", "1.9", "1", "417.0");
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
    List<ErrorEntry> errorEntries = installmentRulesValidator.validateForMinimumInstallmentAmount(installments, BigDecimal.valueOf(Double.valueOf("50.0")));
    assertThat(errorEntries.size(), is(3));
    assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_AMOUNT_LESS_THAN_INTEREST_FEE, "1");
    assertErrorEntry(errorEntries.get(1), AccountConstants.INSTALLMENT_AMOUNT_LESS_THAN_INTEREST_FEE, "2");
    assertErrorEntry(errorEntries.get(2), AccountConstants.INSTALLMENT_AMOUNT_LESS_THAN_INTEREST_FEE, "3");
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Test(org.junit.Test)

Example 7 with ErrorEntry

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

the class InstallmentRulesValidatorTest method shouldValidateInstallmentForDueDateSameAsDisburseDate.

@Test
public void shouldValidateInstallmentForDueDateSameAsDisburseDate() {
    RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDateValue("30-Nov-2010").withPrincipal(new Money(rupee, "499.9")).withInterest(new Money(rupee, "22.1")).withFees(new Money(rupee, "0.0")).withTotal("522.0").build();
    Date dateValue = getDate(installment, "30-Nov-2010");
    List<ErrorEntry> errorEntries = installmentRulesValidator.validateForDisbursementDate(asList(installment), dateValue);
    assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_SAME_AS_DISBURSE_DATE, "3");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) Test(org.junit.Test)

Example 8 with ErrorEntry

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

the class InstallmentRulesValidatorTest method shouldNotValidateForValidVariableInstallments.

@Test
public void shouldNotValidateForValidVariableInstallments() {
    RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("01-Nov-2010").build();
    RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("03-Nov-2010").build();
    RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).withPrincipal(new Money(rupee, "49")).withTotalValue("50").withDueDateValue("06-Nov-2010").build();
    VariableInstallmentDetailsBO variableInstallmentDetails = getVariableInstallmentDetails(2, 5, 50, rupee);
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
    Date disbursementDate = getDate(installment1, "27-Oct-2010");
    List<ErrorEntry> errorEntries = installmentRulesValidator.validateDueDatesForVariableInstallments(installments, variableInstallmentDetails, disbursementDate);
    assertThat(errorEntries.isEmpty(), is(true));
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) VariableInstallmentDetailsBO(org.mifos.accounts.productdefinition.business.VariableInstallmentDetailsBO) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) Test(org.junit.Test)

Example 9 with ErrorEntry

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

the class BranchReportParameterValidatorTest method testValidatorAddsErrorIfServiceSaysNoDataFound.

public void testValidatorAddsErrorIfServiceSaysNoDataFound() throws Exception {
    expect(branchReportServiceMock.isReportDataPresentForRundateAndBranchId(BRANCH_ID, VALID_RUN_DATE)).andReturn(Boolean.FALSE);
    replay(branchReportServiceMock);
    validator.validate(validForm, errors);
    verify(branchReportServiceMock);
    Assert.assertTrue(errors.hasErrors());
    ErrorEntry fieldError = errors.getFieldError(ReportValidationConstants.RUN_DATE_PARAM);
    Assert.assertNotNull(fieldError);
    Assert.assertEquals(ReportValidationConstants.BRANCH_REPORT_NO_DATA_FOUND_MSG, fieldError.getErrorCode());
}
Also used : ErrorEntry(org.mifos.platform.validations.ErrorEntry)

Example 10 with ErrorEntry

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

the class CashFlowSummaryFormBean method prevalidateTotalIsNonNull.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = { "DLS_DEAD_LOCAL_STORE" }, justification = "")
private void prevalidateTotalIsNonNull(MessageContext messageContext) {
    Integer installmentIndex = 1;
    for (Number totalAmount : this.installmentAmounts) {
        if (totalAmount == null) {
            String defaultMessage = "The total amount field for installment {0} was blank and has been defaulted to zero.";
            ErrorEntry fieldError = new ErrorEntry("installment.total.amount.blank.and.invalid", "installmentAmounts", defaultMessage);
            fieldError.setArgs(Arrays.asList(installmentIndex.toString()));
            this.installmentAmounts.set(installmentIndex - 1, Integer.valueOf(0));
            addErrorMessageToContext(messageContext, fieldError);
        }
        installmentIndex++;
    }
}
Also used : ErrorEntry(org.mifos.platform.validations.ErrorEntry)

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