From 7cb12065a677722d8a50ff879bc26df862a7a293 Mon Sep 17 00:00:00 2001 From: Si Chen Date: Fri, 16 Mar 2007 22:03:01 +0000 Subject: [PATCH] Improve ship groups PDF to include shipped and open quantities, allow PDF to be generated for specified ship group. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@519155 13f79535-47bb-0310-9956-ffa450edef68 --- .../order/config/OrderUiLabels.properties | 1 + .../WEB-INF/actions/order/shipGroups.bsh | 54 ++++++++++++------- .../ordermgr/order/ordershippinginfo.ftl | 2 +- .../webapp/ordermgr/order/shipGroups.fo.ftl | 49 ++++++++++------- 4 files changed, 67 insertions(+), 39 deletions(-) diff --git a/applications/order/config/OrderUiLabels.properties b/applications/order/config/OrderUiLabels.properties index 518e9dbddc..9af8ff83fa 100644 --- a/applications/order/config/OrderUiLabels.properties +++ b/applications/order/config/OrderUiLabels.properties @@ -431,6 +431,7 @@ OrderQuantityCancelled=Qty Cncld OrderQuantityInShipGroup=In Group OrderQuantityInShipGroupTotal=Total In Group OrderQuantityPurchase=Qty Purch +OrderQuantityShipped=Shipped OrderQuantitySold=Qty Sold OrderQuantityUom=Unity of measure OrderQuickAddOrderItem=Order Item Quick Add diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh b/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh index 16870446c9..9b63a18ba4 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh +++ b/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh @@ -26,11 +26,17 @@ import org.ofbiz.entity.util.EntityUtil; orderId = parameters.get("orderId"); if (orderId == null) return; -shipGroups = delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("shipGroupSeqId")); +shipGroupSeqId = parameters.get("shipGroupSeqId"); + +// if a particular ship group is requested, we will limit ourselves to it +findMap = UtilMisc.toMap("orderId", orderId); +if (shipGroupSeqId != null) findMap.put("shipGroupSeqId", shipGroupSeqId); + +shipGroups = delegator.findByAnd("OrderItemShipGroup", findMap, UtilMisc.toList("shipGroupSeqId")); context.put("shipGroups", shipGroups); // method to expand the marketing packages -FastList expandProductGroup(product, quantity) { +FastList expandProductGroup(product, quantityInGroup, quantityShipped, quantityOpen) { sublines = FastList.newInstance(); associations = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "MANUF_COMPONENT")); associations = EntityUtil.filterByDate( associations ); @@ -39,10 +45,11 @@ FastList expandProductGroup(product, quantity) { line = FastMap.newInstance(); line.put("product", association.getRelatedOne("AssocProduct")); - // determine the quantity - quantityComposed = association.getDouble("quantity"); - quantityInGroup = quantity * (quantityComposed == null ? 0 : quantityComposed.doubleValue()); - line.put("quantityInGroup", new Double(quantityInGroup)); + // determine the quantities + quantityComposed = (association.getDouble("quantity") == null ? 0 : association.getDouble("quantity").doubleValue()); + line.put("quantityInGroup", quantityInGroup * quantityComposed); + line.put("quantityShipped", quantityShipped * quantityComposed); + line.put("quantityOpen", quantityOpen * quantityComposed); sublines.add(line); } @@ -51,7 +58,6 @@ FastList expandProductGroup(product, quantity) { groupData = FastMap.newInstance(); for (iter = shipGroups.iterator(); iter.hasNext(); ) { - groupQuantity = 0; shipGroup = iter.next(); data = FastMap.newInstance(); @@ -78,31 +84,41 @@ for (iter = shipGroups.iterator(); iter.hasNext(); ) { product = orderItem.getRelatedOne("Product"); line = FastMap.newInstance(); - quantity = orderItemAssoc.get("quantity").doubleValue(); + // the quantity in group + quantityInGroup = orderItemAssoc.get("quantity").doubleValue(); if (orderItemAssoc.get("cancelQuantity") != null) { - quantity -= orderItemAssoc.get("cancelQuantity").doubleValue(); + quantityInGroup -= orderItemAssoc.get("cancelQuantity").doubleValue(); } - line.put("quantityInGroup", quantity); + // the quantity shipped + quantityShipped = 0.0; + List issuances = delegator.findByAnd("ItemIssuance", UtilMisc.toMap("orderId", orderItem.get("orderId"), "orderItemSeqId", orderItem.get("orderItemSeqId"), "shipGroupSeqId", orderItemAssoc.get("shipGroupSeqId"))); + for (iiter = issuances.iterator(); iiter.hasNext(); ) { + issuance = iiter.next(); + quantityShipped += issuance.get("quantity").doubleValue(); + } + + // the quantity open (ordered - shipped) + quantityOpen = orderItem.get("quantity").doubleValue(); + if (orderItem.get("cancelQuantity") != null) { + quantityOpen -= orderItem.get("cancelQuantity").doubleValue(); + } + quantityOpen -= quantityShipped; + line.put("orderItem", orderItem); line.put("product", product); + line.put("quantityInGroup", quantityInGroup); + line.put("quantityShipped", quantityShipped); + line.put("quantityOpen", quantityOpen); if ("MARKETING_PKG_AUTO".equals(product.get("productTypeId"))) { - sublines = expandProductGroup(product, quantity); + sublines = expandProductGroup(product, quantityInGroup, quantityShipped, quantityOpen); line.put("expandedList", sublines); - for (siter = sublines.iterator(); siter.hasNext(); ) { - subline = siter.next(); - groupQuantity += subline.get("quantityInGroup").doubleValue(); - } - } else { - groupQuantity += quantity; } lines.add(line); } data.put("lines", lines); - data.put("groupQuantity", new Double(groupQuantity)); - groupData.put(shipGroup.get("shipGroupSeqId"), data); } context.put("groupData", groupData); diff --git a/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl b/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl index fbab00d263..c0a3b08dde 100644 --- a/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl +++ b/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl @@ -24,7 +24,7 @@ under the License.
 ${uiLabelMap.OrderShipmentInformation} - ${shipGroup.shipGroupSeqId}
diff --git a/applications/order/webapp/ordermgr/order/shipGroups.fo.ftl b/applications/order/webapp/ordermgr/order/shipGroups.fo.ftl index 2c52b6e19d..5532c1dada 100644 --- a/applications/order/webapp/ordermgr/order/shipGroups.fo.ftl +++ b/applications/order/webapp/ordermgr/order/shipGroups.fo.ftl @@ -102,9 +102,11 @@ under the License. <#assign lines = data.lines> - - - + + + + + @@ -117,6 +119,12 @@ under the License. ${uiLabelMap.OrderQuantityInShipGroup} + + ${uiLabelMap.OrderQuantityShipped} + + + ${uiLabelMap.ProductOpenQuantity} + @@ -136,36 +144,39 @@ under the License. ${line.orderItem.itemDescription?if_exists} - <#if !line.expandedList?exists>${line.quantityInGroup?default(0)} + ${line.quantityInGroup?default(0)} + + ${line.quantityShipped?default(0)} + + + ${line.quantityOpen?default(0)} + + <#list line.expandedList?if_exists as expandedLine> - - ${expandedLine.product.productId} + + ${expandedLine.product.productId} - - Component of ${line.orderItem.itemDescription} + + ${expandedLine.product.internalName} - + ${expandedLine.quantityInGroup?default(0)} + + ${expandedLine.quantityShipped?default(0)} + + + ${expandedLine.quantityOpen?default(0)} + - - - - ${uiLabelMap.OrderQuantityInShipGroupTotal} - - - ${data.groupQuantity} - - -