Search in sources :

Example 16 with PrdOfferingDto

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;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ModelAndView(org.springframework.web.servlet.ModelAndView) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with PrdOfferingDto

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;
}
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 18 with PrdOfferingDto

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);
}
Also used : PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with PrdOfferingDto

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());
}
Also used : PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) CustomerBO(org.mifos.customers.business.CustomerBO) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)19 ArrayList (java.util.ArrayList)10 CustomerBO (org.mifos.customers.business.CustomerBO)6 LinkedHashMap (java.util.LinkedHashMap)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 LocalDate (org.joda.time.LocalDate)3 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Test (org.junit.Test)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)2 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 LoanCreationProductDetailsDto (org.mifos.dto.screen.LoanCreationProductDetailsDto)2 MultipleLoanAccountDetailsDto (org.mifos.dto.screen.MultipleLoanAccountDetailsDto)2