svn commit: r594818 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java

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

svn commit: r594818 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java

jacopoc
Author: jacopoc
Date: Wed Nov 14 02:05:54 2007
New Revision: 594818

URL: http://svn.apache.org/viewvc?rev=594818&view=rev
Log:
The list of OrderItemPriceInfos returned by the price rule execution was overriding the existing list.

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=594818&r1=594817&r2=594818&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Wed Nov 14 02:05:54 2007
@@ -483,7 +483,6 @@
         boolean validPriceFound = false;
         double defaultPrice = 0;
         List orderItemPriceInfos = FastList.newInstance();
-        List additionalAdjustments = FastList.newInstance();
         if (defaultPriceValue != null) {
             // If a price calc formula (service) is specified, then use it to get the unit price
             if (UtilValidate.isNotEmpty(defaultPriceValue.getString("customPriceCalcService"))) {
@@ -504,7 +503,6 @@
                         if (!ServiceUtil.isError(outMap)) {
                             Double calculatedDefaultPrice = (Double)outMap.get("price");
                             orderItemPriceInfos = (List)outMap.get("orderItemPriceInfos");
-                            //additionalAdjustments = (List)outMap.get("additionalAdjustments");
                             if (UtilValidate.isNotEmpty(calculatedDefaultPrice)) {
                                 defaultPrice = calculatedDefaultPrice.doubleValue();
                                 validPriceFound = true;
@@ -625,6 +623,15 @@
                         averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
                         webSiteId, partyId, new Double(1.0), currencyUomId, delegator, nowTimestamp);
                     result.putAll(calcResults);
+                    // The orderItemPriceInfos out parameter requires a special treatment:
+                    // the list of OrderItemPriceInfos generated by the price rule is appended to
+                    // the existing orderItemPriceInfos list and the aggregated list is returned.
+                    List orderItemPriceInfosFromRule = (List)calcResults.get("orderItemPriceInfos");
+                    if (UtilValidate.isNotEmpty(orderItemPriceInfosFromRule)) {
+                        orderItemPriceInfos.addAll(orderItemPriceInfosFromRule);
+                    }
+                    result.put("orderItemPriceInfos", orderItemPriceInfos);
+
                     Map errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
                             checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
                     if (errorResult != null) return errorResult;
@@ -634,6 +641,15 @@
                         averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
                         webSiteId, partyId, new Double(quantity), currencyUomId, delegator, nowTimestamp);
                     result.putAll(calcResults);
+                    // The orderItemPriceInfos out parameter requires a special treatment:
+                    // the list of OrderItemPriceInfos generated by the price rule is appended to
+                    // the existing orderItemPriceInfos list and the aggregated list is returned.
+                    List orderItemPriceInfosFromRule = (List)calcResults.get("orderItemPriceInfos");
+                    if (UtilValidate.isNotEmpty(orderItemPriceInfosFromRule)) {
+                        orderItemPriceInfos.addAll(orderItemPriceInfosFromRule);
+                    }
+                    result.put("orderItemPriceInfos", orderItemPriceInfos);
+
                     Map errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
                         checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
                     if (errorResult != null) return errorResult;