Search in sources :

Example 21 with ErrorEntry

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++;
    }
}
Also used : ErrorEntry(org.mifos.platform.validations.ErrorEntry) DateTime(org.joda.time.DateTime)

Example 22 with ErrorEntry

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;
    }
}
Also used : Errors(org.mifos.platform.validations.Errors) ArrayList(java.util.ArrayList) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) LocalDate(org.joda.time.LocalDate) ErrorEntry(org.mifos.platform.validations.ErrorEntry)

Example 23 with ErrorEntry

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);
}
Also used : Errors(org.mifos.platform.validations.Errors) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) Test(org.junit.Test)

Example 24 with ErrorEntry

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");
}
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 25 with ErrorEntry

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");
}
Also used : 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)

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