Author: lektran
Date: Sat Nov 14 22:07:12 2009 New Revision: 836272 URL: http://svn.apache.org/viewvc?rev=836272&view=rev Log: Changed order tax calculation to group tax adjustments by tax auth/geo before rounding to tax final, fixes a rounding error I encountered Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutReview.groovy ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy 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?rev=836272&r1=836271&r2=836272&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sat Nov 14 22:07:12 2009 @@ -4510,18 +4510,14 @@ } public BigDecimal getTotalTax(ShoppingCart cart) { - BigDecimal taxTotal = ZERO; - for (int i = 0; i < shipTaxAdj.size(); i++) { - GenericValue v = (GenericValue) shipTaxAdj.get(i); - taxTotal = taxTotal.add(OrderReadHelper.calcOrderAdjustment(v, cart.getSubTotal())); - } - + List<GenericValue> taxAdjustments = FastList.newInstance(); + taxAdjustments.addAll(shipTaxAdj); Iterator iter = shipItemInfo.values().iterator(); - while (iter.hasNext()) { - CartShipItemInfo info = (CartShipItemInfo) iter.next(); - taxTotal = taxTotal.add(info.getItemTax(cart)); + for (CartShipItemInfo info : shipItemInfo.values()) { + taxAdjustments.addAll(info.itemTaxAdj); } - + Map<String, Object> taxByAuthority = OrderReadHelper.getOrderTaxByTaxAuthGeoAndParty(taxAdjustments); + BigDecimal taxTotal = (BigDecimal) taxByAuthority.get("taxGrandTotal"); return taxTotal; } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutReview.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutReview.groovy?rev=836272&r1=836271&r2=836272&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutReview.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutReview.groovy Sat Nov 14 22:07:12 2009 @@ -129,8 +129,7 @@ shippingAmount = shippingAmount.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true)); context.orderShippingTotal = shippingAmount; -taxAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false); -taxAmount = taxAmount.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false)); +taxAmount = OrderReadHelper.getOrderTaxByTaxAuthGeoAndParty(orderAdjustments).taxGrandTotal; context.orderTaxTotal = taxAmount; context.orderGrandTotal = OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy?rev=836272&r1=836271&r2=836272&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy Sat Nov 14 22:07:12 2009 @@ -108,8 +108,7 @@ shippingAmount = shippingAmount.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true)); context.shippingAmount = shippingAmount; - taxAmount = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false); - taxAmount = taxAmount.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false)); + taxAmount = OrderReadHelper.getOrderTaxByTaxAuthGeoAndParty(orderAdjustments).taxGrandTotal; context.taxAmount = taxAmount; grandTotal = OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments); |
Free forum by Nabble | Edit this page |