/** * action method for deleting PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward delete( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItemReceipt poir = getPurchaseOrderItemReceiptFromRequest(request); this.checkDeletePower(poir, request); PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); pm.deletePurchaseOrderItemReceipt(poir, this.getCurrentUser(request)); return mapping.findForward("success"); }
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)); }
/** * 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"); }
/** * action method for listing PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward list( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItem poi = this.getPurchaseOrderItemFromRequest(request); this.checkViewPower(poi, request); request.setAttribute("x_poi", poi); PurchaseOrderItemReceiptManager fm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); Map conditions = new HashMap(); conditions.put(PurchaseOrderItemReceiptQueryCondition.PURCHASEORDERITEM_ID_EQ, poi.getId()); List result = fm.getPurchaseOrderItemReceiptList( conditions, 0, -1, PurchaseOrderItemReceiptQueryOrder.RECEIVEDATE1, true); request.setAttribute("X_RESULTLIST", result); return mapping.findForward("page"); }
/** * action method for updating PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItemReceipt poir = this.getPurchaseOrderItemReceiptFromRequest(request); this.checkEditPower(poir, request); BeanForm purchaseOrderItemReceiptForm = (BeanForm) form; purchaseOrderItemReceiptForm.populateToBean(poir, request); PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); if (!pm.checkQty(poir)) throw new BackToInputActionException("purchaseOrderItemReceipt.qtyExceeds"); PurchaseOrderItemReceipt oldPoir = this.getPurchaseOrderItemReceiptFromRequest(request); request.setAttribute( "X_OBJECT", pm.updatePurchaseOrderItemReceipt(oldPoir, poir, this.getCurrentUser(request))); request.setAttribute("X_ROWPAGE", "purchaseOrderItemReceipt/row.jsp"); return mapping.findForward("success"); }