svn commit: r437453 - in /incubator/ofbiz/trunk/applications: accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java ecommerce/webapp/ecommerce/cart/showcart.ftl order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r437453 - in /incubator/ofbiz/trunk/applications: accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java ecommerce/webapp/ecommerce/cart/showcart.ftl order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

jonesde
Author: jonesde
Date: Sun Aug 27 13:24:21 2006
New Revision: 437453

URL: http://svn.apache.org/viewvc?rev=437453&view=rev
Log:
Applied patches from Eriks Dobelis for tax calc and VAT display improvements (OFBIZ-113 and OFBIZ-164); fixed a few tabs in the patch; also fixed a bug caused by the changes to getGrandTotal method in ShoppingCart.java where tax could be included twice, there is now a getDisplayGrandTotal method for the display side, and that is now used in ecommerce showcart.ftl

Modified:
    incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
    incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/showcart.ftl
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=437453&r1=437452&r2=437453&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (original)
+++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java Sun Aug 27 13:24:21 2006
@@ -30,6 +30,7 @@
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.common.geo.GeoWorker;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -68,6 +69,9 @@
 
         if (quantity == null) quantity = ONE_BASE;
         BigDecimal amount = basePrice.multiply(quantity);
+        int salestaxFinalDecimals=UtilNumber.getBigDecimalScale("salestax.final.decimals");
+        int salestaxCalcDecimals=UtilNumber.getBigDecimalScale("salestax.calc.decimals");
+        int salestaxRounding=UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
         
         BigDecimal taxTotal = ZERO_BASE;
         BigDecimal taxPercentage = ZERO_BASE;
@@ -108,7 +112,7 @@
                     taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
                     BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
                     taxTotal = taxTotal.add(adjAmount);
-                    priceWithTax = priceWithTax.add(adjAmount);
+                    priceWithTax = priceWithTax.add(adjAmount.divide(quantity,salestaxCalcDecimals,salestaxRounding));
                     Debug.logInfo("For productId [" + productId + "] added [" + adjAmount + "] of tax to price for geoId [" + taxAdjustment.getString("taxAuthGeoId") + "], new price is [" + priceWithTax + "]", module);
                 }
             }
@@ -119,8 +123,8 @@
         }
         
         // round to 2 decimal places for display/etc
-        taxTotal.setScale(2, BigDecimal.ROUND_CEILING);
-        priceWithTax.setScale(2, BigDecimal.ROUND_CEILING);
+        taxTotal.setScale(salestaxFinalDecimals, salestaxRounding);
+        priceWithTax.setScale(salestaxFinalDecimals, salestaxRounding);
         
         Map result = ServiceUtil.returnSuccess();
         result.put("taxTotal", taxTotal);

Modified: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/showcart.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/showcart.ftl?rev=437453&r1=437452&r2=437453&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/showcart.ftl (original)
+++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/showcart.ftl Sun Aug 27 13:24:21 2006
@@ -351,7 +351,7 @@
           </td>
           <td colspan="2" align="right" valign="bottom">
             <hr size="1" class="sepbar">
-            <div class="tabletext"><b><@ofbizCurrency amount=shoppingCart.getGrandTotal() isoCode=shoppingCart.getCurrency()/></b></div>
+            <div class="tabletext"><b><@ofbizCurrency amount=shoppingCart.getDisplayGrandTotal() isoCode=shoppingCart.getCurrency()/></b></div>
           </td>
         </tr>
         <#if itemsFromList>

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=437453&r1=437452&r2=437453&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sun Aug 27 13:24:21 2006
@@ -17,6 +17,7 @@
 package org.ofbiz.order.shoppingcart;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -430,7 +431,7 @@
             }
             //} catch (GenericServiceException e) {
         } catch (Exception e) {
-         Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetSuppliersForProductError", locale) + e.getMessage(), module);
+            Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetSuppliersForProductError", locale) + e.getMessage(), module);
         }
         return supplierProduct;
     }
@@ -2240,12 +2241,27 @@
     /** Returns the total from the cart, including tax/shipping. */
     public double 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);
+        // Debug.logInfo("Subtotal:" + this.getSubTotal() + " Shipping:" + this.getTotalShipping() + "SalesTax: "+ this.getTotalSalesTax() + " others: " + this.getOrderOtherAdjustmentTotal(),module);
         return this.getSubTotal() + this.getTotalShipping() + this.getTotalSalesTax() + this.getOrderOtherAdjustmentTotal();
     }
 
+    public double getDisplaySubTotal() {
+        double itemsTotal = 0.00;
+        Iterator i = iterator();
+
+        while (i.hasNext()) {
+            itemsTotal += ((ShoppingCartItem) i.next()).getDisplayItemSubTotal();
+        }
+        return itemsTotal;
+    }
+
+    /** Returns the total from the cart, including tax/shipping. */
+    public double getDisplayGrandTotal() {
+        return this.getDisplaySubTotal() + this.getTotalShipping() + this.getTotalSalesTax() + this.getOrderOtherAdjustmentTotal();
+    }
+
     public double getOrderOtherAdjustmentTotal() {
-        return OrderReadHelper.calcOrderAdjustments(this.getAdjustments(), getSubTotal(), true, false, false);
+        return OrderReadHelper.calcOrderAdjustmentsBd(this.getAdjustments(), new BigDecimal(this.getSubTotal()), true, false, false).doubleValue();
     }
 
     /** Returns the sub-total in the cart (item-total - discount). */