Search in sources :

Example 6 with LoanProductRequest

use of org.mifos.dto.domain.LoanProductRequest in project head by mifos.

the class LoanProductPreviewController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = "editFormview", required = false) String editFormview, @ModelAttribute("loanProduct") LoanProductFormBean loanProduct, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN);
    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_ADMIN);
        status.setComplete();
    } else if (StringUtils.isNotBlank(edit)) {
        modelAndView.setViewName(editFormview);
        modelAndView.addObject("loanProduct", loanProduct);
        loanProduct.resetMultiSelectListBoxes();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("previewloanProducts");
        modelAndView.addObject("loanProduct", loanProduct);
        loanProduct.resetMultiSelectListBoxes();
        modelAndView.addObject("editFormview", editFormview);
        new ProductModelAndViewPopulator().populateModelAndViewForPreview(loanProduct, modelAndView);
    } else {
        if ("defineLoanProducts".equals(editFormview)) {
            LoanProductRequest loanProductRequest = loanProductFormBeanAssembler.toLoanProductDto(loanProduct);
            PrdOfferingDto product = adminServiceFacade.createLoanProduct(loanProductRequest);
            modelAndView.setViewName("redirect:/confirmLoanProduct.ftl");
            modelAndView.addObject("product", product);
        } else {
            loanProduct.removeMultiSelectItems();
            LoanProductRequest loanProductRequest = loanProductFormBeanAssembler.toLoanProductDto(loanProduct);
            PrdOfferingDto product = adminServiceFacade.updateLoanProduct(loanProductRequest);
            modelAndView.setViewName("redirect:/viewEditLoanProduct.ftl?productId=" + product.getPrdOfferingId());
            modelAndView.addObject("product", product);
        }
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) LoanProductRequest(org.mifos.dto.domain.LoanProductRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with LoanProductRequest

use of org.mifos.dto.domain.LoanProductRequest in project head by mifos.

the class LoanProductFormBeanAssembler method toLoanProductDto.

public LoanProductRequest toLoanProductDto(LoanProductFormBean loanProductFormBean) {
    ProductDetailsDto loanProductDetails = translateToLoanProductDetails(loanProductFormBean);
    LoanAmountDetailsDto loanAmountDetails = translateToLoanAmountDetails(loanProductFormBean);
    Integer interestRateType = Integer.valueOf(loanProductFormBean.getSelectedInterestRateCalculationType());
    Double maxInterest = Double.valueOf(loanProductFormBean.getMaxInterestRate());
    Double minInterest = Double.valueOf(loanProductFormBean.getMinInterestRate());
    Double defaultInterest = Double.valueOf(loanProductFormBean.getDefaultInterestRate());
    MinMaxDefaultDto interestRateRange = MinMaxDefaultDto.create(minInterest, maxInterest, defaultInterest);
    RepaymentDetailsDto repaymentDetails = translateToRepaymentDetails(loanProductFormBean);
    List<Integer> applicableFees = new ArrayList<Integer>();
    if (loanProductFormBean.getSelectedFees() != null) {
        for (String feeId : loanProductFormBean.getSelectedFees()) {
            applicableFees.add(Integer.valueOf(feeId));
        }
    }
    List<Integer> applicablePenalties = new ArrayList<Integer>();
    if (loanProductFormBean.getSelectedPenalties() != null) {
        for (String penaltyId : loanProductFormBean.getSelectedPenalties()) {
            applicablePenalties.add(Integer.valueOf(penaltyId));
        }
    }
    AccountingDetailsDto accountDetails = translateToAccountingDetails(loanProductFormBean);
    Integer currencyId = null;
    if (StringUtils.isNotBlank(loanProductFormBean.getSelectedCurrency())) {
        currencyId = Integer.valueOf(loanProductFormBean.getSelectedCurrency());
    }
    return new LoanProductRequest(loanProductDetails, loanProductFormBean.isIncludeInLoanCycleCounter(), loanProductFormBean.isWaiverInterest(), currencyId, loanAmountDetails, interestRateType, interestRateRange, repaymentDetails, applicableFees, applicablePenalties, accountDetails);
}
Also used : LoanAmountDetailsDto(org.mifos.dto.screen.LoanAmountDetailsDto) ArrayList(java.util.ArrayList) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) MinMaxDefaultDto(org.mifos.dto.domain.MinMaxDefaultDto) LowerUpperMinMaxDefaultDto(org.mifos.dto.domain.LowerUpperMinMaxDefaultDto) AccountingDetailsDto(org.mifos.dto.screen.AccountingDetailsDto) RepaymentDetailsDto(org.mifos.dto.domain.RepaymentDetailsDto) LoanProductRequest(org.mifos.dto.domain.LoanProductRequest)

Aggregations

LoanProductRequest (org.mifos.dto.domain.LoanProductRequest)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ArrayList (java.util.ArrayList)2 LowerUpperMinMaxDefaultDto (org.mifos.dto.domain.LowerUpperMinMaxDefaultDto)2 MinMaxDefaultDto (org.mifos.dto.domain.MinMaxDefaultDto)2 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)2 RepaymentDetailsDto (org.mifos.dto.domain.RepaymentDetailsDto)2 AccountingDetailsDto (org.mifos.dto.screen.AccountingDetailsDto)2 LoanAmountDetailsDto (org.mifos.dto.screen.LoanAmountDetailsDto)2 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)1 AuditLogDto (org.mifos.dto.domain.AuditLogDto)1 PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)1 AuditLogScreenDto (org.mifos.dto.screen.AuditLogScreenDto)1 LoanProductFormDto (org.mifos.dto.screen.LoanProductFormDto)1