@RequestMapping(value = "/debt/{cid}", method = RequestMethod.GET) public String creditClient( ModelMap model, @PathVariable int cid, @ModelAttribute Payment payment) { model.addAttribute("client", clientService.getClientById(cid)); return "/auth/payment/paymentdebt"; }
@RequestMapping(value = "/credit/{cid}", method = RequestMethod.GET) public String chargeBalance( ModelMap modelMap, @ModelAttribute Payment payment, @PathVariable int cid) { modelMap.addAttribute("client", clientService.getClientById(cid)); return "/auth/payment/paymentcredit"; }
@RequestMapping(value = "/credit/{cid}", method = RequestMethod.POST) public String chargeBalanceP( ModelMap modelMap, @ModelAttribute Payment payment, @PathVariable int cid, @RequestParam(required = true) String type, RedirectAttributes redirectAttributes) { Client client = clientService.getClientById(cid); payment.setPaymentType(type); paymentService.increaseCredit(payment, client, "username"); redirectAttributes.addFlashAttribute("message", Messages.success); redirectAttributes.addFlashAttribute("client", client); redirectAttributes.addFlashAttribute("payment", payment); return "redirect:/auth/payment/credit/" + client.getId(); }
@RequestMapping(value = "/veract/{cid}", method = RequestMethod.GET) public String getVerActP( ModelMap model, @PathVariable int cid, @RequestParam(required = false, defaultValue = "") String dateFrom, @RequestParam(required = false, defaultValue = "") String dateTo, @RequestParam(required = false, defaultValue = "bank") String paymentType) { Client client = clientService.getClientById(cid); Date dFrom; Date dTo; List<Payment> payments; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (!dateFrom.equals("") && !dateTo.equals("")) { try { dFrom = sdf.parse(dateFrom); dTo = sdf.parse(dateTo); payments = reportService.listVerAct(client, dFrom, dTo, paymentType); model.addAttribute("startDate", dFrom); model.addAttribute("endDate", dTo); model.addAttribute("myCompany", myCompanyService.getMyCompanyById(1)); if (payments.size() > 0) { model.addAttribute("payments", payments); } else { model.addAttribute("message", "Нет информации для отображения по выбранному периоду!"); } } catch (ParseException e) { e.printStackTrace(); model.addAttribute("message", "error parsing!"); } } model.addAttribute("client", client); return "/auth/payment/paymentveract"; }