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