コード例 #1
0
 private void putMaxQtyToRequest(
     PurchaseOrderItem poi, PurchaseOrderItemReceipt poir, HttpServletRequest request)
     throws Exception {
   PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request);
   int receiveQty = pm.getRecevieSum(poi, this.getCurrentUser(request));
   int maxQty = poi.getQuantity() - receiveQty;
   if (poir != null) {
     User currentUser = this.getCurrentUser(request);
     if (poir.getReceiver1().equals(currentUser) && poir.getReceiveQty1() != null) {
       maxQty += poir.getReceiveQty1().intValue();
     } else if (poir.getReceiver2().equals(currentUser) && poir.getReceiveQty2() != null) {
       maxQty += poir.getReceiveQty2().intValue();
     }
   }
   if (maxQty <= 0)
     throw new ActionException("purchaseOrderItemReceipt.edit.purchaseOrderItem.alreadyReceived");
   request.setAttribute("x_maxQty", new Integer(maxQty));
 }
コード例 #2
0
  /**
   * action method for inserting PurchaseOrderItemReceipt
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward insert(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    PurchaseOrderItem poi = this.getPurchaseOrderItemFromRequest(request);
    this.checkEditPower(poi, request);

    BeanForm purchaseOrderItemReceiptForm = (BeanForm) form;
    PurchaseOrderItemReceipt poir = new PurchaseOrderItemReceipt();
    purchaseOrderItemReceiptForm.populate(poir, BeanForm.TO_BEAN);
    poir.setPurchaseOrderItem(poi);

    PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request);
    if (!pm.checkQty(poir))
      throw new BackToInputActionException("purchaseOrderItemReceipt.qtyExceeds");

    poir = pm.insertPurchaseOrderItemReceipt(poir, this.getCurrentUser(request));
    request.setAttribute("X_OBJECT", poir);
    request.setAttribute("X_ROWPAGE", "purchaseOrderItemReceipt/row.jsp");

    EmailManager em = ServiceLocator.getEmailManager(request);

    Map context = new HashMap();
    User emailToUser = null;
    if (this.getCurrentUser(request).equals(poir.getReceiver1())) {
      emailToUser = poir.getReceiver2();
      context.put("x_receiveQty", poir.getReceiveQty1());
      context.put("x_receiveDate", poir.getReceiveDate1());
    } else {
      emailToUser = poir.getReceiver1();
      context.put("x_receiveQty", poir.getReceiveQty2());
      context.put("x_receiveDate", poir.getReceiveDate2());
    }
    context.put("x_emailToUser", emailToUser);
    context.put("x_receiver", this.getCurrentUser(request));
    context.put("x_poir", poir);
    context.put("role", EmailManager.EMAIL_ROLE_RECEIVER);
    em.insertEmail(poir.getLogSite(), emailToUser.getEmail(), "POItemReceive.vm", context);

    return mapping.findForward("success");
  }