Esempio n. 1
0
  @RequestMapping(value = "/delete/{pid}", method = RequestMethod.GET)
  public String deletePayment(ModelMap modelMap, @PathVariable int pid) {

    Payment payment = paymentService.getPaymentById(pid);
    logService.addLog(
        new Log(
            sessionBean.getUserName(),
            "delete",
            "payment delete",
            "удален платеж на сумму: "
                + payment.getCredit()
                + "/ "
                + payment.getDebt()
                + " для клиента "
                + payment.getClientP().getName()
                + " "
                + payment.getClientP().getContractInfo()
                + " "
                + payment.getReason()));

    if (payment.getInvoiceP() != null || payment.getWaybill() != null) {
      modelMap.addAttribute("message", "unable to remove this type of payment!");
      return "/auth/message";
    }

    String message = "payment with id " + payment.getId() + " has been deleted";
    paymentService.deletePayment(payment);
    System.out.println("deleting!!");
    modelMap.addAttribute("message", message);
    return "/auth/message";
  }
Esempio n. 2
0
  @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();
  }