Affects Version/s: 6.1.1 CE GA2, 6.1.30 EE GA3, 6.2.0 CE M2, 6.2.0 CE M4
Fix Version/s: None
Environment:Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: febe1fa217a5859f770442405eeb455a6c72bf3a.
Tomcat 7.0 + MySQL 5. Portal 6.2.x GIT ID: 838cef246e57e86ae29e9d7d4e145c22c9ffb53a.
Steps to recreate:
1) Configure the shopping portlet to utilize insurance (flat rate or percentage)
2) Add an item to the cart with > $0 value
3) Go to Cart
4) Do NOT add insurance from the drop down
6) Look at saved order and the insurance break out does not show up (rightfully since the insure flag should be false and is checked in edit_order.jsp), but it is still used in the total calculation.
7) Look at the record in the DB for that order, and the insure field is set to 0 (note that the insurance amount is set)
This causes a few of issues:
1) When insurance is configured, the insurance is always added to the order total when viewing the order after checkout. Note that it does not seem to be added during the check out.
2) The insurance amount is not shown in the break out of the order total, but it is added to the total, causing possible confusion and mismatched order totals.
The reason this is happening:
In the com.liferay.portlet.shopping.util.ShoppingUtil.calculateTotal method, the insure flag is never checked when adding the insurance to the total, so it is added regardless of the flag (and the insurance amount is set based on the insurance configuration whether the customer selected insurance during check out or not.)
Here is the code for reference:
double total =
calculateActualSubtotal(orderItems) + order.getTax() +
order.getShipping() + order.getInsurance() -
Note that because of
LPS-30067, the flag would be incorrect anyway!