svn commit: r554550 - in /ofbiz/branches/release4.0/applications/product/webapp/facility: WEB-INF/actions/shipment/PackingSlip.bsh shipment/PackingSlip.fo.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r554550 - in /ofbiz/branches/release4.0/applications/product/webapp/facility: WEB-INF/actions/shipment/PackingSlip.bsh shipment/PackingSlip.fo.ftl

lektran
Author: lektran
Date: Mon Jul  9 00:53:39 2007
New Revision: 554550

URL: http://svn.apache.org/viewvc?view=rev&rev=554550
Log:
Applied fix from trunk for revision: 552809

Modified:
    ofbiz/branches/release4.0/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh
    ofbiz/branches/release4.0/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl

Modified: ofbiz/branches/release4.0/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh?view=diff&rev=554550&r1=554549&r2=554550
==============================================================================
--- ofbiz/branches/release4.0/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh (original)
+++ ofbiz/branches/release4.0/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh Mon Jul  9 00:53:39 2007
@@ -22,6 +22,8 @@
 import javolution.util.FastList;
 import javolution.util.FastMap;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.*;
+import org.ofbiz.entity.condition.*;
 
 // Since this script is run after ViewShipment, we will re-use the shipment in the context
 shipment = context.get("shipment");
@@ -33,6 +35,7 @@
 
 // first we scan the shipment items and count the quantity of each product that is being shipped
 quantityShippedByProduct = FastMap.newInstance();
+quantityInShipmentByProduct = FastMap.newInstance();
 shipmentItems = shipment.getRelated("ShipmentItem");
 for (iter = shipmentItems.iterator(); iter.hasNext(); ) {
     shipmentItem = iter.next();
@@ -42,22 +45,54 @@
     if (shipped == null) shipped = new Double(0);
     shipped += shipmentItem.getDouble("quantity").doubleValue();
     quantityShippedByProduct.put(productId, shipped);
+    quantityInShipmentByProduct.put(productId, shipped);
 }
 
+// Add in the total of all previously shipped items
+previousShipmentIter = delegator.findListIteratorByCondition("Shipment",
+        new EntityConditionList(
+            UtilMisc.toList(
+                new EntityExpr("primaryOrderId", EntityOperator.EQUALS, shipment.getString("primaryOrderId")),
+                new EntityExpr("shipmentTypeId", EntityOperator.EQUALS, "SALES_SHIPMENT"),
+                new EntityExpr("createdDate", EntityOperator.LESS_THAN_EQUAL_TO, shipment.getString("createdDate"))
+            ),
+        EntityOperator.AND),
+    null, null, null, null);
+
+while ((previousShipmentItem = previousShipmentIter.next()) != null) {
+    if (previousShipmentItem.getString("shipmentId").equals(shipment.getString("shipmentId")) == false) {
+        previousShipmentItems = previousShipmentItem.getRelated("ShipmentItem");
+        for (iter = previousShipmentItems.iterator(); iter.hasNext(); ) {
+            shipmentItem = iter.next();
+            productId = shipmentItem.get("productId");
+
+            shipped = quantityShippedByProduct.get(productId);
+            if (shipped == null) shipped = new Double(0);
+            shipped += shipmentItem.getDouble("quantity").doubleValue();
+            quantityShippedByProduct.put(productId, shipped);
+        }
+    }
+}
+previousShipmentIter.close();
+
 // next scan the order items (via issuances) to count the quantity of each product requested
 quantityRequestedByProduct = FastMap.newInstance();
-issuances = shipment.getRelated("ItemIssuance");
+countedOrderItems = FastMap.newInstance(); // this map is only used to keep track of the order items already counted
+order = shipment.getRelatedOne("PrimaryOrderHeader");
+issuances = order.getRelated("ItemIssuance");
 for (iter = issuances.iterator(); iter.hasNext(); ) {
     issuance = iter.next();
     orderItem = issuance.getRelatedOne("OrderItem");
     productId = orderItem.get("productId");
-
-    requested = quantityRequestedByProduct.get(productId);
-    if (requested == null) requested = new Double(0);
-    cancelQuantity = orderItem.getDouble("cancelQuantity");
-    quantity = orderItem.getDouble("quantity");
-    requested += quantity.doubleValue() - (cancelQuantity != null ? cancelQuantity.doubleValue() : 0);
-    quantityRequestedByProduct.put(productId, requested);
+    if (!countedOrderItems.containsKey(orderItem.getString("orderId") + orderItem.getString("orderItemSeqId"))) {
+        countedOrderItems.put(orderItem.getString("orderId") + orderItem.getString("orderItemSeqId"), null);
+        requested = quantityRequestedByProduct.get(productId);
+        if (requested == null) requested = new Double(0);
+        cancelQuantity = orderItem.getDouble("cancelQuantity");
+        quantity = orderItem.getDouble("quantity");
+        requested += quantity.doubleValue() - (cancelQuantity != null ? cancelQuantity.doubleValue() : 0);
+        quantityRequestedByProduct.put(productId, requested);
+    }
 }
 
 // for each package, we want to list the quantities and details of each product
@@ -76,6 +111,7 @@
         line = FastMap.newInstance();
         line.put("product", product);
         line.put("quantityInPackage", content.get("quantity"));
+        line.put("quantityInShipment", quantityInShipmentByProduct.get(product.get("productId")));
         line.put("quantityShipped", quantityShippedByProduct.get(product.get("productId")));
         line.put("quantityRequested", quantityRequestedByProduct.get(product.get("productId")));
         lines.add(line);

Modified: ofbiz/branches/release4.0/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl?view=diff&rev=554550&r1=554549&r2=554550
==============================================================================
--- ofbiz/branches/release4.0/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl (original)
+++ ofbiz/branches/release4.0/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl Mon Jul  9 00:53:39 2007
@@ -53,7 +53,7 @@
             </fo:block>
             <fo:block><fo:leader/></fo:block>
 
-            <fo:block font-size="14pt">${uiLabelMap.ProductShipmentId} #${shipmentId} / Package ${package_index + 1}</fo:block>
+            <fo:block font-size="14pt">${uiLabelMap.ProductShipmentId} #${shipmentId} / Package ${package_index + 1}<#if (packages?size > 1)> of ${packages?size}</#if></fo:block>
             <fo:block font-size="12pt">${uiLabelMap.ProductOrderId} #${shipment.primaryOrderId?default("N/A")} / ${shipment.primaryShipGroupSeqId?default("N/A")}</fo:block>
             <fo:block><fo:leader/></fo:block>
 
@@ -112,14 +112,22 @@
             <fo:block space-after.optimum="10pt" font-size="10pt">
             <fo:table>
                 <fo:table-column column-width="250pt"/>
-                <fo:table-column column-width="67pt"/>
-                <fo:table-column column-width="67pt"/>
-                <fo:table-column column-width="67pt"/>
+                <#if (packages?size > 1)>
+                    <fo:table-column column-width="58pt"/>
+                    <fo:table-column column-width="45pt"/>
+                    <fo:table-column column-width="50pt"/>
+                    <fo:table-column column-width="47pt"/>
+                <#else>
+                    <fo:table-column column-width="67pt"/>
+                    <fo:table-column column-width="67pt"/>
+                    <fo:table-column column-width="67pt"/>
+                </#if>
                 <fo:table-header>
                     <fo:table-row font-weight="bold">
                         <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>${uiLabelMap.ProductProduct}</fo:block></fo:table-cell>
                         <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>Requested</fo:block></fo:table-cell>
                         <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>In this Package</fo:block></fo:table-cell>
+                        <#if (packages?size > 1)><fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>In this Shipment</fo:block></fo:table-cell></#if>
                         <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>Total Shipped</fo:block></fo:table-cell>
                     </fo:table-row>
                 </fo:table-header>
@@ -145,6 +153,11 @@
                                 <fo:table-cell padding="2pt" background-color="${rowColor}">
                                     <fo:block>${line.quantityInPackage?default(0)}</fo:block>
                                 </fo:table-cell>
+                                <#if (packages?size > 1)>
+                                    <fo:table-cell padding="2pt" background-color="${rowColor}">
+                                        <fo:block>${line.quantityInShipment?default(0)}</fo:block>
+                                    </fo:table-cell>
+                                </#if>
                                 <fo:table-cell padding="2pt" background-color="${rowColor}">
                                     <fo:block>${line.quantityShipped?default(0)}</fo:block>
                                 </fo:table-cell>