Author: jaz
Date: Mon May 14 09:31:51 2007 New Revision: 537902 URL: http://svn.apache.org/viewvc?view=rev&rev=537902 Log: packing code now (also) uses picklist bin data to begin packing (packing off a picklist); applied patch from Jacopo which fixes a bug in packing items with multiple reservations Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?view=diff&rev=537902&r1=537901&r2=537902 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Mon May 14 09:31:51 2007 @@ -141,18 +141,23 @@ while (i.hasNext() && qtyRemain > 0) { GenericValue res = (GenericValue) i.next(); double resQty = res.getDouble("quantity").doubleValue(); + PackingSessionLine line = this.findLine(orderId, orderItemSeqId, shipGroupSeqId, res.getString("inventoryItemId"), packageSeqId); + if (UtilValidate.isNotEmpty(line) && !update) { + resQty -= line.getQuantity(); + } + double thisQty = resQty > qtyRemain ? qtyRemain : resQty; int thisCheck = this.checkLineForAdd(res, orderId, orderItemSeqId, shipGroupSeqId, thisQty, packageSeqId, update); switch (thisCheck) { case 2: Debug.log("Packing check returned '2' - new pack line will be created!", module); - toCreateMap.put(res, new Double(resQty)); - qtyRemain -= resQty; + toCreateMap.put(res, new Double(thisQty)); + qtyRemain -= thisQty; break; case 1: Debug.log("Packing check returned '1' - existing pack line has been updated!", module); - qtyRemain -= resQty; + qtyRemain -= thisQty; break; case 0: Debug.log("Packing check returned '0' - doing nothing.", module); @@ -277,18 +282,16 @@ Debug.log("Packed quantity [" + packedQty + "] + [" + quantity + "]", module); if (line == null) { - double checkQty = packedQty + quantity; - Debug.log("No current line found testing [" + invItemId + "] R: " + resQty + " / Q: " + checkQty, module); - if (resQty < checkQty) { + Debug.log("No current line found testing [" + invItemId + "] R: " + resQty + " / Q: " + quantity, module); + if (resQty < quantity) { return 0; } else { return 2; } } else { - double checkQty = update ? ((packedQty - line.getQuantity()) + quantity) : packedQty + quantity; - double newQty = update ? quantity : (line.getQuantity() + quantity); + double newQty = update ? quantity : (line.getQuantity() + quantity); Debug.log("Existing line found testing [" + invItemId + "] R: " + resQty + " / Q: " + newQty, module); - if (resQty < checkQty) { + if (resQty < newQty) { return 0; } else { line.setQuantity(newQty); Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh?view=diff&rev=537902&r1=537901&r2=537902 ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh Mon May 14 09:31:51 2007 @@ -29,6 +29,7 @@ context.put("facility", facility); } +// order based packing orderId = parameters.get("orderId"); shipGroupSeqId = parameters.get("shipGroupSeqId"); shipmentId = parameters.get("shipmentId"); @@ -50,35 +51,69 @@ } } } + +// validate order information if (UtilValidate.isNotEmpty(orderId) && UtilValidate.isEmpty(shipGroupSeqId) && orderId.indexOf("/") > -1) { // split the orderID/shipGroupSeqID idSplit = orderId.split("\\/"); orderId = idSplit[0]; shipGroupSeqId = idSplit[1]; +} else if (orderId != null && UtilValidate.isEmpty(shipGroupSeqId)) { + shipGroupSeqId = "00001"; } +// setup the packing session packSession = session.getAttribute("packingSession"); +clear = parameters.get("clear"); if (packSession == null) { packSession = new org.ofbiz.shipment.packing.PackingSession(dispatcher, userLogin); session.setAttribute("packingSession", packSession); Debug.log("Created NEW packing session!!"); } else { if (packSession.getStatus() == 0) { + OrderReadHelper orh = new OrderReadHelper(delegator, orderId); + shipGrp = orh.getOrderItemShipGroup(shipGroupSeqId); + context.put("shippedShipGroupSeqId", shipGroupSeqId); + context.put("shippedOrderId", orderId); + context.put("shippedCarrier", shipGrp.get("carrierPartyId")); + packSession.clear(); shipGroupSeqId = null; orderId = null; + } else if (clear != null) { + packSession.clear(); + } +} + +// picklist based packing information +picklistBinId = parameters.get("picklistBinId"); +// see if the bin ID is already set +if (UtilValidate.isEmpty(picklistBinId)) { + picklistBinId = packSession.getPicklistBinId(); +} +if (UtilValidate.isNotEmpty(picklistBinId)) { + bin = delegator.findByPrimaryKey("PicklistBin", UtilMisc.toMap("picklistBinId", picklistBinId)); + if (bin != null) { + orderId = bin.getString("primaryOrderId"); + shipGroupSeqId = bin.getString("primaryShipGroupSeqId"); + context.put("picklistItemInfos", bin.getRelatedByAnd("PicklistItem", UtilMisc.toMap("itemStatusId", "PICKITEM_PENDING"))); } +} else { + picklistBinId = null; } // make sure we always re-set the infos packSession.setPrimaryShipGroupSeqId(shipGroupSeqId); packSession.setPrimaryOrderId(orderId); +packSession.setPicklistBinId(picklistBinId); packSession.setFacilityId(facilityId); context.put("packingSession", packSession); context.put("orderId", orderId); context.put("shipGroupSeqId", shipGroupSeqId); +context.put("picklistBinId", picklistBinId); +// grab the order information if (UtilValidate.isNotEmpty(orderId)) { orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); if (orderHeader != null) { Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl?view=diff&rev=537902&r1=537901&r2=537902 ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl (original) +++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Mon May 14 09:31:51 2007 @@ -73,6 +73,30 @@ </tr> </table> </form> + <br/> + + <!-- select picklist bin form --> + <form name="selectPicklistBinForm" method="post" action="<@ofbizUrl>PackOrder</@ofbizUrl>" style="margin: 0;"> + <input type="hidden" name="facilityId" value="${facilityId?if_exists}"> + <table border='0' cellpadding='2' cellspacing='0'> + <tr> + <td width="25%" align='right'><div class="tabletext">Picklist Bin #</div></td> + <td width="1"> </td> + <td width="25%"> + <input type="text" class="inputBox" name="picklistBinId" size="29" maxlength="60" value="${picklistBinId?if_exists}"/> + </td> + <td><div class="tabletext">${uiLabelMap.ProductHideGrid}: <input type="checkbox" name="hideGrid" value="Y" <#if (hideGrid == "Y")>checked=""</#if>></div></td> + <td><div class='tabletext'> </div></td> + </tr> + <tr> + <td colspan="2"> </td> + <td colspan="1"> + <input type="image" src="<@ofbizContentUrl>/images/spacer.gif</@ofbizContentUrl>" onClick="javascript:document.selectPicklistBinForm.submit();"> + <a href="javascript:document.selectPicklistBinForm.submit();" class="buttontext">${uiLabelMap.ProductPackOrder}</a> + </td> + </tr> + </table> + </form> <form name="clearPackForm" method="post" action="<@ofbizUrl>ClearPackAll</@ofbizUrl>" style='margin: 0;'> <input type="hidden" name="orderId" value="${orderId?if_exists}"/> @@ -85,7 +109,7 @@ <input type="hidden" name="facilityId" value="${facilityId?if_exists}"/> </form> - <#if showInput != "N" && orderHeader?exists && orderHeader?has_content> + <#if showInput != "N" && ((orderHeader?exists && orderHeader?has_content) || picklistItemInfos?has_content)> <hr class="sepbar"/> <div class='head2'>${uiLabelMap.ProductOrderId} #<a href="/ordermgr/control/orderview?orderId=${orderId}" class="buttontext">${orderId}</a> / ${uiLabelMap.ProductOrderShipGroupId} #${shipGroupSeqId}</div> <div> </div> @@ -213,41 +237,80 @@ </td> </tr> - <#list itemInfos as orderItem> - <#assign shippedQuantity = orderReadHelper.getItemShippedQuantityBd(orderItem)?if_exists> - <#if orderItem.cancelQuantity?exists> - <#assign orderItemQuantity = orderItem.quantity - orderItem.cancelQuantity> - <#else> - <#assign orderItemQuantity = orderItem.quantity> - </#if> - <#assign inputQty = (orderItemQuantity - shippedQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId))> - <tr> - <td><input type="checkbox" name="sel_${orderItem.orderItemSeqId}" value="Y" <#if (inputQty >0)>checked=""</#if>/></td> - <td><div class="tabletext">${orderItem.orderItemSeqId}</td> - <td><div class="tabletext">${orderItem.productId?default("N/A")}</td> - <td><div class="tabletext">${orderItem.itemDescription?if_exists}</td> - <td align="right"><div class="tabletext">${orderItemQuantity}</td> - <td align="right"><div class="tabletext">${shippedQuantity?default(0)}</td> - <td align="right"><div class="tabletext">${packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId)}</td> - <td> </td> - <td align="center"> - <input type="text" class="inputBox" size="7" name="qty_${orderItem.orderItemSeqId}" value="${inputQty}"> - </td> - <#--td align="center"> - <input type="text" class="inputBox" size="7" name="wgt_${orderItem.orderItemSeqId}" value=""> - </td--> - <td align="center"> - <select name="pkg_${orderItem.orderItemSeqId}"> - <option value="1">${uiLabelMap.ProductPackage} 1</option> - <option value="2">${uiLabelMap.ProductPackage} 2</option> - <option value="3">${uiLabelMap.ProductPackage} 3</option> - <option value="4">${uiLabelMap.ProductPackage} 4</option> - <option value="5">${uiLabelMap.ProductPackage} 5</option> - </select> - </td> - <input type="hidden" name="prd_${orderItem.orderItemSeqId}" value="${orderItem.productId?if_exists}"> - </tr> - </#list> + <#if (picklistItemInfos?has_content)> + <#list picklistItemInfos as pickItem> + <#assign orderItem = pickItem.getRelatedOne("OrderItem")/> + <#assign shippedQuantity = orderReadHelper.getItemShippedQuantityBd(orderItem)?if_exists> + <#if orderItem.cancelQuantity?exists> + <#assign orderItemQuantity = orderItem.quantity - orderItem.cancelQuantity> + <#else> + <#assign orderItemQuantity = orderItem.quantity> + </#if> + <#assign inputQty = (orderItemQuantity - shippedQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId))> + <tr> + <td><input type="checkbox" name="sel_${orderItem.orderItemSeqId}" value="Y" <#if (inputQty >0)>checked=""</#if>/></td> + <td><div class="tabletext">${orderItem.orderItemSeqId}</td> + <td><div class="tabletext">${orderItem.productId?default("N/A")}</td> + <td><div class="tabletext">${orderItem.itemDescription?if_exists}</td> + <td align="right"><div class="tabletext">${orderItemQuantity}</td> + <td align="right"><div class="tabletext">${shippedQuantity?default(0)}</td> + <td align="right"><div class="tabletext">${packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId)}</td> + <td> </td> + <td align="center"> + <input type="text" class="inputBox" size="7" name="qty_${orderItem.orderItemSeqId}" value="${inputQty}"> + </td> + <#--td align="center"> + <input type="text" class="inputBox" size="7" name="wgt_${orderItem.orderItemSeqId}" value=""> + </td--> + <td align="center"> + <select name="pkg_${orderItem.orderItemSeqId}"> + <option value="1">${uiLabelMap.ProductPackage} 1</option> + <option value="2">${uiLabelMap.ProductPackage} 2</option> + <option value="3">${uiLabelMap.ProductPackage} 3</option> + <option value="4">${uiLabelMap.ProductPackage} 4</option> + <option value="5">${uiLabelMap.ProductPackage} 5</option> + </select> + </td> + <input type="hidden" name="prd_${orderItem.orderItemSeqId}" value="${orderItem.productId?if_exists}"> + </tr> + </#list> + <#else> + <#list itemInfos as orderItem> + <#assign shippedQuantity = orderReadHelper.getItemShippedQuantityBd(orderItem)?if_exists> + <#if orderItem.cancelQuantity?exists> + <#assign orderItemQuantity = orderItem.quantity - orderItem.cancelQuantity> + <#else> + <#assign orderItemQuantity = orderItem.quantity> + </#if> + <#assign inputQty = (orderItemQuantity - shippedQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId))> + <tr> + <td><input type="checkbox" name="sel_${orderItem.orderItemSeqId}" value="Y" <#if (inputQty >0)>checked=""</#if>/></td> + <td><div class="tabletext">${orderItem.orderItemSeqId}</td> + <td><div class="tabletext">${orderItem.productId?default("N/A")}</td> + <td><div class="tabletext">${orderItem.itemDescription?if_exists}</td> + <td align="right"><div class="tabletext">${orderItemQuantity}</td> + <td align="right"><div class="tabletext">${shippedQuantity?default(0)}</td> + <td align="right"><div class="tabletext">${packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId)}</td> + <td> </td> + <td align="center"> + <input type="text" class="inputBox" size="7" name="qty_${orderItem.orderItemSeqId}" value="${inputQty}"> + </td> + <#--td align="center"> + <input type="text" class="inputBox" size="7" name="wgt_${orderItem.orderItemSeqId}" value=""> + </td--> + <td align="center"> + <select name="pkg_${orderItem.orderItemSeqId}"> + <option value="1">${uiLabelMap.ProductPackage} 1</option> + <option value="2">${uiLabelMap.ProductPackage} 2</option> + <option value="3">${uiLabelMap.ProductPackage} 3</option> + <option value="4">${uiLabelMap.ProductPackage} 4</option> + <option value="5">${uiLabelMap.ProductPackage} 5</option> + </select> + </td> + <input type="hidden" name="prd_${orderItem.orderItemSeqId}" value="${orderItem.productId?if_exists}"> + </tr> + </#list> + </#if> <tr><td colspan="10"> </td></tr> <tr> <td colspan="10" align="right"> |
Free forum by Nabble | Edit this page |