Author: jleroux
Date: Mon Feb 24 10:50:12 2014
New Revision: 1571225

URL: http://svn.apache.org/r1571225
Log:
"Applied fix from trunk for revision: 1571219" 
------------------------------------------------------------------------
r1571219 | jleroux | 2014-02-24 11:33:12 +0100 (lun. 24 févr. 2014) | 10 lignes

After reverting r1571198 (there was too much unwanted changes due to my "Save 
Actions" setting in Eclipse) doing it again with the only changes really wanted

A slightly modified patch from Praveen Agrawal for "The getFeatureIdQtyMap 
function doesn't include the DISTINGUISHING_FEAT into the featureMap" 
https://issues.apache.org/jira/browse/OFBIZ-5544

The getFeatureIdQtyMap function in ShoppingCartItem.java doesn't include the 
DISTINGUISHING_FEAT in featureMap so if we want to calculate the Shipping 
amount based on Distinguishing feature, this method doesn't return the 
Distinguishing Feature in Feature Map. If we add DISTINGUISHING_FEAT as 
productFeatureApplTypeId in filterExprs then the feature map would contain the 
Distinguishing feature in addition to Standard and Required Feature.

Also in ShoppingCartItem.java, putAdditionalProductFeatureAndAppl method, i 
think the OrderAdjustment should only be included when the amount is not null.

jleroux: When the amount is null it's now not added in the adjustement (I moved 
that in the block above where the amount is already tested for null). But the 
OrderAdjustment is still created because a recurringAmount could still exist . 
I just added a warning for when both amounts are null. We could decide to not 
create an adjustement when there are no amounts at all. But I preferred a 
warning, because it's a weird situation and people could prefer to be aware...

------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    
ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1571219

Modified: 
ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=1571225&r1=1571224&r2=1571225&view=diff
==============================================================================
--- 
ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
 (original)
+++ 
ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
 Mon Feb 24 10:50:12 2014
@@ -2136,8 +2136,8 @@ public class ShoppingCartItem implements
         BigDecimal amount = (BigDecimal) 
additionalProductFeatureAndAppl.get("amount");
         if (amount != null) {
             amount = amount.multiply(this.getQuantity());
+            orderAdjustment.set("amount", amount);
         }
-        orderAdjustment.set("amount", amount);
 
         BigDecimal recurringAmount = (BigDecimal) 
additionalProductFeatureAndAppl.get("recurringAmount");
         if (recurringAmount != null) {
@@ -2146,6 +2146,10 @@ public class ShoppingCartItem implements
             //Debug.logInfo("Setting recurringAmount " + recurringAmount + " 
for " + orderAdjustment, module);
         }
 
+        if (amount == null && recurringAmount == null) {
+            Debug.logWarning("In putAdditionalProductFeatureAndAppl the amount 
and recurringAmount are null for this adjustment: " + orderAdjustment, module);
+        }
+
         this.addAdjustment(orderAdjustment);
     }
 
@@ -2181,6 +2185,7 @@ public class ShoppingCartItem implements
                 featureAppls = product.getRelated("ProductFeatureAppl", null, 
null, false);
                 List<EntityExpr> filterExprs = 
UtilMisc.toList(EntityCondition.makeCondition("productFeatureApplTypeId", 
EntityOperator.EQUALS, "STANDARD_FEATURE"));
                 
filterExprs.add(EntityCondition.makeCondition("productFeatureApplTypeId", 
EntityOperator.EQUALS, "REQUIRED_FEATURE"));
+                
filterExprs.add(EntityCondition.makeCondition("productFeatureApplTypeId", 
EntityOperator.EQUALS, "DISTINGUISHING_FEAT"));
                 featureAppls = EntityUtil.filterByOr(featureAppls, 
filterExprs);
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Unable to get features from product : " + 
product.get("productId"), module);


Reply via email to