Author: lektran
Date: Thu Oct 1 12:42:18 2009 New Revision: 820632 URL: http://svn.apache.org/viewvc?rev=820632&view=rev Log: Fix to make sure all tax adjustments are including when calculating the total tax for an order, adjustments without taxAuth information were being passed over resulting in an incorrect grand total being calculated. Also changed a couple setScale calls to use the fields already defined instead of getting them all over again from UtilNumber. Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.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=820632&r1=820631&r2=820632&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 Thu Oct 1 12:42:18 2009 @@ -2850,6 +2850,8 @@ List<String> distinctTaxAuthGeoIdList = EntityUtil.getFieldListFromEntityList(orderAdjustments, "taxAuthGeoId", true); List<String> distinctTaxAuthPartyIdList = EntityUtil.getFieldListFromEntityList(orderAdjustments, "taxAuthPartyId", true); + // Keep a list of amount that have been added to make sure none are missed (if taxAuth* information is missing) + List<GenericValue> processedAdjustments = FastList.newInstance(); // For each taxAuthGeoId get and add amount from orderAdjustment for (String taxAuthGeoId : distinctTaxAuthGeoIdList) { for (String taxAuthPartyId : distinctTaxAuthPartyIdList) { @@ -2863,14 +2865,23 @@ if (amount == null) { amount = ZERO; } - totalAmount = totalAmount.add(amount).setScale(UtilNumber.getBigDecimalScale("salestax.calc.decimals"), taxRounding); + totalAmount = totalAmount.add(amount).setScale(taxCalcScale, taxRounding); + processedAdjustments.add(orderAdjustment); } - totalAmount = totalAmount.setScale(UtilNumber.getBigDecimalScale("salestax.final.decimals"), UtilNumber.getBigDecimalRoundingMode("salestax.rounding")); + totalAmount = totalAmount.setScale(taxFinalScale, taxRounding); taxByTaxAuthGeoAndPartyList.add(UtilMisc.<String, Object>toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "totalAmount", totalAmount)); taxGrandTotal = taxGrandTotal.add(totalAmount); } } } + // Process any adjustments that got missed + List<GenericValue> missedAdjustments = FastList.newInstance(); + missedAdjustments.addAll(orderAdjustments); + missedAdjustments.removeAll(processedAdjustments); + for (GenericValue orderAdjustment : missedAdjustments) { + taxGrandTotal = taxGrandTotal.add(orderAdjustment.getBigDecimal("amount").setScale(taxCalcScale, taxRounding)); + } + taxGrandTotal = taxGrandTotal.setScale(taxFinalScale, taxRounding); } Map result = FastMap.newInstance(); result.put("taxByTaxAuthGeoAndPartyList", taxByTaxAuthGeoAndPartyList); |
Free forum by Nabble | Edit this page |