Author: jleroux
Date: Thu Feb 19 17:19:48 2009 New Revision: 745931 URL: http://svn.apache.org/viewvc?rev=745931&view=rev Log: A slightly modified patch from Karim Rahimpur "Packing issues: weights and remaining items" https://issues.apache.org/jira/browse/OFBIZ-2163 OFBIZ-2163 Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=745931&r1=745930&r2=745931&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Thu Feb 19 17:19:48 2009 @@ -469,6 +469,7 @@ <attribute name="selInfo" type="Map" string-map-prefix="sel_" mode="IN" optional="true"/> <attribute name="iteInfo" type="Map" string-map-prefix="ite_" mode="IN" optional="true"/> <attribute name="wgtInfo" type="Map" string-map-prefix="wgt_" mode="IN" optional="true"/> + <attribute name="numPackagesInfo" type="Map" string-map-prefix="numPackages_" mode="IN" optional="true"/> </service> <service name="setNextPackageSeq" engine="java" Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java?rev=745931&r1=745930&r2=745931&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Thu Feb 19 17:19:48 2009 @@ -70,6 +70,23 @@ return ServiceUtil.returnSuccess(); } + /** + * <p>Create or update package lines.</p> + * <p>Context parameters: + * <ul> + * <li>selInfo - selected rows</li> + * <li>iteInfo - orderItemIds</li> + * <li>prdInfo - productIds</li> + * <li>pkgInfo - package numbers</li> + * <li>wgtInfo - weights to pack</li> + * <li>numPackagesInfo - number of packages to pack per line (>= 1, default: 1)<br/> + * Packs the same items n times in consecutive packages, starting from the package number retrieved from pkgInfo.</li> + * <ul> + * </p> + * @param dctx + * @param context + * @return + */ public static Map<String, Object> packBulk(DispatchContext dctx, Map<String, ? extends Object> context) { PackingSession session = (PackingSession) context.get("packingSession"); String orderId = (String) context.get("orderId"); @@ -93,6 +110,7 @@ Map<String, String> qtyInfo = UtilGenerics.checkMap(context.get("qtyInfo")); Map<String, String> pkgInfo = UtilGenerics.checkMap(context.get("pkgInfo")); Map<String, String> wgtInfo = UtilGenerics.checkMap(context.get("wgtInfo")); + Map<String, String> numPackagesInfo = UtilGenerics.checkMap(context.get("numPackagesInfo")); if (selInfo != null) { for (String rowKey: selInfo.keySet()) { @@ -158,7 +176,20 @@ } try { - session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq, weightSeq, updateQuantity.booleanValue()); + String numPackagesStr = numPackagesInfo.get(rowKey); + int numPackages = 1; + if (numPackagesStr != null) { + try { + numPackages = Integer.parseInt(numPackagesStr); + if (numPackages < 1) { + numPackages = 1; + } + } catch (NumberFormatException nex) { + } + } + for (int numPackage=0; numPackage<numPackages; numPackage++) { + session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq+numPackage, weightSeq, updateQuantity.booleanValue()); + } } catch (GeneralException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); 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?rev=745931&r1=745930&r2=745931&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Thu Feb 19 17:19:48 2009 @@ -325,6 +325,40 @@ return itemInfos; } + /** + * <p>Delivers all the packing lines grouped by package.</p> + * <p>Output map: + * <ul> + * <li>packageMap - a Map of type Map<Integer, List<PackingSessionLine>> + * that maps package sequence ids to the lines that belong in + * that package</li> + * <li>sortedKeys - a List of type List<Integer> with the sorted package + * sequence numbers to index the packageMap</li> + * @return result Map with packageMap and sortedKeys + */ + public Map<Object, Object> getPackingSessionLinesByPackage() { + FastMap<Integer, List<PackingSessionLine>> packageMap = FastMap.newInstance(); + for (PackingSessionLine line : packLines) { + int pSeq = line.getPackageSeq(); + List<PackingSessionLine> packageLineList = packageMap.get(pSeq); + if (packageLineList == null) { + packageLineList = FastList.newInstance(); + packageMap.put(pSeq, packageLineList); + } + packageLineList.add(line); + } + Object[] keys = packageMap.keySet().toArray(); + java.util.Arrays.sort(keys); + List<Object> sortedKeys = FastList.newInstance(); + for (Object key : keys) { + sortedKeys.add(key); + } + Map<Object, Object> result = FastMap.newInstance(); + result.put("packageMap", packageMap); + result.put("sortedKeys", sortedKeys); + return result; + } + public void clearItemInfos() { itemInfos.clear(); } @@ -539,15 +573,29 @@ this.clearLine(line); } } - return --packageSeq; + //return --packageSeq; + return packageSeq; } public void clearLine(PackingSessionLine line) { this.packLines.remove(line); + BigDecimal packageWeight = this.packageWeights.get(line.packageSeq); + if (packageWeight != null) { + packageWeight = packageWeight.subtract(line.weight); + if (packageWeight.compareTo(BigDecimal.ZERO) < 0) { + packageWeight = BigDecimal.ZERO; + } + this.packageWeights.put(line.packageSeq, packageWeight); + } + if (line.packageSeq == packageSeq) { + packageSeq--; + } } public void clearAllLines() { this.packLines.clear(); + this.packageWeights.clear(); + this.packageSeq = 1; } public void clear() { 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?rev=745931&r1=745930&r2=745931&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl (original) +++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackOrder.ftl Thu Feb 19 17:19:48 2009 @@ -19,7 +19,7 @@ <#if security.hasEntityPermission("FACILITY", "_VIEW", session)> <#assign showInput = requestParameters.showInput?default("Y")> - <#assign hideGrid = requestParameters.hideGrid?default("N")> + <#assign hideGrid = requestParameters.hideGrid?default("N")> <#if (requestParameters.forceComplete?has_content && !shipmentId?has_content)> <#assign forceComplete = "true"> @@ -35,19 +35,19 @@ <div class="screenlet-body"> <#if shipmentId?has_content> <div> - ${uiLabelMap.CommonView} <a href="<@ofbizUrl>/PackingSlip.pdf?shipmentId=${shipmentId}</@ofbizUrl>" target="_blank" class="buttontext">${uiLabelMap.ProductPackingSlip}</a> ${uiLabelMap.CommonOr} + ${uiLabelMap.CommonView} <a href="<@ofbizUrl>/PackingSlip.pdf?shipmentId=${shipmentId}</@ofbizUrl>" target="_blank" class="buttontext">${uiLabelMap.ProductPackingSlip}</a> ${uiLabelMap.CommonOr} ${uiLabelMap.CommonView} <a href="<@ofbizUrl>/ShipmentBarCode.pdf?shipmentId=${shipmentId}</@ofbizUrl>" target="_blank" class="buttontext">${uiLabelMap.ProductBarcode}</a> ${uiLabelMap.CommonFor} ${uiLabelMap.ProductShipmentId} <a href="<@ofbizUrl>/ViewShipment?shipmentId=${shipmentId}</@ofbizUrl>" class="buttontext">${shipmentId}</a> </div> <#if invoiceIds?exists && invoiceIds?has_content> <div> - <p>${uiLabelMap.AccountingInvoices}:</p> + <p>${uiLabelMap.AccountingInvoices}:</p> <ul> - <#list invoiceIds as invoiceId> - <li> - #<a href="/accounting/control/invoiceOverview?invoiceId=${invoiceId}&externalLoginKey=${externalLoginKey}" target="_blank" class="buttontext">${invoiceId}</a> - (<a href="/accounting/control/invoice.pdf?invoiceId=${invoiceId}&externalLoginKey=${externalLoginKey}" target="_blank" class="buttontext">PDF</a>) - </li> - </#list> + <#list invoiceIds as invoiceId> + <li> + #<a href="/accounting/control/invoiceOverview?invoiceId=${invoiceId}&externalLoginKey=${externalLoginKey}" target="_blank" class="buttontext">${invoiceId}</a> + (<a href="/accounting/control/invoice.pdf?invoiceId=${invoiceId}&externalLoginKey=${externalLoginKey}" target="_blank" class="buttontext">PDF</a>) + </li> + </#list> </ul> </div> </#if> @@ -59,7 +59,7 @@ <input type="hidden" name="facilityId" value="${facilityId?if_exists}"> <table cellspacing="0" class="basic-table"> <tr> - <td width="25%" align="right"><span class="label">${uiLabelMap.ProductOrderId} #</span></td> + <td width="25%" align="right"><span class="label">${uiLabelMap.ProductOrderId}</span></td> <td width="1"> </td> <td width="25%"> <input type="text" name="orderId" size="20" maxlength="20" value="${orderId?if_exists}"/> @@ -85,10 +85,10 @@ <input type="hidden" name="facilityId" value="${facilityId?if_exists}"> <table cellspacing="0" class="basic-table"> <tr> - <td width="25%" align='right'><span class="label">${uiLabelMap.FormFieldTitle_picklistBinId} #</span></td> + <td width="25%" align='right'><span class="label">${uiLabelMap.FormFieldTitle_picklistBinId}</span></td> <td width="1"> </td> <td width="25%"> - <input type="text" name="picklistBinId" size="29" maxlength="60" value="${picklistBinId?if_exists}"/> + <input type="text" name="picklistBinId" size="29" maxlength="60" value="${picklistBinId?if_exists}"/> </td> <td><span class="label">${uiLabelMap.ProductHideGrid}</span> <input type="checkbox" name="hideGrid" value="Y" <#if (hideGrid == "Y")>checked=""</#if>></td> <td> </td> @@ -114,7 +114,7 @@ </form> </div> </div> - + <#if showInput != "N" && ((orderHeader?exists && orderHeader?has_content))> <div class="screenlet"> <div class="screenlet-title-bar"> @@ -175,9 +175,9 @@ </td> <td> </td> <td valign="top"> - <span class="label">${uiLabelMap.ProductShipping} ${uiLabelMap.ProductInstruction}</span> + <span class="label">${uiLabelMap.OrderInstructions}</span> <br/> - ${orderItemShipGroup.shippingInstructions?default("(none)")} + ${orderItemShipGroup.shippingInstructions?default("(${uiLabelMap.CommonNone})")} </td> </tr> </table> @@ -196,7 +196,7 @@ <tr> <td> <div> - <span class="label">${uiLabelMap.ProductProduct} #</span> + <span class="label">${uiLabelMap.ProductProductNumber}</span> <input type="text" name="productId" size="20" maxlength="20" value=""/> @ <input type="text" name="quantity" size="6" maxlength="6" value="1"/> @@ -204,9 +204,9 @@ </div> </td> <td> - <span class="label">${uiLabelMap.CommonCurrent} ${uiLabelMap.ProductPackage} ${uiLabelMap.CommonSequence}</span> + <span class="label">${uiLabelMap.ProductCurrentPackageSequence}</span> ${packingSession.getCurrentPackageSeq()} - <input type="button" value="${uiLabelMap.CommonNext} ${uiLabelMap.ProductPackage}" onclick="javascript:document.incPkgSeq.submit();"> + <input type="button" value="${uiLabelMap.ProductNextPackage}" onclick="javascript:document.incPkgSeq.submit();"> </td> </tr> </table> @@ -229,19 +229,20 @@ <td> </td> <td>${uiLabelMap.ProductItem} #</td> <td>${uiLabelMap.ProductProductId}</td> - <td>${uiLabelMap.Description}</td> + <td>${uiLabelMap.ProductInternalName}</td> <td align="right">${uiLabelMap.ProductOrderedQuantity}</td> <td align="right">${uiLabelMap.ProductQuantityShipped}</td> <td align="right">${uiLabelMap.ProductPackedQty}</td> <td> </td> <td align="center">${uiLabelMap.ProductPackQty}</td> - <#--td align="center">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval})</td--> + <td align="center">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval})</td> <td align="center">${uiLabelMap.ProductPackage}</td> + <td align="right"> <b>*</b> ${uiLabelMap.ProductPackages}</td> </tr> - - <#if (itemInfos?has_content)> + + <#if (itemInfos?has_content)> <#assign rowKey = 1> - <#list itemInfos as itemInfo> + <#list itemInfos as itemInfo> <#-- <#list itemInfos as orderItem> --> <#assign orderItem = itemInfo.orderItem/> <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)?if_exists> @@ -255,8 +256,7 @@ <#assign orderItemQuantity = orderItem.quantity> </#if> --> - - <#assign inputQty = (orderItemQuantity - shippedQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, itemInfo.productId))> + <#assign inputQty = orderItemQuantity - packingSession.getPackedQuantity(orderId, orderItem.orderItemSeqId, shipGroupSeqId, itemInfo.productId)> <tr> <td><input type="checkbox" name="sel_${rowKey}" value="Y" <#if (inputQty >0)>checked=""</#if>/></td> <td>${orderItem.orderItemSeqId}</td> @@ -279,18 +279,29 @@ <td align="center"> <input type="text" size="7" name="qty_${rowKey}" value="${inputQty}"> </td> - <#--td align="center"> + <td align="center"> <input type="text" size="7" name="wgt_${rowKey}" value=""> - </td--> + </td> <td align="center"> <select name="pkg_${rowKey}"> - <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> + <#if packingSession.getPackageSeqIds()?exists> + <#list packingSession.getPackageSeqIds() as packageSeqId> + <option value="${packageSeqId}">${uiLabelMap.ProductPackage} ${packageSeqId}</option> + </#list> + <#assign nextPackageSeqId = packingSession.getPackageSeqIds().size() + 1> + <option value="${nextPackageSeqId}">${uiLabelMap.ProductNextPackage}</option> + <#else> + <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> + </#if> </select> </td> + <td align="right"> + <input type="text" size="7" name="numPackages_${rowKey}" value="1"> + </td> <input type="hidden" name="prd_${rowKey}" value="${itemInfo.productId?if_exists}"/> <input type="hidden" name="ite_${rowKey}" value="${orderItem.orderItemSeqId}"/> </tr> @@ -299,10 +310,10 @@ </#if> <tr><td colspan="10"> </td></tr> <tr> - <td colspan="10" align="right"> + <td colspan="12" align="right"> <input type="submit" value="${uiLabelMap.ProductPackItem}"> - <input type="button" value="${uiLabelMap.CommonClear}" onclick="javascript:document.clearPackForm.submit();"/> + <input type="button" value="${uiLabelMap.CommonClear} (${uiLabelMap.CommonAll})" onclick="javascript:document.clearPackForm.submit();"/> </td> </tr> </table> @@ -328,7 +339,7 @@ <span class="label">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval}):</span> <br/> <#list packageSeqIds as packageSeqId> - ${uiLabelMap.ProductPackage} ${packageSeqId} + ${uiLabelMap.ProductPackage} ${packageSeqId} <input type="text" size="7" name="packageWeight_${packageSeqId}" value="${packingSession.getPackageWeight(packageSeqId?int)?if_exists}"> <br/> </#list> @@ -369,11 +380,29 @@ <br/> </form> </#if> + </div> + </div> - <!-- packed items display --> - <#assign packedLines = packingSession.getLines()?if_exists> + <!-- display items in packages, per packed package and in order --> + <#assign linesByPackageResultMap = packingSession.getPackingSessionLinesByPackage()?if_exists> + <#assign packageMap = linesByPackageResultMap.get("packageMap")?if_exists> + <#assign sortedKeys = linesByPackageResultMap.get("sortedKeys")?if_exists> + <#if ((packageMap?has_content) && (sortedKeys?has_content))> + <div class="screenlet"> + <div class="screenlet-title-bar"> + <ul> + <li class="h3">${uiLabelMap.ProductPackages} : ${sortedKeys.size()?if_exists}</li> + </ul> + <br class="clear"/> + </div> + <div class="screenlet-body"> + <#list sortedKeys as key> + <#assign packedLines = packageMap.get(key)> <#if packedLines?has_content> <br/> + <#assign packedLine = packedLines.get(0)?if_exists> + <span class="label" style="font-size:1.2em">${uiLabelMap.ProductPackage} ${packedLine.getPackageSeq()?if_exists}</span> + <br/> <table class="basic-table" cellspacing='0'> <tr class="header-row"> <td>${uiLabelMap.ProductItem} #</td> @@ -381,7 +410,7 @@ <td>${uiLabelMap.Description}</td> <td>${uiLabelMap.ProductInventoryItem} #</td> <td align="right">${uiLabelMap.ProductPackedQty}</td> - <#--td align="right">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval})</td--> + <td align="right">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval}) (${uiLabelMap.ProductPackage})</td> <td align="right">${uiLabelMap.ProductPackage} #</td> <td> </td> </tr> @@ -395,26 +424,72 @@ </td> <td>${line.getInventoryItemId()}</td> <td align="right">${line.getQuantity()}</td> - <#--td align="right">${line.getWeight()}</td--> + <td align="right">${line.getWeight()} (${packingSession.getPackageWeight(line.getPackageSeq()?int)?if_exists})</td> <td align="right">${line.getPackageSeq()}</td> <td align="right"><a href="<@ofbizUrl>ClearPackLine?facilityId=${facilityId}&orderId=${line.getOrderId()}&orderItemSeqId=${line.getOrderItemSeqId()}&shipGroupSeqId=${line.getShipGroupSeqId()}&productId=${line.getProductId()?default("")}&inventoryItemId=${line.getInventoryItemId()}&packageSeqId=${line.getPackageSeq()}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClear}</a></td> </tr> </#list> </table> </#if> - </#if> + </#list> + </div> + </div> + </#if> - <#if orderId?has_content> - <script language="javascript"> - document.singlePackForm.productId.focus(); - </script> - <#else> - <script language="javascript"> - document.selectOrderForm.orderId.focus(); - </script> - </#if> - </div> - </div> + <!-- packed items display --> + <#assign packedLines = packingSession.getLines()?if_exists> + <#if packedLines?has_content> + <div class="screenlet"> + <div class="screenlet-title-bar"> + <ul> + <li class="h3">${uiLabelMap.ProductItems} (${uiLabelMap.ProductPackages}): ${packedLines.size()?if_exists}</li> + </ul> + <br class="clear"/> + </div> + <div class="screenlet-body"> + <table class="basic-table" cellspacing='0'> + <tr class="header-row"> + <td>${uiLabelMap.ProductItem} #</td> + <td>${uiLabelMap.ProductProductId}</td> + <td>${uiLabelMap.Description}</td> + <td>${uiLabelMap.ProductInventoryItem} #</td> + <td align="right">${uiLabelMap.ProductPackedQty}</td> + <td align="right">${uiLabelMap.ProductPackedWeight} (${("uiLabelMap.ProductShipmentUomAbbreviation_" + defaultWeightUomId)?eval}) (${uiLabelMap.ProductPackage})</td> + <td align="right">${uiLabelMap.ProductPackage} #</td> + <td> </td> + </tr> + <#list packedLines as line> + <#assign product = Static["org.ofbiz.product.product.ProductWorker"].findProduct(delegator, line.getProductId())/> + <tr> + <td>${line.getOrderItemSeqId()}</td> + <td>${line.getProductId()?default("N/A")}</td> + <td> + <a href="/catalog/control/EditProduct?productId=${line.getProductId()?if_exists}${externalKeyParam}" class="buttontext" target="_blank">${product.internalName?if_exists?default("[N/A]")}</a> + </td> + <td>${line.getInventoryItemId()}</td> + <td align="right">${line.getQuantity()}</td> + <td align="right">${line.getWeight()} (${packingSession.getPackageWeight(line.getPackageSeq()?int)?if_exists})</td> + <td align="right">${line.getPackageSeq()}</td> + <td align="right"><a href="<@ofbizUrl>ClearPackLine?facilityId=${facilityId}&orderId=${line.getOrderId()}&orderItemSeqId=${line.getOrderItemSeqId()}&shipGroupSeqId=${line.getShipGroupSeqId()}&productId=${line.getProductId()?default("")}&inventoryItemId=${line.getInventoryItemId()}&packageSeqId=${line.getPackageSeq()}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClear}</a></td> + </tr> + </#list> + </table> + </div> + </div> + </#if> + </#if> + + <#if orderId?has_content> + <script language="javascript"> + document.singlePackForm.productId.focus(); + </script> + <#else> + <script language="javascript"> + document.selectOrderForm.orderId.focus(); + </script> + </#if> + </div> + </div> <#else> - <h3>${uiLabelMap.ProductFacilityViewPermissionError}</h3> + <h3>${uiLabelMap.ProductFacilityViewPermissionError}</h3> </#if> \ No newline at end of file |
Free forum by Nabble | Edit this page |