svn commit: r1747540 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java product/config/promotext.properties

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

svn commit: r1747540 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java product/config/promotext.properties

Mridul Pathak-5
Author: mridulpathak
Date: Thu Jun  9 11:58:22 2016
New Revision: 1747540

URL: http://svn.apache.org/viewvc?rev=1747540&view=rev
Log:
[OFBIZ-7027] Added support to include party classification information in promo description. Thanks Swapnil M Mane for the contribution.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
    ofbiz/trunk/applications/product/config/promotext.properties

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=1747540&r1=1747539&r2=1747540&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Thu Jun  9 11:58:22 2016
@@ -666,6 +666,8 @@ public class ProductPromoWorker {
         if (productPromo == null) {
             return "";
         }
+        ArrayList<String> partyClassificationsIncluded = new ArrayList<String>();
+        ArrayList<String> partyClassificationsExcluded = new ArrayList<String>();
         StringBuilder promoDescBuf = new StringBuilder();
         List<GenericValue> productPromoRules = productPromo.getRelated("ProductPromoRule", null, null, true);
         Iterator<GenericValue> promoRulesIter = productPromoRules.iterator();
@@ -688,12 +690,27 @@ public class ProductPromoWorker {
                 }
 
                 Map<String, Object> messageContext = UtilMisc.<String, Object>toMap("condValue", condValue, "equalityOperator", equalityOperator, "quantityOperator", quantityOperator);
-                String msgProp = UtilProperties.getMessage("promotext", "condition." + productPromoCond.getString("inputParamEnumId"), messageContext, locale);
-                promoDescBuf.append(msgProp);
-                promoDescBuf.append(" ");
 
-                if (promoRulesIter.hasNext()) {
-                    promoDescBuf.append(" and ");
+                if ("PPIP_PARTY_CLASS".equalsIgnoreCase(productPromoCond.getString("inputParamEnumId"))) {
+                    GenericValue partyClassificationGroup = EntityQuery.use(delegator).from("PartyClassificationGroup").where("partyClassificationGroupId", condValue).cache(true).queryOne();
+                    if (UtilValidate.isNotEmpty(partyClassificationGroup) && UtilValidate.isNotEmpty(partyClassificationGroup.getString("description"))) {
+                        condValue = partyClassificationGroup.getString("description");
+                    }
+
+                    if ("PPC_EQ".equalsIgnoreCase(productPromoCond.getString("operatorEnumId"))) {
+                        partyClassificationsIncluded.add(condValue);
+                    }
+                    if ("PPC_NEQ".equalsIgnoreCase(productPromoCond.getString("operatorEnumId"))) {
+                        partyClassificationsExcluded.add(condValue);
+                    }
+                } else {
+                    String msgProp = UtilProperties.getMessage("promotext", "condition." + productPromoCond.getString("inputParamEnumId"), messageContext, locale);
+                    promoDescBuf.append(msgProp);
+                    promoDescBuf.append(" ");
+
+                    if (promoRulesIter.hasNext()) {
+                        promoDescBuf.append(" and ");
+                    }
                 }
             }
 
@@ -752,6 +769,18 @@ public class ProductPromoWorker {
                     UtilMisc.toMap("limit", productPromo.getLong("useLimitPerPromotion")), locale));
         }
 
+        if (UtilValidate.isNotEmpty(partyClassificationsIncluded)) {
+            Map<String, Object> messageContext = UtilMisc.<String, Object>toMap("partyClassificationsIncluded", partyClassificationsIncluded);
+            String msgProp = UtilProperties.getMessage("promotext", "condition.PPIP_PARTY_CLASS.APPLIED", messageContext, locale);
+            promoDescBuf.append("\n" + msgProp);
+        }
+
+        if (UtilValidate.isNotEmpty(partyClassificationsExcluded)) {
+            Map<String, Object> messageContext = UtilMisc.<String, Object>toMap("partyClassificationsExcluded", partyClassificationsExcluded);
+            String msgProp = UtilProperties.getMessage("promotext", "condition.PPIP_PARTY_CLASS.NOT_APPLIED", messageContext, locale);
+            promoDescBuf.append("\n" + msgProp);
+        }
+
         return promoDescBuf.toString();
     }
 

Modified: ofbiz/trunk/applications/product/config/promotext.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/promotext.properties?rev=1747540&r1=1747539&r2=1747540&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/promotext.properties (original)
+++ ofbiz/trunk/applications/product/config/promotext.properties Thu Jun  9 11:58:22 2016
@@ -33,6 +33,8 @@ operator.quantity.PPC_GTE=more than
 
 
 condition.PPIP_ORDER_TOTAL=spend ${quantityOperator} $${condValue}
+condition.PPIP_PARTY_CLASS.APPLIED=Applied to party classification - ${partyClassificationsIncluded}
+condition.PPIP_PARTY_CLASS.NOT_APPLIED=Not applied to party classification - ${partyClassificationsExcluded}
 condition.PPIP_PRODUCT_TOTAL=buy ${quantityOperator} $${condValue} of qualifying products
 condition.PPIP_PRODUCT_AMOUNT=for each $${condValue} or more of qualifying products
 condition.PPIP_PRODUCT_QUANT=buy ${condValue} of qualifying products