/**
   * action method for editing PurchaseOrderItemReceipt
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward edit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    PurchaseOrderItemReceipt poir = getPurchaseOrderItemReceiptFromRequest(request);
    this.checkEditPower(poir, request);
    this.putReceiverNoToRequest(poir.getPurchaseOrderItem(), request);
    this.putMaxQtyToRequest(poir.getPurchaseOrderItem(), poir, request);

    if (!isBack(request)) {
      BeanForm purchaseOrderItemReceiptForm =
          (BeanForm) getForm("/updatePurchaseOrderItemReceipt", request);
      purchaseOrderItemReceiptForm.populateToForm(poir);
    }

    this.setAdding(false, request);

    if (this.isRequestor(poir.getPurchaseOrderItem(), request)) {
      if (poir.getReceiveDate1() != null)
        request.setAttribute("x_receiveDate", poir.getReceiveDate1());
      else request.setAttribute("x_receiveDate", new Date());
    } else {
      if (poir.getReceiveDate2() != null)
        request.setAttribute("x_receiveDate", poir.getReceiveDate2());
      else request.setAttribute("x_receiveDate", new Date());
    }

    return mapping.findForward("page");
  }
  /**
   * 修改PurchaseOrderItem
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward edit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    PurchaseOrderItem poi = this.getPurchaseOrderItemFromSession(request);
    // this.checkPurchaseOrderEditPower(poi.getPurchaseOrder(),request);
    PurchaseRequest pr = poi.getPurchaseRequestItem().getPurchaseRequest();

    request.setAttribute("x_poi", poi);

    BeanForm itemForm = (BeanForm) this.getForm("/updatePurchaseOrderItem", request);

    if (!this.isBack(request)) {
      itemForm.populateToForm(poi);
    }

    // recharge
    this.setRechargeInfoToRequest(
        poi, poi.getRecharges(), pr.getDepartment().getSite(), itemForm, request);
    request.setAttribute("X_FORMNAME", "purchaseOrderItemForm");

    // combo list
    SupplierManager sm = ServiceLocator.getSupplierManager(request);
    request.setAttribute(
        "x_supplierItemList",
        sm.getSuitableSupplierItemListForPurchase(
            poi.getSupplier(),
            poi.getPurchaseOrder().getSubCategory(),
            poi.getExchangeRate().getCurrency()));
    this.putPurchaseTypeListToRequest(pr.getDepartment().getSite(), request);
    this.putProjectCodeToRequest(pr.getDepartment().getSite(), request);
    // make itemAttacmentRow.jsp edit version
    this.setEditing(true, request);

    return mapping.findForward("page");
  }
  /**
   * action method for creating PurchaseOrderItemReceipt
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward newObject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    PurchaseOrderItem poi = this.getPurchaseOrderItemFromRequest(request);
    this.checkEditPower(poi, request);
    this.putReceiverNoToRequest(poi, request);
    this.putMaxQtyToRequest(poi, null, request);

    if (!isBack(request)) {
      PurchaseOrderItemReceipt purchaseOrderItemReceipt = new PurchaseOrderItemReceipt();
      purchaseOrderItemReceipt.setPurchaseOrderItem(poi);
      BeanForm purchaseOrderItemReceiptForm =
          (BeanForm) getForm("/insertPurchaseOrderItemReceipt", request);
      purchaseOrderItemReceiptForm.populateToForm(purchaseOrderItemReceipt);
    }

    this.setAdding(true, request);
    request.setAttribute("x_receiveDate", new Date());
    return mapping.findForward("page");
  }