Author: mor
Date: Mon May 25 06:20:48 2009
New Revision: 778302
URL:
http://svn.apache.org/viewvc?rev=778302&view=revLog:
Fix: Divide by zero error when estimatedShipCost comes out to be zero.
Applied patch from Akash Jain, part of OFBIZ-2506 (
https://issues.apache.org/jira/browse/OFBIZ-2506)
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java?rev=778302&r1=778301&r2=778302&view=diff==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingServices.java Mon May 25 06:20:48 2009
@@ -424,7 +424,11 @@
newEstimatedShipCost = newEstimatedShipCost.add(shipment.getBigDecimal("additionalShippingCharge"));
}
}
- diffInShipCostInPerc = (((newEstimatedShipCost.subtract(estimatedShipCost)).divide(estimatedShipCost, 2, rounding)).multiply(new BigDecimal(100))).abs();
+ if (estimatedShipCost.equals(ZERO)) {
+ diffInShipCostInPerc = newEstimatedShipCost;
+ } else {
+ diffInShipCostInPerc = (((newEstimatedShipCost.subtract(estimatedShipCost)).divide(estimatedShipCost, 2, rounding)).multiply(new BigDecimal(100))).abs();
+ }
if (doEstimates.compareTo(diffInShipCostInPerc) == -1) {
response.put("showWarningForm", true);
} else {