svn commit: r1571219 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java

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

svn commit: r1571219 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java

jleroux@apache.org
Author: jleroux
Date: Mon Feb 24 10:33:12 2014
New Revision: 1571219

URL: http://svn.apache.org/r1571219
Log:
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/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=1571219&r1=1571218&r2=1571219&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Mon Feb 24 10:33: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);