use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.
the class SavingsProductPreviewController 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("savingsProduct") SavingsProductFormBean savingsProduct, BindingResult result) {
ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN);
configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_ADMIN);
} else if (StringUtils.isNotBlank(edit)) {
modelAndView.setViewName(editFormview);
modelAndView.addObject("savingsProduct", savingsProduct);
} else if (result.hasErrors()) {
modelAndView.setViewName("previewSavingsProducts");
modelAndView.addObject("savingsProduct", savingsProduct);
modelAndView.addObject("editFormview", editFormview);
populateModelAndViewForPreview(savingsProduct, modelAndView);
} else {
PrdOfferingDto product;
SavingsProductDto savingsProductRequest = new SavingsProductFormBeanAssembler().assembleSavingsProductRequest(savingsProduct);
if (editFormview.equalsIgnoreCase("defineSavingsProduct")) {
try {
product = this.adminServiceFacade.createSavingsProduct(savingsProductRequest);
modelAndView.setViewName("redirect:/confirmSavingsProduct.ftl");
modelAndView.addObject("product", product);
} catch (BusinessRuleException e) {
handleBusinessRuleViolation(editFormview, savingsProduct, result, modelAndView, e.getMessageKey());
}
} else if (editFormview.equalsIgnoreCase("editSavingsProduct")) {
try {
product = this.adminServiceFacade.updateSavingsProduct(savingsProductRequest);
modelAndView.setViewName("redirect:/viewEditSavingsProduct.ftl?productId=" + product.getPrdOfferingId());
modelAndView.addObject("product", product);
} catch (BusinessRuleException e) {
handleBusinessRuleViolation(editFormview, savingsProduct, result, modelAndView, e.getMessageKey());
}
}
}
return modelAndView;
}
use of org.mifos.dto.domain.PrdOfferingDto 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.PrdOfferingDto in project head by mifos.
the class DefineProductMixController method populateProductNameOptions.
private void populateProductNameOptions(ProductMixFormBean formBean) {
Map<String, String> productNameOptions = new LinkedHashMap<String, String>();
List<PrdOfferingDto> applicableProducts = this.adminServiceFacade.retrieveLoanProductsNotMixed();
for (PrdOfferingDto product : applicableProducts) {
productNameOptions.put(product.getPrdOfferingId().toString(), product.getPrdOfferingName());
}
formBean.setProductNameOptions(productNameOptions);
}
use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.
the class SavingsActionStrutsTest method testGetPrdOfferings.
@Test
public void testGetPrdOfferings() throws Exception {
createInitialObjects();
Date currentDate = new Date(System.currentTimeMillis());
savingsOffering1 = TestObjectFactory.createSavingsProduct("sav prd1", "prd1", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
savingsOffering2 = TestObjectFactory.createSavingsProduct("sav prd2", "prd2", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
addRequestParameter("customerId", group.getCustomerId().toString());
setRequestPathInfo("/savingsAction.do");
addRequestParameter("method", "getPrdOfferings");
actionPerform();
verifyForward("getPrdOfferings_success");
List<PrdOfferingDto> savingPrds = (List<PrdOfferingDto>) SessionUtils.getAttribute(SavingsConstants.SAVINGS_PRD_OFFERINGS, request);
Assert.assertEquals(Integer.valueOf("2").intValue(), savingPrds.size());
CustomerBO client = (CustomerBO) SessionUtils.getAttribute(SavingsConstants.CLIENT, request);
Assert.assertEquals(group.getCustomerId(), client.getCustomerId());
}
Aggregations