Author: mbrohl
Date: Sat Sep 19 11:06:41 2015
New Revision: 1703980
URL: http://svn.apache.org/viewvc?rev=1703980&view=rev
Log:
Applied patch for OFBIZ-6629: Duplicate calculation and typo in
ShoppingCart.getGrandTotal().
This removes duplicate code, fixes a methode name typo and adds type safety to
an iterator.
Thanks Martin Becker for spotting this and providing the patch.
Modified:
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
Modified:
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1703980&r1=1703979&r2=1703980&view=diff
==============================================================================
---
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
(original)
+++
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
Sat Sep 19 11:06:41 2015
@@ -2732,11 +2732,8 @@ public class ShoppingCart implements Ite
/** Returns the total from the cart, including tax/shipping. */
public BigDecimal getGrandTotal() {
// sales tax and shipping are not stored as adjustments but rather as
part of the ship group
- // Debug.logInfo("Subtotal:" + this.getSubTotal() + " Shipping:" +
this.getTotalShipping() + "SalesTax: "+ this.getTotalSalesTax() + " others: " +
this.getOrderOtherAdjustmentTotal(),module);
- BigDecimal grandTotal =
this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal());
- // Debug.logInfo("Grand Total before rounding:" + grandTotal, module);
- grandTotal =
this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()).add(this.getOrderGlobalAdjusments());
- return grandTotal;
+ // Debug.logInfo("Subtotal:" + this.getSubTotal() + " Shipping:" +
this.getTotalShipping() + "SalesTax: "+ this.getTotalSalesTax() + " others: " +
this.getOrderOtherAdjustmentTotal() + " global: " +
this.getOrderGlobalAdjustments(), module);
+ return
this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()).add(this.getOrderGlobalAdjustments());
}
public BigDecimal getDisplaySubTotal() {
@@ -2746,7 +2743,7 @@ public class ShoppingCart implements Ite
}
return itemsTotal;
}
- public BigDecimal getOrderGlobalAdjusments() {
+ public BigDecimal getOrderGlobalAdjustments() {
List cartAdjustments = this.getAdjustments();
List tempAdjustmentsList = FastList.newInstance();
if (cartAdjustments != null) {
@@ -2775,7 +2772,7 @@ public class ShoppingCart implements Ite
/** Returns the total from the cart, including tax/shipping. */
public BigDecimal getDisplayGrandTotal() {
- return
this.getDisplaySubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()).add(this.getOrderGlobalAdjusments());
+ return
this.getDisplaySubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()).add(this.getOrderGlobalAdjustments());
}
public BigDecimal getOrderOtherAdjustmentTotal() {
@@ -4907,7 +4904,7 @@ public class ShoppingCart implements Ite
}
if ("Y".equals(splitPayPrefPerShpGrp) &&
cart.paymentInfo.size() == 1) {
for(CartShipInfo csi : cart.getShipGroups()) {
- maxAmount =
csi.getTotal().add(cart.getOrderOtherAdjustmentTotal().add(cart.getOrderGlobalAdjusments()).divide(new
BigDecimal(cart.getShipGroupSize()),
generalRounding)).add(csi.getShipEstimate().add(csi.getTotalTax(cart)));
+ maxAmount =
csi.getTotal().add(cart.getOrderOtherAdjustmentTotal().add(cart.getOrderGlobalAdjustments()).divide(new
BigDecimal(cart.getShipGroupSize()),
generalRounding)).add(csi.getShipEstimate().add(csi.getTotalTax(cart)));
maxAmount = maxAmount.setScale(scale, rounding);
// create the OrderPaymentPreference record