Search in sources :

Example 1 with MultipleLoanCreationDto

use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveMultipleLoanAccountDetails.

@Override
public MultipleLoanAccountDetailsDto retrieveMultipleLoanAccountDetails(String searchId, Short branchId, Integer productId) {
    List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
    if (clients.isEmpty()) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
    // FIXME - Refactor MultipleLoanCreationDto into proper Dto
    List<MultipleLoanCreationDto> multipleLoanDetails = buildClientViewHelper(loanOffering, clients);
    List<ValueListElement> allLoanPruposes = this.loanProductDao.findAllLoanPurposes();
    boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
    return new MultipleLoanAccountDetailsDto(allLoanPruposes, loanPendingApprovalStateEnabled);
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) MultipleLoanAccountDetailsDto(org.mifos.dto.screen.MultipleLoanAccountDetailsDto) ClientBO(org.mifos.customers.client.business.ClientBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MultipleLoanCreationDto(org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 2 with MultipleLoanCreationDto

use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.

the class MultipleLoanAccountsCreationAction method get.

@TransactionDemarcate(joinToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MultipleLoanAccountsCreationActionForm loanActionForm = (MultipleLoanAccountsCreationActionForm) form;
    String searchId = loanActionForm.getCenterSearchId();
    Short branchId = getShortValue(loanActionForm.getBranchOfficeId());
    Integer productId = Integer.parseInt(loanActionForm.getPrdOfferingId());
    MultipleLoanAccountDetailsDto multipleLoanDetails = this.loanAccountServiceFacade.retrieveMultipleLoanAccountDetails(searchId, branchId, productId);
    List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
    if (clients.isEmpty()) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
    List<MultipleLoanCreationDto> multipleLoanDetailsXX = buildClientViewHelper(loanOffering, clients);
    loanActionForm.setClientDetails(multipleLoanDetailsXX);
    SessionUtils.setAttribute(LoanConstants.LOANOFFERING, loanOffering, request);
    SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, multipleLoanDetails.getAllLoanPruposes(), request);
    SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, multipleLoanDetails.isLoanPendingApprovalStateEnabled(), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) MultipleLoanAccountDetailsDto(org.mifos.dto.screen.MultipleLoanAccountDetailsDto) ClientBO(org.mifos.customers.client.business.ClientBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MultipleLoanCreationDto(org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto) MultipleLoanAccountsCreationActionForm(org.mifos.accounts.loan.struts.actionforms.MultipleLoanAccountsCreationActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with MultipleLoanCreationDto

use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.

the class MultipleLoanAccountsCreationAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MultipleLoanAccountsCreationActionForm loanActionForm = (MultipleLoanAccountsCreationActionForm) form;
    Integer centerId = getIntegerValue(loanActionForm.getCenterId());
    Short loanProductId = getShortValue(loanActionForm.getPrdOfferingId());
    Short accountStateId = getShortValue(loanActionForm.getStateSelected());
    List<MultipleLoanCreationDto> applicableClientDetails = loanActionForm.getApplicableClientDetails();
    List<CreateLoanRequest> createMultipleLoans = new ArrayList<CreateLoanRequest>();
    for (MultipleLoanCreationDto clientDetail : applicableClientDetails) {
        CreateLoanRequest createLoanRequest = new CreateLoanRequest(centerId, loanProductId, accountStateId, clientDetail.getClientId(), clientDetail.getLoanAmount(), clientDetail.getDefaultNoOfInstall(), clientDetail.getMaxLoanAmount().toString(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxNoOfInstall(), clientDetail.getMinNoOfInstall(), getIntegerValue(clientDetail.getBusinessActivity()));
        createMultipleLoans.add(createLoanRequest);
    }
    List<String> accountNumbers = this.loanAccountServiceFacade.createMultipleLoans(createMultipleLoans);
    request.setAttribute(LoanConstants.ACCOUNTS_LIST, accountNumbers);
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : ArrayList(java.util.ArrayList) MultipleLoanCreationDto(org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto) MultipleLoanAccountsCreationActionForm(org.mifos.accounts.loan.struts.actionforms.MultipleLoanAccountsCreationActionForm) CreateLoanRequest(org.mifos.dto.domain.CreateLoanRequest) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with MultipleLoanCreationDto

use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.

the class MultipleLoanAccountsCreationActionForm method checkValidationForCreate.

private void checkValidationForCreate(ActionErrors errors, HttpServletRequest request) throws PageExpiredException, ServiceException {
    logger.debug("inside checkValidationForCreate method");
    List<MultipleLoanCreationDto> applicableClientDetails = getApplicableClientDetails();
    if (CollectionUtils.isEmpty(applicableClientDetails)) {
        addError(errors, LoanConstants.APPL_RECORDS, LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD, getLabel(ConfigurationConstants.CLIENT));
        return;
    }
    for (MultipleLoanCreationDto clientDetail : applicableClientDetails) {
        try {
            if (!clientDetail.isLoanAmountInRange()) {
                addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.INVALIDMINMAX, this.getLocalizedMessage("loan.loanAmountFor") + clientDetail.getClientName(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxLoanAmount().toString());
            }
        } catch (NumberFormatException nfe) {
            addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.INVALIDMINMAX, this.getLocalizedMessage("loan.loanAmountFor") + clientDetail.getClientName(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxLoanAmount().toString());
        }
        if (StringUtils.isEmpty(clientDetail.getBusinessActivity()) && isPurposeOfLoanMandatory(request)) {
            addError(errors, LoanConstants.PURPOSE_OF_LOAN, LoanExceptionConstants.CUSTOMER_PURPOSE_OF_LOAN_FIELD);
        }
    }
    logger.debug("outside checkValidationForCreate method");
}
Also used : MultipleLoanCreationDto(org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto)

Aggregations

MultipleLoanCreationDto (org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto)4 MultipleLoanAccountsCreationActionForm (org.mifos.accounts.loan.struts.actionforms.MultipleLoanAccountsCreationActionForm)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 MultipleLoanAccountDetailsDto (org.mifos.dto.screen.MultipleLoanAccountDetailsDto)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ArrayList (java.util.ArrayList)1 CreateLoanRequest (org.mifos.dto.domain.CreateLoanRequest)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1