Ejemplo n.º 1
0
 @RequestMapping(value = "/admin/taxRates/{taxRateId}/edit", method = RequestMethod.POST)
 public String taxRateEditSave(
     @PathVariable long taxRateId,
     @RequestParam(value = "page", defaultValue = FIRST_PAGE) int page,
     @Valid TaxRate thisTaxRate,
     BindingResult result,
     Model model) {
   logger.info("TaxRate: " + thisTaxRate.toString());
   if (result.hasErrors()) {
     int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
     model.addAttribute("menuCategory", menuCategory);
     model.addAttribute("thisTaxRate", thisTaxRate);
     Pageable pageRequest = new PageRequest(page, PAGE_SIZE, Sort.Direction.ASC, "priority");
     Page<TaxRate> taxRates = taxRateService.findAll(pageRequest);
     model.addAttribute("taxRates", taxRates);
     return "admin/taxes/taxRatesEditForm";
   } else {
     TaxRate loadedTaxRate = taxRateService.findById(taxRateId);
     loadedTaxRate.setLastModified(new Date());
     loadedTaxRate.setPriority(thisTaxRate.getPriority());
     loadedTaxRate.setTaxRate(thisTaxRate.getTaxRate());
     loadedTaxRate.setTaxClass(thisTaxRate.getTaxClass());
     loadedTaxRate.setTaxZone(thisTaxRate.getTaxZone());
     taxRateService.update(loadedTaxRate);
     return "redirect:/admin/taxRates/" + taxRateId + "?page=" + page;
   }
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/admin/taxRates/{taxRateId}/delete", method = RequestMethod.GET)
 public String taxRateDeleteForm(
     @PathVariable long taxRateId,
     @RequestParam(value = "page", defaultValue = FIRST_PAGE) int page,
     Model model) {
   int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
   model.addAttribute("menuCategory", menuCategory);
   TaxRate thisTaxRate = taxRateService.findById(taxRateId);
   model.addAttribute("thisTaxRate", thisTaxRate);
   Pageable pageRequest = new PageRequest(page, PAGE_SIZE, Sort.Direction.ASC, "priority");
   Page<TaxRate> taxRates = taxRateService.findAll(pageRequest);
   model.addAttribute("taxRates", taxRates);
   return "admin/taxes/taxRatesDeleteForm";
 }
Ejemplo n.º 3
0
 @RequestMapping(value = "/admin/taxRates", method = RequestMethod.GET)
 public String taxRates(
     @RequestParam(value = "page", defaultValue = FIRST_PAGE) int page, Model model) {
   int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
   model.addAttribute("menuCategory", menuCategory);
   Pageable pageRequest = new PageRequest(page, PAGE_SIZE, Sort.Direction.ASC, "priority");
   Page<TaxRate> taxRates = taxRateService.findAll(pageRequest);
   model.addAttribute("taxRates", taxRates);
   TaxRate thisTaxRate = null;
   if (taxRates.getContent().size() > 0) {
     thisTaxRate = taxRates.iterator().next();
   }
   model.addAttribute("thisTaxRate", thisTaxRate);
   return "admin/taxes/taxRates";
 }
Ejemplo n.º 4
0
 @RequestMapping(value = "/admin/taxRates/insert", method = RequestMethod.GET)
 public String taxRateInsertForm(
     @RequestParam(value = "page", defaultValue = FIRST_PAGE) int page, Model model) {
   int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
   model.addAttribute("menuCategory", menuCategory);
   Pageable pageRequest = new PageRequest(page, PAGE_SIZE, Sort.Direction.ASC, "priority");
   Page<TaxRate> taxRates = taxRateService.findAll(pageRequest);
   model.addAttribute("taxRates", taxRates);
   TaxRate thisTaxRate = new TaxRate();
   model.addAttribute("thisTaxRate", thisTaxRate);
   List<TaxZone> taxZones = taxZoneService.findAll();
   model.addAttribute("taxZones", taxZones);
   List<TaxClass> taxClasses = taxClassService.findAll();
   model.addAttribute("taxClasses", taxClasses);
   return "admin/taxes/taxRatesInsertForm";
 }
Ejemplo n.º 5
0
 @RequestMapping(value = "/admin/taxRates/insert", method = RequestMethod.POST)
 public String taxRateInsertPerform(
     @RequestParam(value = "page", defaultValue = FIRST_PAGE) int page,
     @Valid TaxRate thisTaxRate,
     BindingResult result,
     Model model) {
   logger.info("TaxRate: " + thisTaxRate.toString());
   if (result.hasErrors()) {
     int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
     model.addAttribute("menuCategory", menuCategory);
     Pageable pageRequest = new PageRequest(page, PAGE_SIZE, Sort.Direction.ASC, "priority");
     Page<TaxRate> taxRates = taxRateService.findAll(pageRequest);
     model.addAttribute("taxRates", taxRates);
     model.addAttribute("thisTaxRate", thisTaxRate);
     return "admin/taxes/taxRatesInsertForm";
   } else {
     taxRateService.create(thisTaxRate);
     return "redirect:/admin/taxRates/" + thisTaxRate.getId() + "?page=" + page;
   }
 }