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;
}
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);
}
Aggregations