svn commit: r1831783 [3/3] - in /ofbiz/ofbiz-framework/trunk/applications: datamodel/entitydef/ order/servicedef/ order/src/main/java/org/apache/ofbiz/order/shoppingcart/ order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ product/ product...

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

svn commit: r1831783 [3/3] - in /ofbiz/ofbiz-framework/trunk/applications: datamodel/entitydef/ order/servicedef/ order/src/main/java/org/apache/ofbiz/order/shoppingcart/ order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ product/ product...

nmalin
Added: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy?rev=1831783&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy Thu May 17 14:03:46 2018
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.sql.Timestamp
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilMisc
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.order.shoppingcart.ShoppingCart
+import org.apache.ofbiz.testtools.GroovyScriptTestCase
+import org.apache.ofbiz.service.ServiceUtil
+
+class ProductPromoCondTest extends GroovyScriptTestCase {
+
+    Map prepareConditionMap(ShoppingCart cart, String condValue) {
+        return prepareConditionMap(cart, condValue, false)
+    }
+
+    Map prepareConditionMap(ShoppingCart cart, String condValue, boolean persist) {
+        GenericValue productPromoCond = delegator.makeValue("ProductPromoCond", [condValue: condValue])
+        if (persist) {
+            GenericValue productPromo = delegator.makeValue("ProductPromo", [productPromoId: 'TEST'])
+            delegator.createOrStore(productPromo)
+            GenericValue productPromoRule = delegator.makeValue("ProductPromoRule", [productPromoId: 'TEST', productPromoRuleId:'01'])
+            delegator.createOrStore(productPromoRule)
+            productPromoCond.productPromoId = 'TEST'
+            productPromoCond.productPromoRuleId = '01'
+            productPromoCond.productPromoCondSeqId = '01'
+            delegator.createOrStore(productPromoCond)
+        }
+        return  [shoppingCart: cart, nowTimestamp: UtilDateTime.nowTimestamp(), productPromoCond: productPromoCond]
+    }
+
+    ShoppingCart loadOrder(String orderId) {
+        GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
+        Map<String, Object> serviceCtx = [orderId: orderId,
+                skipInventoryChecks: true, // the items are already reserved, no need to check again
+                skipProductChecks: true, // the products are already in the order, no need to check their validity now
+                includePromoItems: false,
+                createAsNewOrder: 'Y',
+                userLogin: permUserLogin]
+        Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
+
+        return loadCartResp.shoppingCart
+    }
+
+    /**
+     * This test check if the function productPartyID work correctly
+     *  1. test success with a valid partyId
+     *  2. test failed with passing non valid value
+     */
+    void testPartyIdPromo() {
+        String condValue = "FrenchCustomer"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId(condValue)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyID", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondPartyID", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productNewACCT work correctly
+     *  1. test success if the customer is subscribed more than the "condValue"
+     *  2. test failed with passing non valid value
+     */
+    void testNewACCTPromo() {
+        String condValue = "1095"
+        GenericValue frenchCustomer = delegator.makeValue("Party", [partyId: "FrenchCustomer", createdDate: Timestamp.valueOf("2010-01-01 00:00:00")])
+        frenchCustomer.store()
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        Timestamp nowTimestamp = UtilDateTime.nowTimestamp()
+        cart.setOrderPartyId("FrenchCustomer")
+        cart.getPartyDaysSinceCreated(nowTimestamp)
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondNewACCT", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase >= 0
+
+        //2.test promo nonvalid
+        frenchCustomer.createdDate = nowTimestamp
+        frenchCustomer.store()
+        cart.getPartyDaysSinceCreated(nowTimestamp)
+        serviceResult = dispatcher.runSync("productPromoCondNewACCT", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase < 0
+    }
+
+    /**
+     * This test check if the function productPartyClass work correctly
+     *  1. test success if the login user is from part of classification of the promoCondition
+     *  2. test failed with passing non valid value
+     */
+    void testPartyClassPromo() {
+        String condValue = "PROMO_TEST"
+        GenericValue partyClassGroup = delegator.makeValue("PartyClassificationGroup", [partyClassificationGroupId: condValue])
+        delegator.createOrStore(partyClassGroup)
+        GenericValue partyClassification = delegator.makeValue("PartyClassification",
+                [partyId: "FrenchCustomer", partyClassificationGroupId: condValue,
+                 fromDate: Timestamp.valueOf("2010-01-01 00:00:00"),
+                 thruDate: null])
+        delegator.createOrStore(partyClassification)
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId("FrenchCustomer")
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyClass", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        partyClassification.refresh()
+        partyClassification.thruDate = Timestamp.valueOf("2010-01-01 00:00:00")
+        partyClassification.store()
+        serviceResult = dispatcher.runSync("productPromoCondPartyClass", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 1
+    }
+
+    /**
+     * This test check if the function productPartyGM work correctly
+     *  1. test success if the login user is from part of the Group member of the promoCondition
+     *  2. test failed with passing non valid value
+     */
+    void testPartyGMPromo() {
+        String condValue = "HUMAN_RES"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId(condValue)
+        GenericValue partyRole = delegator.makeValue("PartyRole", [partyId: "FrenchCustomer", roleTypeId: "_NA_"])
+        delegator.createOrStore(partyRole)
+        partyRole.partyId = condValue
+        delegator.createOrStore(partyRole)
+        GenericValue relation = delegator.makeValue("PartyRelationship", [partyIdFrom: "FrenchCustomer", roleTypeIdFrom: "_NA_",
+                                               partyIdTo: condValue, roleTypeIdTo: "_NA_",
+                                               fromDate: Timestamp.valueOf("2010-01-01 00:00:00"),
+                                               partyRelationshipTypeId: "GROUP_ROLLUP"])
+        delegator.createOrStore(relation)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyGM", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondPartyGM", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 1
+    }
+
+    /**
+     * This test check if the function productRoleType work correctly
+     *  1. test success if the login user role type is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testRoleTypePromo() {
+        String condValue = "APPROVER"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId("FrenchCustomer")
+        GenericValue partyRole = delegator.makeValue("PartyRole", [partyId: "FrenchCustomer", roleTypeId: condValue])
+        delegator.createOrStore(partyRole)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondRoleType", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondRoleType", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productGeoID work correctly
+     *  1. test success if the shipping address is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testCondGeoIdPromo() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+        cart.setShippingContactMechId(0, "9200")
+        GenericValue productPromoCond = EntityQuery.use(delegator).from("ProductPromoCond").where("productPromoId", "9022", "productPromoRuleId", "01", "productPromoCondSeqId", "01").queryOne()
+
+        // call service promo
+        Map<String, Object> serviceContext = [shoppingCart: cart, nowTimestamp: UtilDateTime.nowTimestamp(), productPromoCond: productPromoCond]
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondGeoID", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart = loadOrder("DEMO10091")
+        cart.setShippingContactMechId(0, "10000")
+        serviceContext.shoppingCart = cart
+        serviceResult = dispatcher.runSync("productPromoCondGeoID", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productOrderTotal work correctly
+     *  1. test success if the order total is equal or greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testCondOrderTotalPromo() {
+        String condValue = "34.56"
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(loadOrder("DEMO10090"), condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondOrderTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        serviceContext.shoppingCart = loadOrder("Demo1002")
+        serviceResult = dispatcher.runSync("productPromoCondOrderTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase > 0
+    }
+
+    /**
+     * This test check if the function productPromoRecurrence work correctly
+     *  1. test success if the recurrence is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testRecurrencePromo() {
+        String condValue = "TEST_PROMO"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        GenericValue reccurenceRule = delegator.makeValue("RecurrenceRule", [recurrenceRuleId: condValue, frequency: "DAILY", intervalNumber: 1l,
+                                                                       countNumber: -1l, byDayList: "MO,TU,WE,TH,FR,SA,SU"])
+        delegator.createOrStore(reccurenceRule)
+        GenericValue reccurenceInfo = delegator.makeValue("RecurrenceInfo", [recurrenceInfoId: condValue, startDateTime: Timestamp.valueOf("2008-01-01 00:00:00.000"),
+                                                                       recurrenceRuleId: condValue, recurrenceCount: 0l])
+        delegator.createOrStore(reccurenceInfo)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPromoRecurrence", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        condValue = "3"
+        serviceContext = prepareConditionMap(cart, condValue)
+        serviceResult = dispatcher.runSync("productPromoCondPromoRecurrence", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productShipTotal work correctly
+     *  1. test success if ship total is greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testShipTotalPromo() {
+        String condValue = "20"
+        BigDecimal amount = BigDecimal.valueOf(25)
+        ShoppingCart cart = loadOrder("DEMO10090")
+        cart.setItemShipGroupEstimate(amount, 0)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondOrderShipTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase > 0
+
+        //2.test promo nonvalid
+        amount = BigDecimal.valueOf(19)
+        cart.setItemShipGroupEstimate(amount, 0)
+        serviceResult = dispatcher.runSync("productPromoCondOrderShipTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase <= 0
+    }
+
+    /**
+     * This test check if the function productAmount work correctly
+     *  1. test success if the amount of specific product is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testProductAmountPromo() {
+        String condValue = "30"
+        String orderId = "DEMO10090"
+        ShoppingCart cart = loadOrder(orderId)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue, true)
+        GenericValue productPromoProduct = delegator.makeValue("ProductPromoProduct",
+                [productPromoId: 'TEST', productPromoRuleId: '01', productPromoCondSeqId: '01',
+                 productId: 'GZ-2644', productPromoApplEnumId: 'PPPA_INCLUDE', productPromoActionSeqId: '_NA_'])
+        delegator.createOrStore(productPromoProduct)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondProductAmount", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        condValue = "50"
+        serviceContext = prepareConditionMap(cart, condValue, true)
+        serviceResult = dispatcher.runSync("productPromoCondProductAmount", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productTotal work correctly
+     *  1. test success if the total amount of product is equal or greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testProductTotalPromo() {
+        String orderId = "Demo1002"
+        ShoppingCart cart = loadOrder(orderId)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, "50", true)
+        GenericValue productPromoProduct = delegator.makeValue("ProductPromoProduct",
+            [productPromoId: 'TEST', productPromoRuleId: '01', productPromoCondSeqId: '01',
+             productId: 'WG-1111', productPromoApplEnumId: 'PPPA_INCLUDE', productPromoActionSeqId: '_NA_'])
+        delegator.createOrStore(productPromoProduct)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondProductTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase >= 0
+
+
+        //2.test promo nonvalid
+        cart = loadOrder(orderId)
+        serviceContext = prepareConditionMap(cart, "150", true)
+        serviceResult = dispatcher.runSync("productPromoCondProductTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase < 0
+    }
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/product/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/ofbiz-component.xml?rev=1831783&r1=1831782&r2=1831783&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/ofbiz-component.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/ofbiz-component.xml Thu May 17 14:03:46 2018
@@ -32,7 +32,8 @@ under the License.
     <entity-resource type="data" reader-name="seed" loader="main" location="data/FacilitySecurityPermissionSeedData.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/ApiSchemaDhl.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/ProductPortletData.xml"/>
-    
+    <entity-resource type="data" reader-name="seed" loader="main" location="data/PromoCustomMethodData.xml"/>
+
     <entity-resource type="data" reader-name="seed-initial" loader="main" location="data/ProductScheduledServices.xml"/>
     <entity-resource type="data" reader-name="seed-initial" loader="main" location="data/CatalogSystemPropertyData.xml"/>
 
@@ -70,6 +71,7 @@ under the License.
     <test-suite loader="main" location="testdef/GroupOrderTest.xml"/>
     <test-suite loader="main" location="testdef/ProductTagTest.xml"/>
     <test-suite loader="main" location="testdef/ProductTest.xml"/>
+    <test-suite loader="main" location="testdef/ProductPromoTests.xml"/>
 
     <webapp name="catalog"
         title="Catalog"

Modified: ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_pricepromo.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_pricepromo.xml?rev=1831783&r1=1831782&r2=1831783&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_pricepromo.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_pricepromo.xml Thu May 17 14:03:46 2018
@@ -156,7 +156,7 @@ under the License.
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="productPromoActionSeqId" mode="OUT"/>
-        <override name="productPromoActionEnumId" optional="false"/>
+        <override name="customMethodId" optional="false" />
     </service>
     <service name="updateProductPromoAction" default-entity-name="ProductPromoAction" engine="entity-auto" invoke="update" auth="true">
         <description>Update a ProductPromo</description>
@@ -368,4 +368,158 @@ under the License.
         <description>Delete a ProductPriceAutoNotice</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
-</services>
+
+    <!-- ProductPricePromoCond services -->
+    <service name="interfaceProductPromoCond" engine="interface" location="" invoke="">
+        <attribute name="productPromoCond" type="org.apache.ofbiz.entity.GenericValue" mode="IN"/>
+        <attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN"/>
+        <attribute name="nowTimestamp" type="Timestamp" mode="IN"/>
+        <attribute name="directResult" type="Boolean" mode="OUT" optional="true"/>
+        <attribute name="compareBase" type="Integer" mode="OUT" optional="true"/>
+        <attribute name="operatorEnumId" type="String" mode="OUT" optional="true"/>
+    </service>
+    <service name="productPromoCondProductAmount" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productAmount">
+        <description>Product promo condition service on the product amount</description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondProductTotal" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productTotal">
+        <description>Product promo condition service on the product Total</description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondProductQuant" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productQuant">
+        <description>Product promo condition service on quantity </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondNewACCT" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productNewACCT">
+        <description>Product promo condition service on Account Days Since Created </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondPartyID" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productPartyID">
+        <description>Product promo condition service on party ID </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondPartyGM" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productPartyGM">
+        <description>Product promo condition service on party group member </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondPartyClass" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productPartyClass">
+        <description>Product promo condition service on party Classification </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondRoleType" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productRoleType">
+        <description>Product promo condition service on role type </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondGeoID" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productGeoID">
+        <description>Product promo condition service on shipping destination </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondOrderTotal" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productOrderTotal">
+        <description>Product promo condition service on cart sub-total </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondOrderHist" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productOrderHist">
+        <description>Product promo condition service on Order sub-total X in last Y Months </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondOrderYear" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productOrderYear">
+        <description>Product promo condition service on Order sub-total X since beginning of current year </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondOrderLastYear" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productOrderLastYear">
+        <description>Product promo condition service on Order sub-total X last year </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondPromoRecurrence" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productPromoRecurrence">
+        <description>Product promo condition service on promotion recurrence </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondOrderShipTotal" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productShipTotal">
+        <description>Product promo condition service on promotion recurrence </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondListPriceMinAmount" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productListPriceMinAmount">
+        <description>Product promo condition service on shipping total </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+    <service name="productPromoCondListPriceMinPercent" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoCondServices.groovy" invoke="productListPriceMinPercent">
+        <description>Product promo condition service on shipping total </description>
+        <implements service="interfaceProductPromoCond"/>
+    </service>
+
+    <!-- ProductPricePromoAction services -->
+    <service name="interfaceProductPromoAction" engine="interface" location="" invoke="">
+        <attribute name="productPromoAction" type="org.apache.ofbiz.entity.GenericValue" mode="IN"/>
+        <attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN"/>
+        <attribute name="nowTimestamp" type="Timestamp" mode="IN"/>
+        <attribute name="actionResultInfo" type="org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker$ActionResultInfo" mode="INOUT" />
+        <attribute name="cartItemModifyException" type="org.apache.ofbiz.order.shoppingcart.CartItemModifyException" mode="OUT" optional="true"/>
+    </service>
+    <service name="productPromoActGiftGWP" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productGWP">
+        <description>Product promo Action gift with purchase </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActFreeShip" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productActFreeShip">
+        <description>Product promo Action free shipping </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActProdDISC" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productDISC">
+        <description>Product promo Action product discount % </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActProdAMDISC" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productAMDISC">
+        <description>Product promo Action product discount </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActProdPrice" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productPrice">
+        <description>Product promo Action product price </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActOrderPercent" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productOrderPercent">
+        <description>Product promo Action order percent </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActOrderAmount" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productOrderAmount">
+        <description>Product promo Action order amount </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActProdSpecialPrice" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productSpecialPrice">
+        <description>Product promo Action product special price </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActTaxPercent" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productTaxPercent">
+        <description>Product promo Action product tax percent </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+    <service name="productPromoActShipCharge" engine="groovy" auth="false"
+            location="component://product/groovyScripts/product/promo/ProductPromoActionServices.groovy" invoke="productShipCharge">
+        <description>Product promo Action product shipping charge </description>
+        <implements service="interfaceProductPromoAction"/>
+    </service>
+</services>

Modified: ofbiz/ofbiz-framework/trunk/applications/product/template/promo/EditProductPromoRules.ftl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/template/promo/EditProductPromoRules.ftl?rev=1831783&r1=1831782&r2=1831783&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/template/promo/EditProductPromoRules.ftl (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/template/promo/EditProductPromoRules.ftl Thu May 17 14:03:46 2018
@@ -80,15 +80,15 @@ under the License.
                   <input type="hidden" name="productPromoRuleId" value="${(productPromoCond.productPromoRuleId)!}"/>
                   <input type="hidden" name="productPromoCondSeqId" value="${(productPromoCond.productPromoCondSeqId)!}"/>
                   <select name="inputParamEnumId" size="1">
-      <#if (productPromoCond.inputParamEnumId)??>
-        <#assign inputParamEnum = productPromoCond.getRelatedOne("InputParamEnumeration", true)>
-                    <option value="${productPromoCond.inputParamEnumId}"><#if inputParamEnum??>${(inputParamEnum.get("description",locale))!}<#else>[${(productPromoCond.inputParamEnumId)!}]</#if></option>
-                    <option value="${(productPromoCond.inputParamEnumId)!}">&nbsp;</option>
+                  <#if (productPromoCond.customMethodId)??>
+                    <#assign customMethod = productPromoCond.getRelatedOne("CustomMethod", true)>
+                             <option value="${productPromoCond.customMethodId}"><#if customMethod??>${(customMethod.get("description",locale))!}<#else>[${(productPromoCond.customMethodId)!}]</#if></option>
+                             <option value="${(productPromoCond.customMethodId)!}">&nbsp;</option>
       <#else>
                     <option value="">&nbsp;</option>
       </#if>
-      <#list inputParamEnums as inputParamEnum>
-                    <option value="${(inputParamEnum.enumId)!}">${(inputParamEnum.get("description",locale))!}</option>
+      <#list inputParamCustomMethods as inputParamCustomMethod>
+                    <option value="${(inputParamCustomMethod.customMethodId)!}">${(inputParamCustomMethod.get("description",locale))!}</option>
       </#list>
                   </select>
                   <select name="operatorEnumId" size="1">
@@ -240,9 +240,9 @@ under the License.
                   <input type="hidden" name="productPromoId" value="${(productPromoRule.productPromoId)!}" />
                   <input type="hidden" name="productPromoRuleId" value="${(productPromoRule.productPromoRuleId)!}" />
                   <span class="label"><b>${uiLabelMap.CommonNew}</b>&nbsp;</span>
-                  <select name="inputParamEnumId" size="1">
-    <#list inputParamEnums as inputParamEnum>
-                    <option value="${(inputParamEnum.enumId)!}">${(inputParamEnum.get("description",locale))!}</option>
+                  <select name="customMethodId" size="1">
+    <#list inputParamCustomMethods as inputParamCustomMethod>
+                    <option value="${(inputParamCustomMethod.customMethodId)!}">${(inputParamCustomMethod.get("description",locale))!}</option>
     </#list>
                   </select>
                   <select name="operatorEnumId" size="1">
@@ -268,7 +268,7 @@ under the License.
           </table>
         </td>
       </tr>
-      <tr><td><hr /></td><td colspan="2"></td></tr>
+      <tr><td><hr/> </td><td colspan="2"></td></tr>
       <tr valign="top" class="row-level-one<#if "1" == ruleClass> alternate-row</#if>">
         <td align="right" class="label">${uiLabelMap.ProductActionForRule} ${(productPromoRule.productPromoRuleId)!} :</td>
         <td colspan="2">
@@ -284,16 +284,16 @@ under the License.
                     <input type="hidden" name="productPromoId" value="${(productPromoAction.productPromoId)!}" />
                     <input type="hidden" name="productPromoRuleId" value="${(productPromoAction.productPromoRuleId)!}" />
                     <input type="hidden" name="productPromoActionSeqId" value="${(productPromoAction.productPromoActionSeqId)!}" />
-                    <select name="productPromoActionEnumId" size="1">
-      <#if (productPromoAction.productPromoActionEnumId)??>
+                    <select name="customMethodId" size="1">
+      <#if (productPromoAction.customMethodId)??>
         <#assign productPromoActionCurEnum = productPromoAction.getRelatedOne("ActionEnumeration", true)>
-                      <option value="${(productPromoAction.productPromoActionEnumId)!}"><#if productPromoActionCurEnum??>${(productPromoActionCurEnum.get("description",locale))!}<#else>[${(productPromoAction.productPromoActionEnumId)!}]</#if></option>
-                      <option value="${(productPromoAction.productPromoActionEnumId)!}">&nbsp;</option>
+                      <option value="${(productPromoAction.customMethodId)!}"><#if productPromoActionCurEnum??>${(productPromoActionCurEnum.get("description",locale))!}<#else>[${(productPromoAction.customMethodId)!}]</#if></option>
+                      <option value="${(productPromoAction.customMethodId)!}">&nbsp;</option>
       <#else>
                       <option value="">&nbsp;</option>
       </#if>
-      <#list productPromoActionEnums as productPromoActionEnum>
-                      <option value="${(productPromoActionEnum.enumId)!}">${(productPromoActionEnum.get("description",locale))!}</option>
+      <#list PromoActionCustomMethods as PromoActionCustomMethod>
+                      <option value="${(PromoActionCustomMethod.customMethodId)!}">${(PromoActionCustomMethod.get("description",locale))!}</option>
       </#list>
                     </select>
                     <input type="hidden" name="orderAdjustmentTypeId" value="${(productPromoAction.orderAdjustmentTypeId)!}" />
@@ -400,7 +400,6 @@ under the License.
                   <form method="post" action="<@ofbizUrl>createProductPromoProduct</@ofbizUrl>" name="createProductPromoProductActions">
                     <input type="hidden" name="productPromoId" value="${productPromoId}" />
                     <input type="hidden" name="productPromoRuleId" value="${productPromoAction.productPromoRuleId}" />
-                    <input type="hidden" name="productPromoActionSeqId" value="${productPromoAction.productPromoActionSeqId}" />
                     <input type="hidden" name="productPromoCondSeqId" value="_NA_" />
                     <@htmlTemplate.lookupField formName="createProductPromoProductActions" name="productId" id="productId" fieldFormName="LookupProduct"/>
                     <select name="productPromoApplEnumId">
@@ -427,10 +426,11 @@ under the License.
                   <form method="post" action="<@ofbizUrl>createProductPromoAction</@ofbizUrl>" name="createProductPromoAction">
                     <input type="hidden" name="productPromoId" value="${(productPromoRule.productPromoId)!}" />
                     <input type="hidden" name="productPromoRuleId" value="${(productPromoRule.productPromoRuleId)!}" />
+                    <input type="hidden" name="customMethodId" value="${(productPromoAction.customMethodId)!}" />
                     <span class="label"><b>${uiLabelMap.CommonNew}:</b>&nbsp;</span>
-                    <select name="productPromoActionEnumId" size="1">
-    <#list productPromoActionEnums as productPromoActionEnum>
-                      <option value="${(productPromoActionEnum.enumId)!}">${(productPromoActionEnum.get("description",locale))!}</option>
+                    <select name="customMethodId" size="1">
+    <#list PromoActionCustomMethods as PromoActionCustomMethod>
+                      <option value="${(PromoActionCustomMethod.customMethodId)!}">${(PromoActionCustomMethod.get("description",locale))!}</option>
     </#list>
                     </select>
                     <input type="hidden" name="orderAdjustmentTypeId" value="PROMOTION_ADJUSTMENT" />

Added: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml?rev=1831783&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml (added)
+++ ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml Thu May 17 14:03:46 2018
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<test-suite suite-name="productPromoTests"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
+
+    <test-group case-name="product-Conditions-tests">
+        <groovy-test-suite name="prodCond" location="component://product/groovyScripts/product/test/ProductPromoCondTests.groovy"/>
+        <!--groovy-test-suite name="productPromoCondTests" location="component://product/groovyScripts/product/test/ProductPromoCondTests.groovy"/-->
+    </test-group>
+    <test-group case-name="product-Action-tests">
+        <groovy-test-suite name="productPromoActionTests" location="component://product/groovyScripts/product/test/ProductPromoActionTests.groovy"/>
+    </test-group>
+</test-suite>

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/ofbiz-framework/trunk/applications/product/widget/catalog/PromoScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=1831783&r1=1831782&r2=1831783&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/widget/catalog/PromoScreens.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/widget/catalog/PromoScreens.xml Thu May 17 14:03:46 2018
@@ -160,9 +160,9 @@ under the License.
                 </entity-condition>
 
                 <!-- General Data for Drop-downs, etc -->
-                <entity-condition entity-name="Enumeration" list="inputParamEnums" use-cache="true">
-                    <condition-expr field-name="enumTypeId" value="PROD_PROMO_IN_PARAM"/>
-                    <order-by field-name="sequenceId"/>
+                <entity-condition entity-name="CustomMethod" list="inputParamCustomMethods" use-cache="true">
+                    <condition-expr field-name="customMethodTypeId" value="PRODUCT_PROMO_COND"/>
+                    <order-by field-name="customMethodName"/>
                 </entity-condition>
                 <entity-condition entity-name="CarrierShipmentMethod" list="carrierShipmentMethods" use-cache="true">
                     <order-by field-name="shipmentMethodTypeId"/>
@@ -171,9 +171,9 @@ under the License.
                     <condition-expr field-name="enumTypeId" value="PROD_PROMO_COND"/>
                     <order-by field-name="sequenceId"/>
                 </entity-condition>
-                <entity-condition entity-name="Enumeration" list="productPromoActionEnums" use-cache="true">
-                    <condition-expr field-name="enumTypeId" value="PROD_PROMO_ACTION"/>
-                    <order-by field-name="sequenceId"/>
+                <entity-condition entity-name="CustomMethod" list="PromoActionCustomMethods" use-cache="true">
+                    <condition-expr field-name="customMethodTypeId" value="PRODUCT_PROMO_ACTION"/>
+                    <order-by field-name="customMethodName"/>
                 </entity-condition>
                 <entity-condition entity-name="Enumeration" list="productPromoApplEnums" use-cache="true">
                     <condition-expr field-name="enumTypeId" value="PROD_PROMO_PCAPPL"/>