462c8b0bc5597bddef18512d0de05bbd542a7f4f
Example: Consider two promotions: * consider two products: Product A, with price $20, and Product B, with price $40 * Promotion 1: 20% discount on all the products in a category containing Product A and Product B * Promotion 2: 40% discount on Product A When Product A and Product B are both in the cart: * Expected behavior: on Product A the Promotion 2 should be applied i.e. 40% discount, and on Product B Promotion 1 should be applied i.e. 20% discount. ** Summary Product Price Discount Subtotal A $20 $8 (40% discount) $12 B $40 $8 (20% discount) $32 Total Adjustment: $16 * OFBiz behavior (before this fix): Promotion 1 is applied to Product A and Product B; this happens because the total discount of Promotion 1 is greater than the total discount of Promotion 2 and OFBiz applies promotions sorted by discount (desc) ** Summary Product Price Discount Subtotal A $20 $4 (20% discount) $16 B $40 $8 (20% discount) $32 Total Adjustment: $12 The new solution fixes this issue and similar ones. Here are some details about the new algorithm. Overview of the flow: 1) run the promotions one by one in a test run 2) collect the ProductPromoUse information 3) sort them by weight (i.e. the ratio between the discount and the value of the products discounted) 4) execute the ProductPromoUse in the given order In order to understand this solution, and specifically the changes to ProductPromoWorker.java, there is an important concept to consider: one Promotion can generate more than one ProductPromoUseInfo objects. For example if I have 2 units of WG-1111 in the cart (in one cart item) and I have the promotion “20% discount on WG-1111 and GZ-1000” then the system will create TWO ProductPromoUseInfo objects both associated to the same promotion one for each of the 2 units discounted. Similarly if I had two lines: 2 units of WG-1111 and 1 unit of GZ-1000 I would get 3 ProductPromoUseInfo objects 2 objects for WG-1111 and 1 object for GZ-1000 We can sort these ProductPromoUseInfo objects based on their weight (i.e. the ratio between the discount and the value of the products discounted) in desc order and now we have a sorted list of ProductPromoUseInfo objects ready to be executed However we only want to execute each of them once and for this reason we set (in memory, not in the DB) the useLimitPerOrder to 1 in the first ProductPromoUseInfo of a given promotion and then to 2 if the same ProductPromoUseInfo is associated to the same promotion etc... in this way the end result is that the system will generate, as we desire, ONE ProductPromoUseInfo only for each of the ProductPromoUseInfo in the list. Here is an example: we have 2 promotions: PROMO A PROMO B After test run: ProductPromoUseInfo - PROMO A - #1 - weight 0.3 ProductPromoUseInfo - PROMO A - #2 - weight 0.3 ProductPromoUseInfo - PROMO B - #1 - weight 0.4 After sorting: ProductPromoUseInfo - PROMO B - #1 - weight 0.4 ProductPromoUseInfo - PROMO A - #1 - weight 0.3 ProductPromoUseInfo - PROMO A - #2 - weight 0.3 Based on this we create a list (sortedExplodedProductPromoList) of ProductPromo: PROMO B - with useLimitPerOrder=1 PROMO A - with useLimitPerOrder=1 PROMO A - with useLimitPerOrder=2 When we apply these to the cart we get the following results: PROMO B - with useLimitPerOrder=1 APPLIED PROMO A - with useLimitPerOrder=1 APPLIED PROMO A - with useLimitPerOrder=2 NOT APPLIED (because PROMO B used the item) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1554265 13f79535-47bb-0310-9956-ffa450edef68
This completes "set different ports for testing in a CI environment (e.g. Jenkins)" https://issues.apache.org/jira/browse/OFBIZ-4794
Welcome to Apache OFBiz!
All you need to run OFBiz is a 1.6 (version 6) JDK
(not just the JRE, the full JDK).
http://java.sun.com/javase/downloads/index.jsp
You can load the demo data (strongly advised if you are new to
OFBiz) with the following command on the command line
from the OFBiz home folder (in Unix-like operating systems
type "./ant" rather than "ant"):
ant load-demo
Then start OFBiz:
ant start
(or "java -Xms128M -Xmx512M -XX:MaxPermSize=128m -jar ofbiz.jar")
Once OFBiz starts, you can look at the demo storefront at:
http://localhost:8080/ecommerce
and the administration interface at:
https://localhost:8443/webtools
You can log in with the user "admin" and password "ofbiz".
To stop OFBiz:
ant stop
To get the list of available commands:
ant -p
You will also find several platform dependent scripts in the
"tools" folder (for example for Windows and Unix-like operating
systems, the startup scripts are startofbiz.bat and startofbiz.sh).
Note that the default configuration uses an embedded Java database
(Apache Derby) and embedded application server components such as
Tomcat, Geronimo (transaction manager), etc.
For more details about OFBiz please visit the OFBiz Documentation page:
http://ofbiz.apache.org/documentation.html
In this page you will find links to useful guides such as:
* "Demo and Test Setup Guide"
* "Basic Production Setup Guide"
* "A Beginners Development Guide"
If you would like to get in touch with the OFBiz community of users and
developers, the following page will help to get started:
http://ofbiz.apache.org/community.html
Enjoy!
=========================================================================
== BIS Crypto TSU exception notice ==
=========================================================================
This distribution includes cryptographic software. The country in
which you currently reside may have restrictions on the import,
possession, use, and/or re-export to another country, of
encryption software. BEFORE using any encryption software, please
check your country's laws, regulations and policies concerning the
import, possession, or use, and re-export of encryption software, to
see if this is permitted. See <http://www.wassenaar.org/> for more
information.
The U.S. Government Department of Commerce, Bureau of Industry and
Security (BIS), has classified this software as Export Commodity
Control Number (ECCN) 5D002.C.1, which includes information security
software using or performing cryptographic functions with asymmetric
algorithms. The form and manner of this Apache Software Foundation
distribution makes it eligible for export under the License Exception
ENC Technology Software Unrestricted (TSU) exception (see the BIS
Export Administration Regulations, Section 740.13) for both object
code and source code.
The following provides more details on the included cryptographic
software:
* Various classes in OFBiz, including DesCrypt, HashCrypt, and
BlowFishCrypt use libraries from the Sun Java JDK API including
java.security.* and javax.crypto.* (the JCE, Java Cryptography
Extensions API)
* Other classes such as HttpClient and various related ones use
the JSSE (Java Secure Sockets Extension) API
=========================================================================
Languages
Java
66.9%
FreeMarker
15.3%
Groovy
10.5%
JavaScript
4.6%
CSS
2.1%
Other
0.4%