use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class NewOfficePreviewController method processSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = EDIT_PARAM, required = false) String edit, @ModelAttribute("officeFormBean") OfficeFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
if (StringUtils.isNotBlank(cancel)) {
status.setComplete();
} else if (result.hasErrors()) {
modelAndView = new ModelAndView("previewOfficeDetails");
modelAndView.addObject("officeFormBean", formBean);
modelAndView.addObject("showError", "true");
} else if (StringUtils.isNotBlank(edit)) {
EditOfficeInformationController editOfficeInformationController = new EditOfficeInformationController(officeServiceFacade);
modelAndView = new ModelAndView("defineNewOffice");
modelAndView.addObject("showError", "false");
if (!formBean.getLevelId().equals("1")) {
modelAndView.addObject("parentOffices", editOfficeInformationController.getParentDetails(formBean.getLevelId()));
}
modelAndView.addObject("officeTypes", editOfficeInformationController.getOfficeTypes(formBean.getLevelId()));
modelAndView.addObject("officeFormBean", formBean);
modelAndView.addObject("view", "enable");
}
/*Code for update office in else -vishnu*/
return modelAndView;
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class NewPenaltyPreviewController 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") PenaltyFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
if (StringUtils.isNotBlank(edit)) {
modelAndView.setViewName("defineNewPenalty");
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTIES);
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("newPenaltyPreview");
} else {
boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
Short currencyId = null;
Double rate = null;
Short penaltyFormula = null;
Short periodId = 3;
Integer duration = null;
if (ratePenalty) {
rate = Double.valueOf(formBean.getRate());
penaltyFormula = Short.valueOf(formBean.getFormulaId());
}
if (StringUtils.isNotBlank(formBean.getDuration())) {
duration = Integer.valueOf(formBean.getDuration());
}
if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
currencyId = Short.valueOf(formBean.getCurrencyId());
}
if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
periodId = Short.valueOf(formBean.getPeriodTypeId());
}
PenaltyFormDto dto = new PenaltyFormDto();
dto.setCategoryType(Short.valueOf(formBean.getCategoryTypeId()));
dto.setPenaltyPeriod(periodId);
dto.setPenaltyFrequency(Short.valueOf(formBean.getFrequencyId()));
dto.setGlCode(Short.valueOf(formBean.getGlCodeId()));
dto.setPenaltyFormula(penaltyFormula);
dto.setPenaltyName(formBean.getName());
dto.setRatePenalty(ratePenalty);
dto.setCurrencyId(currencyId);
dto.setRate(rate);
dto.setAmount(formBean.getAmount());
dto.setDuration(duration);
dto.setMin(Double.valueOf(formBean.getMin()));
dto.setMax(Double.valueOf(formBean.getMax()));
this.penaltyServiceFacade.createPenalty(dto);
status.setComplete();
}
return modelAndView;
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class PenaltyController method showAllPenalties.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showAllPenalties() {
ModelAndView modelAndView = new ModelAndView("viewPenalties");
modelAndView.addObject("savingPenalties", penaltyServiceFacade.getSavingPenalties());
modelAndView.addObject("loanPenalties", penaltyServiceFacade.getLoanPenalties());
return modelAndView;
}
use of org.springframework.web.bind.annotation.RequestMapping 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.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class PreviewHolidayController 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") HolidayFormBean formBean, BindingResult result, SessionStatus status) {
String viewName = REDIRECT_TO_ADMIN_SCREEN;
ModelAndView modelAndView = new ModelAndView();
if (StringUtils.isNotBlank(edit)) {
viewName = "defineNewHoliday";
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName("redirect:viewHolidays.ftl");
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("previewHoliday");
} else {
HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean);
List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds());
this.holidayServiceFacade.createHoliday(holidayDetail, branchIds);
viewName = REDIRECT_TO_ADMIN_SCREEN;
modelAndView.setViewName(viewName);
status.setComplete();
}
return modelAndView;
}
Aggregations