Author: lektran
Date: Mon Jun 25 02:31:22 2007 New Revision: 550432 URL: http://svn.apache.org/viewvc?view=rev&rev=550432 Log: Applied fix from trunk for revision: 550044 Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?view=diff&rev=550432&r1=550431&r2=550432 ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Mon Jun 25 02:31:22 2007 @@ -67,7 +67,7 @@ public static final int scale = UtilNumber.getBigDecimalScale("order.decimals"); public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding"); public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals"); - public static final int taxFinalScale = UtilNumber.getBigDecimalRoundingMode("salestax.final.decimals"); + public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals"); public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding"); public static final BigDecimal ZERO = (new BigDecimal("0")).setScale(scale, rounding); public static final BigDecimal percentage = (new BigDecimal("0.01")).setScale(scale, rounding); @@ -2675,7 +2675,7 @@ Iterator itemIter = UtilMisc.toIterator(orderItems); while (itemIter != null && itemIter.hasNext()) { - result = result.add(getOrderItemAdjustmentsTotalBd((GenericValue) itemIter.next(), adjustments, includeOther, includeTax, includeShipping)); + result = result.add(getOrderItemAdjustmentsTotalBd((GenericValue) itemIter.next(), adjustments, includeOther, includeTax, includeShipping)).setScale(scale, rounding); } return result; } Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=550432&r1=550431&r2=550432 ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Mon Jun 25 02:31:22 2007 @@ -32,6 +32,7 @@ import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilNumber; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; @@ -59,6 +60,15 @@ public static final String module = ShoppingCart.class.getName(); public static final String resource_error = "OrderErrorUiLabels"; + // scales and rounding modes for BigDecimal math + public static final int scale = UtilNumber.getBigDecimalScale("order.decimals"); + public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding"); + public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals"); + public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals"); + public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding"); + public static final BigDecimal ZERO = (new BigDecimal("0")).setScale(scale, rounding); + public static final BigDecimal percentage = (new BigDecimal("0.01")).setScale(scale, rounding); + private String orderType = "SALES_ORDER"; // default orderType private String channel = "UNKNWN_SALES_CHANNEL"; // default channel enum @@ -2292,12 +2302,12 @@ /** Returns the tax amount from the cart object. */ public double getTotalSalesTax() { - double totalTax = 0.00; + BigDecimal totalTax = ZERO; for (int i = 0; i < shipInfo.size(); i++) { CartShipInfo csi = this.getShipInfo(i); - totalTax += csi.getTotalTax(this); + totalTax = totalTax.add(new BigDecimal(csi.getTotalTax(this))).setScale(taxCalcScale, taxRounding); } - return totalTax; + return totalTax.setScale(taxFinalScale, taxRounding).doubleValue(); } /** Returns the shipping amount from the cart object. */ |
Free forum by Nabble | Edit this page |