Search in sources :

Example 6 with Errors

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

the class LoanAccountServiceFacadeWebTier method validateCashFlowForInstallmentsForWarnings.

@Override
public Errors validateCashFlowForInstallmentsForWarnings(List<CashFlowDataDto> cashFlowDataDtos, Integer productId) {
    Errors errors = new Errors();
    LoanOfferingBO loanOfferingBO = this.loanProductDao.findById(productId);
    if (loanOfferingBO.shouldValidateCashFlowForInstallments()) {
        CashFlowDetail cashFlowDetail = loanOfferingBO.getCashFlowDetail();
        if (CollectionUtils.isNotEmpty(cashFlowDataDtos)) {
            for (CashFlowDataDto cashflowDataDto : cashFlowDataDtos) {
                validateCashFlow(errors, cashFlowDetail.getCashFlowThreshold(), cashflowDataDto);
            }
        }
    }
    return errors;
}
Also used : Errors(org.mifos.platform.validations.Errors) CashFlowDetail(org.mifos.accounts.productdefinition.business.CashFlowDetail) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDataDto(org.mifos.dto.screen.CashFlowDataDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO)

Example 7 with Errors

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

the class LoanAccountActionTest method getLoanRepaymentScheduleShouldValidateViewDate.

@Test
public void getLoanRepaymentScheduleShouldValidateViewDate() throws Exception {
    ActionForward getLoanScheduleFailure = new ActionForward("getLoanRepaymentScheduleFailure");
    java.sql.Date extraInterestDate = TestUtils.getSqlDate(10, 7, 2010);
    Errors errors = new Errors();
    errors.addError(LoanConstants.CANNOT_VIEW_REPAYMENT_SCHEDULE, new String[] { extraInterestDate.toString() });
    when(loanBusinessService.computeExtraInterest(loanBO, extraInterestDate)).thenReturn(errors);
    when(form.getScheduleViewDateValue(Locale.US)).thenReturn(extraInterestDate);
    when(request.getParameter("accountId")).thenReturn("1");
    when(mapping.findForward("getLoanRepaymentScheduleFailure")).thenReturn(getLoanScheduleFailure);
    when(loanServiceFacade.retrieveOriginalLoanSchedule(Matchers.<Integer>any())).thenReturn(new OriginalScheduleInfoDto("100", new Date(), Collections.<RepaymentScheduleInstallment>emptyList()));
    ActionForward forward = loanAccountAction.getLoanRepaymentSchedule(mapping, form, request, response);
    assertThat(forward, is(getLoanScheduleFailure));
    verify(form).resetScheduleViewDate();
}
Also used : Errors(org.mifos.platform.validations.Errors) ActionErrors(org.apache.struts.action.ActionErrors) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) ActionForward(org.apache.struts.action.ActionForward) Date(java.util.Date) Test(org.junit.Test)

Example 8 with Errors

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

the class LoanAccountServiceFacadeWebTierTest method shouldValidateInstallmentSchedule.

@Test
public void shouldValidateInstallmentSchedule() {
    List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
    Errors expectedErrors = new Errors();
    BigDecimal minInstallmentAmount = BigDecimal.ZERO;
    when(installmentsValidator.validateInstallmentSchedule(installments, minInstallmentAmount)).thenReturn(expectedErrors);
    Errors errors = loanAccountServiceFacade.validateInstallmentSchedule(new ArrayList<LoanCreationInstallmentDto>(), minInstallmentAmount);
    assertThat(errors, is(expectedErrors));
    verify(installmentsValidator).validateInstallmentSchedule(installments, minInstallmentAmount);
}
Also used : Errors(org.mifos.platform.validations.Errors) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) ArrayList(java.util.ArrayList) LoanCreationInstallmentDto(org.mifos.dto.domain.LoanCreationInstallmentDto) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 9 with Errors

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

the class JdbcBranchCashConfirmationReportParameterFormTest method testShouldReportErrorIfBranchIdAndDateAreInvalid.

public void testShouldReportErrorIfBranchIdAndDateAreInvalid() throws Exception {
    JdbcBranchCashConfirmationReportParameterForm form = new JdbcBranchCashConfirmationReportParameterForm("-2", "262008");
    Errors errors = new Errors();
    String branchInvalidErrorCode = getErrorCode(errors, ReportValidationConstants.BRANCH_ID_PARAM);
    String dateInvalidErrorCode = getErrorCode(errors, ReportValidationConstants.RUN_DATE_PARAM_FOR_CASH_CONF_REPORT);
    form.validate(errors);
    Assert.assertTrue(errors.hasErrors());
    Assert.assertEquals(ReportValidationConstants.BRANCH_ID_INVALID_MSG, branchInvalidErrorCode);
    Assert.assertEquals(ReportValidationConstants.RUN_DATE_INVALID_MSG, dateInvalidErrorCode);
}
Also used : Errors(org.mifos.platform.validations.Errors)

Example 10 with Errors

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

the class JdbcBranchCashConfirmationReportParameterFormTest method testShouldAcceptValidBranchIdAndDate.

public void testShouldAcceptValidBranchIdAndDate() {
    JdbcBranchCashConfirmationReportParameterForm form = new JdbcBranchCashConfirmationReportParameterForm("1", "26/06/2008");
    Errors errorsMock = createMock(Errors.class);
    replay(errorsMock);
    form.validate(errorsMock);
    verify(errorsMock);
}
Also used : Errors(org.mifos.platform.validations.Errors)

Aggregations

Errors (org.mifos.platform.validations.Errors)31 Date (java.util.Date)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 LocalDate (org.joda.time.LocalDate)7 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)7 BigDecimal (java.math.BigDecimal)6 ActionErrors (org.apache.struts.action.ActionErrors)4 OriginalScheduleInfoDto (org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto)4 LoanCreationInstallmentDto (org.mifos.dto.domain.LoanCreationInstallmentDto)4 ErrorEntry (org.mifos.platform.validations.ErrorEntry)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 CustomerBO (org.mifos.customers.business.CustomerBO)3 Locale (java.util.Locale)2 DateTime (org.joda.time.DateTime)2 Ignore (org.junit.Ignore)2 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)2 LoanScheduleDto (org.mifos.dto.screen.LoanScheduleDto)2 Money (org.mifos.framework.util.helpers.Money)2