Author: arunpatidar
Date: Fri May 20 06:52:19 2016
New Revision: 1744662
URL:
http://svn.apache.org/viewvc?rev=1744662&view=revLog:
[OFBIZ-5935] Added manually calculated sales tax while recalculating tax of order. Thanks Rohit Koushal for patch and Divesh Dutta for suggestion.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1744662&r1=1744661&r2=1744662&view=diff==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Fri May 20 06:52:19 2016
@@ -1633,6 +1633,15 @@ public class OrderServices {
}
}
+ // Accumulate the total manually added tax adjustment
+ BigDecimal totalManuallyAddedOrderTax = ZERO;
+ for (GenericValue orderTaxAdjustment : orderTaxAdjustments) {
+ String comment = orderTaxAdjustment.getString("comments");
+ if (orderTaxAdjustment.get("amount") != null && comment !=null && comment.startsWith("Added manually by")) {
+ totalManuallyAddedOrderTax = totalManuallyAddedOrderTax.add(orderTaxAdjustment.getBigDecimal("amount").setScale(taxDecimals, taxRounding));
+ }
+ }
+
// Recalculate the taxes for the order
BigDecimal totalNewOrderTax = ZERO;
OrderReadHelper orh = new OrderReadHelper(orderHeader);
@@ -1758,6 +1767,11 @@ public class OrderServices {
}
}
}
+
+ // If there is any manually added tax then add it into new system generated tax.
+ if (totalManuallyAddedOrderTax.compareTo(BigDecimal.ZERO) > 0) {
+ totalNewOrderTax = totalNewOrderTax.add(totalManuallyAddedOrderTax).setScale(taxDecimals, taxRounding);
+ }
// Determine the difference between existing and new tax adjustment totals, if any
BigDecimal orderTaxDifference = totalNewOrderTax.subtract(totalExistingOrderTax).setScale(taxDecimals, taxRounding);