You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2007/06/24 10:51:01 UTC
Re: svn commit: r550044 - in
/ofbiz/trunk/applications/order/src/org/ofbiz/order:
order/OrderReadHelper.java shoppingcart/ShoppingCart.java
I was asking myself if these changes should be put in release. I guess they should not, else Scott would have surely commited them.
But it's not easy to track such things. Using Fisheye would help a lot. This is only the beginning of such needs. I believe using
Fisheyse is almost mandatory when dealing with releases (because we can't rely totally on Scoot wonderful good will :o). Sorry, I
currently have not enough time to do the installation so I wonder if a good soul could do it ? Else I always hope to do it a some
day...
Jacques
De : <le...@apache.org>
> Author: lektran
> Date: Sat Jun 23 07:03:20 2007
> New Revision: 550044
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=550044
> Log:
> Fixed a sales order rounding bug, reported by Jacopo Cappellato
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
>
> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?view=diff&rev=550044&r1=550043&r2=550044
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Sat Jun 23 07:03:20 2007
> @@ -68,7 +68,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);
> @@ -2677,7 +2677,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/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
> URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=550044&r1=550043&r2=550044
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sat Jun 23 07:03:20 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;
> @@ -60,6 +61,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
>
> @@ -2357,12 +2367,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. */
>