[OFBiz] SVN: r6122 - in trunk/applications: order/src/org/ofbiz/order/order product/src/org/ofbiz/product/inventory

sichen at svn.ofbiz.org sichen at svn.ofbiz.org
Mon Nov 14 13:49:38 EST 2005


Author: sichen
Date: 2005-11-14 12:49:31 -0600 (Mon, 14 Nov 2005)
New Revision: 6122

Modified:
   trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
   trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java
Log:
When exploding auto-exploded marketing packages, use a default quantity of 1.0 if the component product has no quantity specified in ProductAssoc, to avoid any possible crashes

Modified: trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java	2005-11-14 15:59:25 UTC (rev 6121)
+++ trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java	2005-11-14 18:49:31 UTC (rev 6122)
@@ -4423,6 +4423,12 @@
                 continue;
             }
 
+            // if an order item does not have a quantity, skip it
+            if (quantity == null) {
+                Debug.logWarning("Order item seq [" + orderItemSeqId + "] has a null quantity, so it cannot be exploded" , module);
+                continue;
+            }
+            
             try {
                 //deal with the order adjustment without orderItemSeqId.  These are adjustments of the order, and we just keep them.
                 if (orderAdjustments != null && orderAdjustments.size() > 0) {
@@ -4455,7 +4461,7 @@
                 if (tmpResult.get("assocProducts") != null) {
                     productAssocList = (List) tmpResult.get("assocProducts");
                 }
-
+                
                 if (productAssocList != null && productAssocList.size() > 0) {
                     Debug.logInfo("The product [" + productId + "] explodes to [" + productAssocList.toString() + "]", module);
                     // now add the associated products to the order
@@ -4467,7 +4473,14 @@
                         GenericValue productTo = productAssoc.getRelatedOne("AssocProduct");
                         String productIdTo = productTo.getString("productId");
                         String itemDescription = "";
+                        
                         Double productToQuantity = productAssoc.getDouble("quantity");
+                        
+                        if (productToQuantity == null) {
+                            productToQuantity = new Double(1.0);
+                            Debug.logWarning("For order item [" + orderItemSeqId + "] Product association [" + productAssoc + "] had a null quantity, assuming 1", module);
+                        }
+                        
                         Double newQuantity = new Double(productToQuantity.doubleValue() * quantity.doubleValue());
 
                         Double listPrice = new Double(0);
@@ -4529,7 +4542,7 @@
                         assocOrderItems.add(newOrderItem);
                         Debug.logInfo("explode OrderItem [" + orderItem.toString() + "] to [" + newOrderItem + "]", module);
                     }// for
-
+                    
                     // If there were a difference between the price of the parent item and the sum of the prices of the marketing package components,
                     // then create an OrderAdjustment for each new order item and pro-rate the difference based on its quantity and the total quantity of all
                     // the component items.

Modified: trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java
===================================================================
--- trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java	2005-11-14 15:59:25 UTC (rev 6121)
+++ trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java	2005-11-14 18:49:31 UTC (rev 6122)
@@ -589,6 +589,12 @@
                String productIdTo = productAssoc.getString("productIdTo");
                Double assocQuantity = productAssoc.getDouble("quantity");
                
+               // if there is no quantity for the associated product in ProductAssoc entity, default it to 1.0
+               if (assocQuantity == null) {
+                   Debug.logWarning("ProductAssoc from [" + productAssoc.getString("productId") + "] to [" + productAssoc.getString("productIdTo") + "] has no quantity, assuming 1.0", module);
+                   assocQuantity = new Double(1.0);
+               }
+               
                // figure out the inventory available for this associated product
                Map resultOutput = null;
                try {



More information about the Svn mailing list