Author: lektran
Date: Wed Mar 19 01:11:37 2008 New Revision: 638740 URL: http://svn.apache.org/viewvc?rev=638740&view=rev Log: Fixed a bug and some incorrect rounding when calculating tax on returns. For the most part this should get rid of those $0.01 adjustments that are common on returns Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.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?rev=638740&r1=638739&r2=638740&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Wed Mar 19 01:11:37 2008 @@ -1797,7 +1797,7 @@ while (i.hasNext()) { GenericValue returnedItem = (GenericValue) i.next(); if ((returnedItem.get("returnPrice") != null) && (returnedItem.get("returnQuantity") != null)) { - returnedAmount = returnedAmount.add(returnedItem.getBigDecimal("returnPrice").multiply(returnedItem.getBigDecimal("returnQuantity"))).setScale(scale, rounding); + returnedAmount = returnedAmount.add(returnedItem.getBigDecimal("returnPrice").multiply(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding)); } Map itemAdjustmentCondition = UtilMisc.toMap("returnId", returnedItem.get("returnId"), "returnItemSeqId", returnedItem.get("returnItemSeqId")); returnedAmount = returnedAmount.add(getReturnAdjustmentTotal(orderHeader.getDelegator(), itemAdjustmentCondition)); @@ -2770,13 +2770,13 @@ Iterator adjustmentIterator = adjustments.iterator(); while (adjustmentIterator.hasNext()) { GenericValue returnAdjustment = (GenericValue) adjustmentIterator.next(); - total = total.add(setScaleByType("RET_SALES_TAX_ADJ".equals(returnAdjustment.get("returnAdjustmentTypeId")),returnAdjustment.getBigDecimal("amount"))).setScale(scale, rounding); + total = total.add(setScaleByType("RET_SALES_TAX_ADJ".equals(returnAdjustment.get("returnAdjustmentTypeId")),returnAdjustment.getBigDecimal("amount"))); } } } catch (GenericEntityException e) { Debug.logError(e, OrderReturnServices.module); } - return total.setScale(scale, rounding); + return total; } // little helper method to set the scale according to tax type Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?rev=638740&r1=638739&r2=638740&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Wed Mar 19 01:11:37 2008 @@ -2072,7 +2072,7 @@ } BigDecimal returnTotal = returnItem.getBigDecimal("returnPrice").multiply(returnItem.getBigDecimal("returnQuantity")); BigDecimal orderTotal = orderItem.getBigDecimal("quantity").multiply(orderItem.getBigDecimal("unitPrice")); - amount = getAdjustmentAmount("RET_SALES_TAX_ADJ".equals(returnAdjustmentType), returnTotal, orderTotal, orderAdjustment.getBigDecimal("amount")); + amount = getAdjustmentAmount("RET_SALES_TAX_ADJ".equals(returnAdjustmentTypeId), returnTotal, orderTotal, orderAdjustment.getBigDecimal("amount")); } else { amount = (Double) context.get("amount"); } @@ -2276,12 +2276,11 @@ String decimalsPrefix = isSalesTax ? ".calc" : ""; int decimals = UtilNumber.getBigDecimalScale(settingPrefix + decimalsPrefix + ".decimals"); int rounding = UtilNumber.getBigDecimalRoundingMode(settingPrefix + ".rounding"); - int finalDecimals = isSalesTax ? UtilNumber.getBigDecimalScale(settingPrefix + ".final.decimals") : decimals; returnTotal = returnTotal.setScale(decimals, rounding); originalTotal = originalTotal.setScale(decimals, rounding); BigDecimal newAmount = null; if (ZERO.compareTo(originalTotal) != 0) { - newAmount = returnTotal.divide(originalTotal, decimals, rounding).multiply(amount).setScale(finalDecimals, rounding); + newAmount = returnTotal.divide(originalTotal, decimals, rounding).multiply(amount).setScale(decimals, rounding); } else { newAmount = ZERO; } |
Free forum by Nabble | Edit this page |