use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class CashFlowSummaryFormBean method prevalidateActualPaymentDateIsNonNull.
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = { "DLS_DEAD_LOCAL_STORE" }, justification = "")
private void prevalidateActualPaymentDateIsNonNull(MessageContext messageContext) {
Integer installmentIndex = 1;
for (DateTime dueDate : this.actualPaymentDates) {
if (dueDate == null) {
String defaultMessage = "The actual payment date field for installment {0} is blank.";
ErrorEntry fieldError = new ErrorEntry("installment.actualpaymentdate.blank.and.invalid", "installmentAmounts", defaultMessage);
fieldError.setArgs(Arrays.asList(installmentIndex.toString()));
addErrorMessageToContext(messageContext, fieldError);
}
installmentIndex++;
}
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class XlsLoansAccountImporter method validateDisbursalDate.
private void validateDisbursalDate(Date disbursalDate, CustomerBO customerBO, LoanOfferingBO loanOfferingBO, int currentCell, HSSFRow currentRow, String statusName) throws XlsParsingException {
if (disbursalDate == null) {
throw new XlsParsingException(getCellError(XlsMessageConstants.MISSING_DISBURSAL_DATE, currentRow, currentCell, null));
}
LocalDate localDisbursalDate = new LocalDate(disbursalDate.getTime());
Errors errors = loanAccountServiceFacade.validateLoanDisbursementDate(localDisbursalDate, customerBO.getCustomerId(), loanOfferingBO.getPrdOfferingId().intValue());
if (localDisbursalDate.isAfter(new LocalDate()) && (statusName.equals("Active in good standing") || statusName.equals("Active in bad standing"))) {
String[] args = { "" };
errors.addError("import.loan.account.disbursal.date", args);
}
if (errors.hasErrors()) {
XlsParsingException xlEx = new XlsParsingException(true);
List<Object> tmp = new ArrayList<Object>();
tmp.add(localDisbursalDate);
xlEx.getMessages().add(getCellError(XlsMessageConstants.INVALID_DATE, currentRow, currentCell, tmp));
for (ErrorEntry entry : errors.getErrorEntries()) {
xlEx.getMessages().add(getNestedMessage(entry.getErrorCode(), entry.getArgs()));
}
throw xlEx;
}
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class LoanBusinessServiceTest method shouldComputeExtraInterestAsOfDateEarlierThanLastPaymentDate.
@Test
public void shouldComputeExtraInterestAsOfDateEarlierThanLastPaymentDate() {
Date asOfDate = TestUtils.getDate(1, 9, 2010);
Date lastPaymentDate = TestUtils.getDate(10, 9, 2010);
when(accountPaymentEntity.getPaymentDate()).thenReturn(lastPaymentDate);
when(loanBO.findMostRecentNonzeroPaymentByPaymentDate()).thenReturn(accountPaymentEntity);
when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
Errors errors = loanBusinessService.computeExtraInterest(loanBO, asOfDate);
assertThat(errors, is(not(nullValue())));
assertThat(errors.hasErrors(), is(true));
List<ErrorEntry> errorEntries = errors.getErrorEntries();
assertThat(errorEntries, is(not(nullValue())));
assertThat(errorEntries.size(), is(1));
assertThat(errorEntries.get(0).getErrorCode(), is(LoanConstants.CANNOT_VIEW_REPAYMENT_SCHEDULE));
verify(scheduleCalculatorAdaptor, never()).computeExtraInterest(loanBO, asOfDate);
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class InstallmentRulesValidatorTest method shouldValidateInstallmentForDueDateBeforeDisburseDate.
@Test
public void shouldValidateInstallmentForDueDateBeforeDisburseDate() {
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-Dec-2010");
List<ErrorEntry> errorEntries = installmentRulesValidator.validateForDisbursementDate(asList(installment), dateValue);
assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_BEFORE_DISBURSE_DATE, "3");
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class InstallmentRulesValidatorTest method shouldValidateMaximumGapOfFiveDaysForFirstInstallmentAndDisbursementDate.
@Test
public void shouldValidateMaximumGapOfFiveDaysForFirstInstallmentAndDisbursementDate() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("01-Nov-2010").build();
VariableInstallmentDetailsBO variableInstallmentDetails = getVariableInstallmentDetails(null, 5, 100, rupee);
List<RepaymentScheduleInstallment> installments = asList(installment1);
Date disbursementDate = getDate(installment1, "25-Oct-2010");
List<ErrorEntry> errorEntries = installmentRulesValidator.validateDueDatesForVariableInstallments(installments, variableInstallmentDetails, disbursementDate);
assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_MORE_THAN_MAX_GAP, "1");
}
Aggregations