use of org.mifos.dto.domain.PenaltyFormDto 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.mifos.dto.domain.PenaltyFormDto in project head by mifos.
the class EditPenaltyPreviewController 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, PenaltyFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView modelAndView = new ModelAndView();
AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
if (StringUtils.isNotBlank(edit)) {
modelAndView.setViewName("editPenalty");
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("penaltyPreview");
} else {
modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
Short id = Short.valueOf(formBean.getId());
Short categoryType = Short.valueOf(formBean.getCategoryTypeId());
Short penaltyStatus = Short.valueOf(formBean.getStatusId());
Short penaltyFrequency = Short.valueOf(formBean.getFrequencyId());
Short glCode = Short.valueOf(formBean.getGlCodeId());
boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
Short currencyId = null;
Double rate = null;
Short penaltyFormula = null;
Integer duration = null;
Short penaltyPeriod = 3;
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())) {
penaltyPeriod = Short.valueOf(formBean.getPeriodTypeId());
}
Double min = Double.valueOf(formBean.getMin());
Double max = Double.valueOf(formBean.getMax());
PenaltyFormDto dto = new PenaltyFormDto();
dto.setId(id);
dto.setCategoryType(categoryType);
dto.setPenaltyStatus(penaltyStatus);
dto.setPenaltyPeriod(penaltyPeriod);
dto.setPenaltyFrequency(penaltyFrequency);
dto.setGlCode(glCode);
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(min);
dto.setMax(max);
this.penaltyServiceFacade.updatePenalty(dto);
status.setComplete();
}
return modelAndView;
}
Aggregations