コード例 #1
0
ファイル: PaymentController.java プロジェクト: lor2/work2
  @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";
  }
コード例 #2
0
ファイル: PaymentController.java プロジェクト: lor2/work2
  @RequestMapping(value = "/get/{type}", method = RequestMethod.GET)
  public String getPaymentsSpecific(
      ModelMap model,
      @PathVariable String type,
      @RequestParam(required = false, defaultValue = "") String dateFrom,
      @RequestParam(required = false, defaultValue = "") String dateTo,
      @RequestParam(required = false, defaultValue = "") String clientStr) {

    List<Payment> payments = new ArrayList<>();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyy-MM-dd");
    Date d1 = new Date();
    Date d2 = new Date();

    model
        .addAttribute("dateFrom", dateFrom)
        .addAttribute("dateTo", dateTo)
        .addAttribute("clientStr", clientStr);

    if (type.equals("in")) {

      if (!dateFrom.equals("") && !dateTo.equals("")) {
        try {
          d1 = sdf.parse(dateFrom);
          d2 = sdf.parse(dateTo);
        } catch (ParseException e) {
          e.printStackTrace();
        }
        payments = paymentService.listPayments(clientStr, d1, d2);
      }

      if (dateFrom.equals("") && dateTo.equals("") && !clientStr.equals("")) {
        try {
          d1 = sdf.parse("1971-01-01");
          d2 = sdf.parse("2025-01-01");
        } catch (ParseException e) {
          e.printStackTrace();
        }
        payments = paymentService.listPayments(clientStr, d1, d2);
      }

      if (dateFrom.equals("") && dateTo.equals("") && clientStr.equals("")) {
        payments = paymentService.listPayments();
      }
      model.addAttribute("payments", payments);
      return "/auth/payment/paymentgetin";
    }

    // model.addAttribute("payments", paymentService.listPayments());
    return "/auth/payment/paymentget";
  }
コード例 #3
0
ファイル: PaymentController.java プロジェクト: lor2/work2
  @RequestMapping(value = "/roundall", method = RequestMethod.GET)
  public String roundPaymentTable(ModelMap modelMap) {
    paymentService.roundAllBalances();
    System.out.println("rounding!!!");

    return "redirect:/";
  }
コード例 #4
0
ファイル: PaymentController.java プロジェクト: lor2/work2
 @RequestMapping(value = "/recalc", method = RequestMethod.GET)
 public String recalcPaymentTable(ModelMap modelMap) {
   paymentService.recalcPaymentTable();
   modelMap.addAttribute("message", "recalc is done");
   System.out.println("recalcing!!!");
   return "/auth/message";
 }
コード例 #5
0
ファイル: PaymentController.java プロジェクト: lor2/work2
  @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();
  }
コード例 #6
0
ファイル: PaymentController.java プロジェクト: lor2/work2
  @RequestMapping(value = "/get", method = RequestMethod.GET)
  public String getPaymentsAll(ModelMap model) {

    model.addAttribute("payments", paymentService.listPayments());
    return "/auth/payment/paymentget";
  }