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");
}
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");
}
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));
}
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());
}
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++;
}
}
Aggregations