Search in sources :

Example 1 with Errors

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

the class InstallmentsValidatorImpl method validateInputInstallments.

@Override
public Errors validateInputInstallments(List<RepaymentScheduleInstallment> installments, InstallmentValidationContext installmentValidationContext) {
    Errors errors = new Errors();
    validateInstallmentFormat(installments, errors);
    validateListOfInstallments(installments, errors);
    validateBusinessRulesForInstallments(installments, installmentValidationContext, errors);
    return errors;
}
Also used : Errors(org.mifos.platform.validations.Errors)

Example 2 with Errors

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

the class InstallmentsValidatorImpl method validateInstallmentSchedule.

@Override
public Errors validateInstallmentSchedule(List<RepaymentScheduleInstallment> installments, BigDecimal minInstallmentAmountAllowed) {
    Errors errors = new Errors();
    errors.addErrors(installmentRulesValidator.validateForMinimumInstallmentAmount(installments, minInstallmentAmountAllowed));
    return errors;
}
Also used : Errors(org.mifos.platform.validations.Errors)

Example 3 with Errors

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

the class LoanBusinessServiceTest method shouldComputeExtraInterestAsOfDateLaterThanLastPaymentDate.

@Test
public void shouldComputeExtraInterestAsOfDateLaterThanLastPaymentDate() {
    Date asOfDate = TestUtils.getDate(10, 9, 2010);
    Date lastPaymentDate = TestUtils.getDate(1, 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(false));
    verify(scheduleCalculatorAdaptor).computeExtraInterest(loanBO, asOfDate);
}
Also used : Errors(org.mifos.platform.validations.Errors) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Errors

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

the class LoanAccountAction method getLoanRepaymentSchedule.

@TransactionDemarcate(saveToken = true)
public ActionForward getLoanRepaymentSchedule(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form;
    UserContext userContext = getUserContext(request);
    Integer loanId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
    Locale locale = userContext.getPreferredLocale();
    Date viewDate = loanAccountActionForm.getScheduleViewDateValue(locale);
    LoanBO loan = getLoan(loanId);
    setSessionAtributeForGLIM(request, loan);
    loan.updateDetails(userContext);
    Errors errors = loanBusinessService.computeExtraInterest(loan, viewDate);
    if (errors.hasErrors()) {
        loanAccountActionForm.resetScheduleViewDate();
    }
    OriginalScheduleInfoDto originalSchedule = this.loanServiceFacade.retrieveOriginalLoanSchedule(loanId);
    String memberAccountIdParam = request.getParameter("memberAccountId");
    if (StringUtils.isNotBlank(memberAccountIdParam)) {
        Integer memberId = Integer.valueOf(memberAccountIdParam);
        LoanBO member = loan.findMemberById(memberId);
        if (member != null) {
            SessionUtils.setAttribute(CustomerConstants.CUSTOMER_NAME, member.getCustomer().getDisplayName(), request);
            SessionUtils.setAttribute(CustomerConstants.GLOBAL_CUST_NUM, member.getCustomer().getGlobalCustNum(), request);
        }
    }
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
    SessionUtils.setAttribute(Constants.ORIGINAL_SCHEDULE_AVAILABLE, originalSchedule.hasOriginalInstallments(), request);
    SessionUtils.setAttribute(Constants.VIEW_DATE, viewDate, request);
    String forward = errors.hasErrors() ? ActionForwards.getLoanRepaymentScheduleFailure.toString() : ActionForwards.getLoanRepaymentSchedule.toString();
    addErrors(request, getActionErrors(errors));
    return mapping.findForward(forward);
}
Also used : Locale(java.util.Locale) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) ActionErrors(org.apache.struts.action.ActionErrors) Errors(org.mifos.platform.validations.Errors) UserContext(org.mifos.security.util.UserContext) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.util.Date) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with Errors

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

the class LoanAccountServiceFacadeWebTier method retrieveGetProductDetailsForLoanAccountCreation.

@Override
public LoanCreationProductDetailsDto retrieveGetProductDetailsForLoanAccountCreation(final Integer customerId) {
    final CustomerBO customer = this.customerDao.findCustomerById(customerId);
    final CustomerDetailDto customerDetailDto = customer.toCustomerDetailDto();
    // FIXME - keithw - below code is not needed when jsp/struts is removed as this is worked out for enter loan account details step.
    final Date nextMeetingDate = customer.getCustomerAccount().getNextMeetingDate();
    final String recurMonth = customer.getCustomerMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString();
    final boolean isGroup = customer.isGroup();
    final boolean isGlimEnabled = configurationPersistence.isGlimEnabled();
    final boolean isLsimEnabled = configurationPersistence.isRepaymentIndepOfMeetingEnabled();
    final boolean isGroupLoanWithMembersEnabled = AccountingRules.isGroupLoanWithMembers();
    List<PrdOfferingDto> loanProductDtos = retrieveActiveLoanProductsApplicableForCustomer(customer, isLsimEnabled);
    LoanCreationGlimDto loanCreationGlimDto = null;
    List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
    Errors errors = new Errors();
    List<ErrorEntry> errorEntry = new ArrayList<ErrorEntry>();
    if (isGroup && isGlimEnabled && isGroupLoanWithMembersEnabled) {
        String defaultMessage = "New Group Loan option is enabled in configuration file and also GLIM option is enabled in the database. Loan for Group will be created using new Group Loan approach. Please turn off GLIM option in database. If you want to create Loan for Group using old approach, then please disable AccountingRules.GroupLoanWithMembers option in configuration file and restart Mifos.";
        errorEntry.add(new ErrorEntry("createLoanAccount.glim.and.new.glim.are.enabled", "activeClients2", defaultMessage));
        errors.addErrors(errorEntry);
    }
    if (isGroup && (isGlimEnabled || isGroupLoanWithMembersEnabled)) {
        final List<ValueListElement> loanPurposes = loanProductDao.findAllLoanPurposes();
        final List<ClientBO> activeClientsOfGroup = customerDao.findActiveClientsUnderGroup(customer);
        loanCreationGlimDto = new LoanCreationGlimDto(loanPurposes);
        if (activeClientsOfGroup == null || activeClientsOfGroup.size() < 2) {
            errorEntry.clear();
            String defaultMessage = "Group loan is not allowed as there must be at least two active clients within the group when Group loan with individual monitoring (GLIM) is enabled";
            errorEntry.add(new ErrorEntry("createLoanAccount.glim.invalid.less.than.two.active.clients.in.group", "activeClients", defaultMessage));
            errors.addErrors(errorEntry);
            loanProductDtos = new ArrayList<PrdOfferingDto>();
        } else {
            for (ClientBO client : activeClientsOfGroup) {
                LoanAccountDetailsDto clientDetail = new LoanAccountDetailsDto();
                clientDetail.setClientId(client.getCustomerId().toString());
                clientDetail.setClientName(client.getDisplayName());
                clientDetails.add(clientDetail);
            }
        }
    }
    return new LoanCreationProductDetailsDto(loanProductDtos, customerDetailDto, nextMeetingDate, recurMonth, isGroup, isGlimEnabled, loanCreationGlimDto, clientDetails, errors);
}
Also used : LoanCreationGlimDto(org.mifos.dto.screen.LoanCreationGlimDto) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ErrorEntry(org.mifos.platform.validations.ErrorEntry) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) MultipleLoanAccountDetailsDto(org.mifos.dto.screen.MultipleLoanAccountDetailsDto) Errors(org.mifos.platform.validations.Errors) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) LoanCreationProductDetailsDto(org.mifos.dto.screen.LoanCreationProductDetailsDto) ValueListElement(org.mifos.dto.domain.ValueListElement)

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