Search in sources :

Example 1 with CoaDto

use of org.mifos.application.admin.servicefacade.CoaDto in project head by mifos.

the class PreviewCoaController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") CoaFormBean formBean, BindingResult result, SessionStatus status) {
    String viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(edit)) {
        viewName = DEFINE_NEW_COA;
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_COA_ADMIN_SCREEN);
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName(PREVIEW_COA);
    } else {
        try {
            CoaDto coaDto = new CoaDto();
            coaDto.setAccountName(formBean.getCoaName());
            coaDto.setGlCodeString(formBean.getGlCode());
            coaDto.setParentId(formBean.getParentId());
            coaServiceFacade.create(coaDto);
            viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
            modelAndView.setViewName(viewName);
            status.setComplete();
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
            result.addError(error);
            modelAndView.setViewName(PREVIEW_COA);
            modelAndView.addObject("formBean", formBean);
        }
    }
    return modelAndView;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CoaDto

use of org.mifos.application.admin.servicefacade.CoaDto in project head by mifos.

the class CoaServiceFacadeWebTier method getList.

@Override
public List<CoaDto> getList(Short id) {
    List<COABO> coaBoList = null;
    if (id == null) {
        coaBoList = legacyAccountDao.getCOAlist();
    } else {
        coaBoList = legacyAccountDao.getCOAChildList(id);
    }
    List<CoaDto> coaDtoList = new ArrayList<CoaDto>();
    boolean userHasAccess = canModifyCOA();
    for (COABO coaBo : coaBoList) {
        CoaDto dto = coaBo.toDto();
        if (userHasAccess) {
            dto.setModifiable(isModifiable(coaBo));
        } else {
            dto.setModifiable(false);
        }
        coaDtoList.add(dto);
    }
    return coaDtoList;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto) COABO(org.mifos.accounts.financial.business.COABO) ArrayList(java.util.ArrayList)

Example 3 with CoaDto

use of org.mifos.application.admin.servicefacade.CoaDto in project head by mifos.

the class COABO method toDto.

public CoaDto toDto() {
    CoaDto dto = new CoaDto();
    dto.setAccountId(accountId);
    dto.setAccountName(accountName);
    dto.setGlCodeString(this.associatedGlcode.getGlcode());
    COAHierarchyEntity parentHierarchy = coaHierarchy.getParentAccount();
    if (parentHierarchy != null) {
        COABO parent = parentHierarchy.getCoa();
        dto.setParentGlCode(parent.getGlCode());
    }
    return dto;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto)

Example 4 with CoaDto

use of org.mifos.application.admin.servicefacade.CoaDto in project head by mifos.

the class ModifyCoaController method showForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(@RequestParam(value = "id", required = true) Short id) {
    ModelAndView modelAndView = new ModelAndView(MODIFY_COA);
    CoaDto coaDto = coaServiceFacade.getCoaDTO(id);
    CoaFormBean formBean = new CoaFormBean();
    formBean.setCoaName(coaDto.getAccountName());
    formBean.setGlCode(coaDto.getGlCodeString());
    formBean.setAccountId(id);
    formBean.setParentGlCode(coaDto.getParentGlCode());
    modelAndView.addObject("formBean", formBean);
    modelAndView.addObject("COAlist", coaServiceFacade.getList(null));
    return modelAndView;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with CoaDto

use of org.mifos.application.admin.servicefacade.CoaDto in project head by mifos.

the class DeleteCoaController method showForm.

@ModelAttribute("formBean")
@RequestMapping(method = RequestMethod.GET)
public CoaFormBean showForm(@RequestParam(value = "id", required = true) Short id) {
    CoaDto coaDto = coaServiceFacade.getCoaDTO(id);
    CoaFormBean formBean = new CoaFormBean();
    formBean.setCoaName(coaDto.getAccountName());
    formBean.setGlCode(coaDto.getGlCodeString());
    formBean.setAccountId(id);
    return formBean;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CoaDto (org.mifos.application.admin.servicefacade.CoaDto)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ObjectError (org.springframework.validation.ObjectError)2 ArrayList (java.util.ArrayList)1 COABO (org.mifos.accounts.financial.business.COABO)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1