private void saveDoc(HttpServletRequest req) {

    if (!req.getParameter("SaveDoc").isEmpty()) {

      PaymentDocument paymentDocument =
          (PaymentDocument) req.getSession(false).getAttribute("currentPaymentDocumentForEdit");

      if (paymentDocument == null) {

        LOG.error("Payment Document not found in session scope.");
        req.getSession(false)
            .setAttribute("errorMessage", "Payment Document not found. Please reload the page.");

      } else {

        try {

          if (paymentDocument.getId() == 0) {
            paymentDocumentService.createDoc(paymentDocument);
          } else {
            paymentDocumentService.updateDoc(paymentDocument);
          }

        } catch (POMServicesException e) {

          LOG.error("Could not save Document: " + e.getMessage(), e);
          req.getSession(false)
              .setAttribute("errorMessage", "Could not save Document:" + e.getMessage());
          return;
        }
      }
    }
  }
  private void deletePaymentDocument(HttpServletRequest req) {

    try {

      long id = Long.parseLong(req.getParameter("DellCurrent"));

      paymentDocumentService.deleteDoc(paymentDocumentService.retrieveDocById(id));

    } catch (POMServicesException | NumberFormatException e) {

      LOG.error("Can not delete Payment Document: " + e.getMessage(), e);
      req.getSession(false)
          .setAttribute("errorMessage", "Can not delete Payment Document: " + e.getMessage());
      return;
    }
  }
  private void setCurrentDocToSession(HttpServletRequest req) {

    PaymentDocument paymentDocument = null;

    if (!req.getParameter("EditCurrent").isEmpty()) {

      long id = Long.parseLong(req.getParameter("EditCurrent"));
      try {
        paymentDocument = paymentDocumentService.retrieveDocById(id);
      } catch (POMServicesException e) {
        LOG.error("Can not retrieve Payment Document: " + e.getMessage(), e);
        req.getSession(false)
            .setAttribute("errorMessage", "Can not retrieve Payment Document: " + e.getMessage());
        return;
      }
    }

    req.getSession(false).setAttribute("currentPaymentDocumentForEdit", paymentDocument);
  }