svn commit: r731851 [20/22] - in /ofbiz/trunk: applications/accounting/entitydef/ applications/accounting/script/org/ofbiz/accounting/finaccount/ applications/accounting/script/org/ofbiz/accounting/fixedasset/ applications/accounting/script/org/ofbiz/a...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r731851 [20/22] - in /ofbiz/trunk: applications/accounting/entitydef/ applications/accounting/script/org/ofbiz/accounting/finaccount/ applications/accounting/script/org/ofbiz/accounting/fixedasset/ applications/accounting/script/org/ofbiz/a...

jonesde
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Mon Jan  5 23:13:36 2009
@@ -91,13 +91,13 @@
         estimate.set("featurePercent", context.get("featurePercent"));
         estimate.set("featurePrice", context.get("featurePrice"));
         estimate.set("weightBreakId", context.get("weightBreakId"));
-        estimate.set("weightUnitPrice", (Double)context.get("wprice"));
+        estimate.set("weightUnitPrice", (BigDecimal)context.get("wprice"));
         estimate.set("weightUomId", context.get("wuom"));
         estimate.set("quantityBreakId", context.get("quantityBreakId"));
-        estimate.set("quantityUnitPrice", (Double)context.get("qprice"));
+        estimate.set("quantityUnitPrice", (BigDecimal)context.get("qprice"));
         estimate.set("quantityUomId", context.get("quom"));
         estimate.set("priceBreakId", context.get("priceBreakId"));
-        estimate.set("priceUnitPrice", (Double)context.get("pprice"));
+        estimate.set("priceUnitPrice", (BigDecimal)context.get("pprice"));
         estimate.set("priceUomId", context.get("puom"));
         storeAll.add(estimate);
 
@@ -165,11 +165,11 @@
 
     private static boolean applyQuantityBreak(Map context, Map<String, Object> result, List<GenericValue> storeAll, GenericDelegator delegator,
                                               GenericValue estimate, String prefix, String breakType, String breakTypeString) {
-        Double min = (Double) context.get(prefix + "min");
-        Double max = (Double) context.get(prefix + "max");
+        BigDecimal min = (BigDecimal) context.get(prefix + "min");
+        BigDecimal max = (BigDecimal) context.get(prefix + "max");
         if (min != null || max != null) {
             if (min != null && max != null) {
-                if (min.doubleValue() <= max.doubleValue() || max.doubleValue() == 0) {
+                if (min.compareTo(max) <= 0 || max.compareTo(BigDecimal.ZERO) == 0) {
                     try {
                         String newSeqId = delegator.getNextSeqId("QuantityBreak");
                         GenericValue weightBreak = delegator.makeValue("QuantityBreak");
@@ -178,7 +178,7 @@
                         weightBreak.set("fromQuantity", min);
                         weightBreak.set("thruQuantity", max);
                         estimate.set(breakType + "BreakId", newSeqId);
-                        estimate.set(breakType + "UnitPrice", (Double) context.get(prefix + "price"));
+                        estimate.set(breakType + "UnitPrice", (BigDecimal) context.get(prefix + "price"));
                         if (context.containsKey(prefix + "uom")) {
                             estimate.set(breakType + "UomId", (String) context.get(prefix + "uom"));
                         }
@@ -222,22 +222,22 @@
         //Map shippableFeatureMap = (Map) context.get("shippableFeatureMap");
         //List shippableItemSizes = (List) context.get("shippableItemSizes");
 
-        Double shippableTotal = (Double) context.get("shippableTotal");
-        Double shippableQuantity = (Double) context.get("shippableQuantity");
-        Double shippableWeight = (Double) context.get("shippableWeight");
-        Double initialEstimateAmt = (Double) context.get("initialEstimateAmt");
+        BigDecimal shippableTotal = (BigDecimal) context.get("shippableTotal");
+        BigDecimal shippableQuantity = (BigDecimal) context.get("shippableQuantity");
+        BigDecimal shippableWeight = (BigDecimal) context.get("shippableWeight");
+        BigDecimal initialEstimateAmt = (BigDecimal) context.get("initialEstimateAmt");
 
         if (shippableTotal == null) {
-            shippableTotal = Double.valueOf(0.00);
+            shippableTotal = BigDecimal.ZERO;
         }
         if (shippableQuantity == null) {
-            shippableQuantity = Double.valueOf(0.00);
+            shippableQuantity = BigDecimal.ZERO;
         }
         if (shippableWeight == null) {
-            shippableWeight = Double.valueOf(0.00);
+            shippableWeight = BigDecimal.ZERO;
         }
         if (initialEstimateAmt == null) {
-            initialEstimateAmt = Double.valueOf(0.00);
+            initialEstimateAmt = BigDecimal.ZERO;
         }
 
         // get the ShipmentCostEstimate(s)
@@ -259,13 +259,13 @@
             return ServiceUtil.returnError("Unable to locate estimates from database");
         }
         if (estimates == null || estimates.size() < 1) {
-            if (initialEstimateAmt.doubleValue() == 0.00) {
+            if (initialEstimateAmt.compareTo(BigDecimal.ZERO) == 0) {
                 Debug.logWarning("Using the passed context : " + context, module);
                 Debug.logWarning("No shipping estimates found; the shipping amount returned is 0!", module);
             }
 
             Map<String, Object> respNow = ServiceUtil.returnSuccess();
-            respNow.put("shippingEstimateAmount", Double.valueOf(0.00));
+            respNow.put("shippingEstimateAmount", BigDecimal.ZERO);
             return respNow;
         }
 
@@ -340,41 +340,41 @@
 
                     if (wv != null) {
                         useWeight = true;
-                        double min = 0.0001;
-                        double max = 0.0001;
+                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
+                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);
 
                         try {
-                            min = wv.getDouble("fromQuantity").doubleValue();
-                            max = wv.getDouble("thruQuantity").doubleValue();
+                            min = wv.getBigDecimal("fromQuantity");
+                            max = wv.getBigDecimal("thruQuantity");
                         } catch (Exception e) {
                         }
-                        if (shippableWeight.doubleValue() >= min && (max == 0 || shippableWeight.doubleValue() <= max))
+                        if (shippableWeight.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableWeight.compareTo(max) <= 0))
                             weightValid = true;
                     }
                     if (qv != null) {
                         useQty = true;
-                        double min = 0.0001;
-                        double max = 0.0001;
+                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
+                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);
 
                         try {
-                            min = qv.getDouble("fromQuantity").doubleValue();
-                            max = qv.getDouble("thruQuantity").doubleValue();
+                            min = qv.getBigDecimal("fromQuantity");
+                            max = qv.getBigDecimal("thruQuantity");
                         } catch (Exception e) {
                         }
-                        if (shippableQuantity.doubleValue() >= min && (max == 0 || shippableQuantity.doubleValue() <= max))
+                        if (shippableQuantity.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 0))
                             qtyValid = true;
                     }
                     if (pv != null) {
                         usePrice = true;
-                        double min = 0.0001;
-                        double max = 0.0001;
+                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
+                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);
 
                         try {
-                            min = pv.getDouble("fromQuantity").doubleValue();
-                            max = pv.getDouble("thruQuantity").doubleValue();
+                            min = pv.getBigDecimal("fromQuantity");
+                            max = pv.getBigDecimal("thruQuantity");
                         } catch (Exception e) {
                         }
-                        if (shippableTotal.doubleValue() >= min && (max == 0 || shippableTotal.doubleValue() <= max))
+                        if (shippableTotal.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableTotal.compareTo(max) <= 0))
                             priceValid = true;
                     }
                     // Now check the tests.
@@ -390,26 +390,26 @@
         }
 
         // make the shippable item size/feature objects
-        List<Double> shippableItemSizes = FastList.newInstance();
-        Map<String, Double> shippableFeatureMap = FastMap.newInstance();
+        List<BigDecimal> shippableItemSizes = FastList.newInstance();
+        Map<String, BigDecimal> shippableFeatureMap = FastMap.newInstance();
         if (shippableItemInfo != null) {
             for (Map<String, Object> itemMap: shippableItemInfo) {
                 // add the item sizes
-                Double itemSize = (Double) itemMap.get("size");
+                BigDecimal itemSize = (BigDecimal) itemMap.get("size");
                 if (itemSize != null) {
                     shippableItemSizes.add(itemSize);
                 }
 
                 // add the feature quantities
-                Double quantity = (Double) itemMap.get("quantity");
+                BigDecimal quantity = (BigDecimal) itemMap.get("quantity");
                 Set<String> featureSet = UtilGenerics.checkSet(itemMap.get("featureSet"));
                 if (UtilValidate.isNotEmpty(featureSet)) {
                     for (String featureId: featureSet) {
-                        Double featureQuantity = shippableFeatureMap.get(featureId);
+                        BigDecimal featureQuantity = (BigDecimal) shippableFeatureMap.get(featureId);
                         if (featureQuantity == null) {
-                            featureQuantity = Double.valueOf(0.00);
+                            featureQuantity = BigDecimal.ZERO;
                         }
-                        featureQuantity = Double.valueOf(featureQuantity.doubleValue() + quantity.doubleValue());
+                        featureQuantity = featureQuantity.add(quantity);
                         shippableFeatureMap.put(featureId, featureQuantity);
                     }
                 }
@@ -461,60 +461,60 @@
         //Debug.log("[ShippingEvents.getShipEstimate] Working with estimate [" + estimateIndex + "]: " + estimate, module);
 
         // flat fees
-        double orderFlat = 0.00;
-        if (estimate.getDouble("orderFlatPrice") != null)
-            orderFlat = estimate.getDouble("orderFlatPrice").doubleValue();
-
-        double orderItemFlat = 0.00;
-        if (estimate.getDouble("orderItemFlatPrice") != null)
-            orderItemFlat = estimate.getDouble("orderItemFlatPrice").doubleValue();
-
-        double orderPercent = 0.00;
-        if (estimate.getDouble("orderPricePercent") != null)
-            orderPercent = estimate.getDouble("orderPricePercent").doubleValue();
+        BigDecimal orderFlat = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("orderFlatPrice") != null)
+            orderFlat = estimate.getBigDecimal("orderFlatPrice");
+
+        BigDecimal orderItemFlat = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("orderItemFlatPrice") != null)
+            orderItemFlat = estimate.getBigDecimal("orderItemFlatPrice");
+
+        BigDecimal orderPercent = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("orderPricePercent") != null)
+            orderPercent = estimate.getBigDecimal("orderPricePercent");
 
-        double itemFlatAmount = shippableQuantity.doubleValue() * orderItemFlat;
-        double orderPercentage = shippableTotal.doubleValue() * (orderPercent / 100);
+        BigDecimal itemFlatAmount = shippableQuantity.multiply(orderItemFlat);
+        BigDecimal orderPercentage = shippableTotal.multiply(orderPercent.movePointLeft(2));
 
         // flat total
-        double flatTotal = orderFlat + itemFlatAmount + orderPercentage;        
+        BigDecimal flatTotal = orderFlat.add(itemFlatAmount).add(orderPercentage);        
 
         // spans
-        double weightUnit = 0.00;
-        if (estimate.getDouble("weightUnitPrice") != null)
-            weightUnit = estimate.getDouble("weightUnitPrice").doubleValue();
-
-        double qtyUnit = 0.00;
-        if (estimate.getDouble("quantityUnitPrice") != null)
-            qtyUnit = estimate.getDouble("quantityUnitPrice").doubleValue();
-
-        double priceUnit = 0.00;
-        if (estimate.getDouble("priceUnitPrice") != null)
-            priceUnit = estimate.getDouble("priceUnitPrice").doubleValue();
-
-        double weightAmount = shippableWeight.doubleValue() * weightUnit;
-        double quantityAmount = shippableQuantity.doubleValue() * qtyUnit;
-        double priceAmount = shippableTotal.doubleValue() * priceUnit;
+        BigDecimal weightUnit = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("weightUnitPrice") != null)
+            weightUnit = estimate.getBigDecimal("weightUnitPrice");
+
+        BigDecimal qtyUnit = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("quantityUnitPrice") != null)
+            qtyUnit = estimate.getBigDecimal("quantityUnitPrice");
+
+        BigDecimal priceUnit = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("priceUnitPrice") != null)
+            priceUnit = estimate.getBigDecimal("priceUnitPrice");
+
+        BigDecimal weightAmount = shippableWeight.multiply(weightUnit);
+        BigDecimal quantityAmount = shippableQuantity.multiply(qtyUnit);
+        BigDecimal priceAmount = shippableTotal.multiply(priceUnit);
 
         // span total
-        double spanTotal = weightAmount + quantityAmount + priceAmount;
+        BigDecimal spanTotal = weightAmount.add(quantityAmount).add(priceAmount);
 
         // feature surcharges
-        double featureSurcharge = 0.00;
+        BigDecimal featureSurcharge = BigDecimal.ZERO;
         String featureGroupId = estimate.getString("productFeatureGroupId");
-        Double featurePercent = estimate.getDouble("featurePercent");
-        Double featurePrice = estimate.getDouble("featurePrice");
+        BigDecimal featurePercent = estimate.getBigDecimal("featurePercent");
+        BigDecimal featurePrice = estimate.getBigDecimal("featurePrice");
         if (featurePercent == null) {
-            featurePercent = Double.valueOf(0);
+            featurePercent = BigDecimal.ZERO;
         }
         if (featurePrice == null) {
-            featurePrice = Double.valueOf(0.00);
+            featurePrice = BigDecimal.ZERO;
         }
 
         if (featureGroupId != null && featureGroupId.length() > 0 && shippableFeatureMap != null) {
-            for (Map.Entry<String, Double> entry: shippableFeatureMap.entrySet()) {
+            for (Map.Entry<String, BigDecimal> entry: shippableFeatureMap.entrySet()) {
                 String featureId = entry.getKey();
-                Double quantity = entry.getValue();
+                BigDecimal quantity = entry.getValue();
                 GenericValue appl = null;
                 Map<String, String> fields = UtilMisc.toMap("productFeatureGroupId", featureGroupId, "productFeatureId", featureId);
                 try {
@@ -525,43 +525,43 @@
                     Debug.logError(e, "Unable to lookup feature/group" + fields, module);
                 }
                 if (appl != null) {
-                    featureSurcharge += (shippableTotal.doubleValue() * (featurePercent.doubleValue() / 100) * quantity.doubleValue());
-                    featureSurcharge += featurePrice.doubleValue() * quantity.doubleValue();
+                    featureSurcharge = featureSurcharge.add( shippableTotal.multiply( featurePercent.movePointLeft(2) ).multiply(quantity) );
+                    featureSurcharge = featureSurcharge.add(featurePrice.multiply(quantity));
                 }
             }
         }
 
         // size surcharges
-        double sizeSurcharge = 0.00;
-        Double sizeUnit = estimate.getDouble("oversizeUnit");
-        Double sizePrice = estimate.getDouble("oversizePrice");
-        if (sizeUnit != null && sizeUnit.doubleValue() > 0) {
+        BigDecimal sizeSurcharge = BigDecimal.ZERO;
+        BigDecimal sizeUnit = estimate.getBigDecimal("oversizeUnit");
+        BigDecimal sizePrice = estimate.getBigDecimal("oversizePrice");
+        if (sizeUnit != null && sizeUnit.compareTo(BigDecimal.ZERO) > 0) {
             if (shippableItemSizes != null) {
-                for (Double size: shippableItemSizes) {
-                    if (size != null && size.doubleValue() >= sizeUnit.doubleValue()) {
-                        sizeSurcharge += sizePrice.doubleValue();
+                for (BigDecimal size: shippableItemSizes) {
+                    if (size != null && size.compareTo(sizeUnit) >= 0) {
+                        sizeSurcharge = sizeSurcharge.add(sizePrice);
                     }
                 }
             }
         }
 
         // surcharges total
-        double surchargeTotal = featureSurcharge + sizeSurcharge;
+        BigDecimal surchargeTotal = featureSurcharge.add(sizeSurcharge);
 
         // shipping subtotal
-        double subTotal = spanTotal + flatTotal + surchargeTotal;
+        BigDecimal subTotal = spanTotal.add(flatTotal).add(surchargeTotal);
 
         // percent add-on
-        double shippingPricePercent = 0.00;
-        if (estimate.getDouble("shippingPricePercent") != null)
-            shippingPricePercent = estimate.getDouble("shippingPricePercent").doubleValue();
+        BigDecimal shippingPricePercent = BigDecimal.ZERO;
+        if (estimate.getBigDecimal("shippingPricePercent") != null)
+            shippingPricePercent = estimate.getBigDecimal("shippingPricePercent");
 
         // shipping total
-        double shippingTotal = subTotal + ((subTotal + initialEstimateAmt.doubleValue()) * (shippingPricePercent / 100));
+        BigDecimal shippingTotal = subTotal.add((subTotal.add(initialEstimateAmt)).multiply(shippingPricePercent.movePointLeft(2)));
 
         // prepare the return result
         Map<String, Object> responseResult = ServiceUtil.returnSuccess();
-        responseResult.put("shippingEstimateAmount", Double.valueOf(shippingTotal));
+        responseResult.put("shippingEstimateAmount", shippingTotal);
         return responseResult;
     }
 
@@ -619,9 +619,9 @@
             // to store list
             List<GenericValue> toStore = FastList.newInstance();
 
-            String shipGroupSeqId = shipment.getString("primaryShipGroupSeqId");
-            String orderId = shipment.getString("primaryOrderId");
-            String orderInfoKey = orderId + "/" + shipGroupSeqId;
+            //String shipGroupSeqId = shipment.getString("primaryShipGroupSeqId");
+            //String orderId = shipment.getString("primaryOrderId");
+            //String orderInfoKey = orderId + "/" + shipGroupSeqId;
 
             // make the staging records
             GenericValue stageShip = delegator.makeValue("OdbcShipmentOut");
@@ -872,20 +872,20 @@
             if (shipmentAndItems.size() == 0) return ServiceUtil.returnSuccess();
 
             // store the quantity of each product shipped in a hashmap keyed to productId
-            Map<String, Double> shippedCountMap = FastMap.newInstance();
+            Map<String, BigDecimal> shippedCountMap = FastMap.newInstance();
             for (GenericValue item: shipmentAndItems) {
-                double shippedQuantity = item.getDouble("quantity").doubleValue();
-                Double quantity = shippedCountMap.get(item.getString("productId"));
-                quantity = Double.valueOf(quantity == null ? shippedQuantity : shippedQuantity + quantity.doubleValue());
+                BigDecimal shippedQuantity = item.getBigDecimal("quantity");
+                BigDecimal quantity = shippedCountMap.get(item.getString("productId"));
+                quantity = quantity == null ? shippedQuantity : shippedQuantity.add(quantity);
                 shippedCountMap.put(item.getString("productId"), quantity);
             }
 
             // store the quantity of each product received in a hashmap keyed to productId
-            Map<String, Double> receivedCountMap = FastMap.newInstance();
+            Map<String, BigDecimal> receivedCountMap = FastMap.newInstance();
             for (GenericValue item: shipmentReceipts) {
-                double receivedQuantity = item.getDouble("quantityAccepted").doubleValue();
-                Double quantity = receivedCountMap.get(item.getString("productId"));
-                quantity = Double.valueOf(quantity == null ? receivedQuantity : receivedQuantity + quantity.doubleValue());
+                BigDecimal receivedQuantity = item.getBigDecimal("quantityAccepted");
+                BigDecimal quantity = receivedCountMap.get(item.getString("productId"));
+                quantity = quantity == null ? receivedQuantity : receivedQuantity.add(quantity);
                 receivedCountMap.put(item.getString("productId"), quantity);
             }
 
@@ -1044,10 +1044,10 @@
             
                 // Convert the value to the shipment currency, if necessary
                 GenericValue orderHeader = packageContent.getRelatedOne("OrderHeader");
-                Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", orderHeader.getString("currencyUom"), "uomIdTo", currencyUomId, "originalValue", Double.valueOf(packageContentValue.doubleValue())));
+                Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", orderHeader.getString("currencyUom"), "uomIdTo", currencyUomId, "originalValue", packageContentValue));
                 if (ServiceUtil.isError(convertUomResult)) return convertUomResult;
                 if (convertUomResult.containsKey("convertedValue")) {
-                    packageContentValue = new BigDecimal(((Double) convertUomResult.get("convertedValue")).doubleValue()).setScale(decimals, rounding);
+                    packageContentValue = ((BigDecimal) convertUomResult.get("convertedValue")).setScale(decimals, rounding);
                 }
                 
                 // Add the value of the packed item to the package's total value

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java Mon Jan  5 23:13:36 2009
@@ -20,6 +20,11 @@
 
 import java.io.IOException;
 import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -157,9 +162,9 @@
         String shipmentMethodTypeId = (String) context.get("shipmentMethodTypeId");
         String shippingContactMechId = (String) context.get("shippingContactMechId");
         List shippableItemInfo = UtilGenerics.checkList(context.get("shippableItemInfo"));
-        Double shippableTotal = (Double) context.get("shippableTotal");
-        Double shippableQuantity = (Double) context.get("shippableQuantity");
-        Double shippableWeight = (Double) context.get("shippableWeight");
+        BigDecimal shippableTotal = (BigDecimal) context.get("shippableTotal");
+        BigDecimal shippableQuantity = (BigDecimal) context.get("shippableQuantity");
+        BigDecimal shippableWeight = (BigDecimal) context.get("shippableWeight");
         
         if (shipmentMethodTypeId.equals("NO_SHIPPING")) {
             Map<String, Object> result = ServiceUtil.returnSuccess();
@@ -203,11 +208,11 @@
             }
         }
 
-        if ((shippableWeight == null) || (shippableWeight.doubleValue() <= 0.0)) {
+        if ((shippableWeight == null) || (shippableWeight.compareTo(BigDecimal.ZERO) <= 0)) {
             String tmpValue = UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.default.weight.value");
             if (tmpValue != null) {
                 try {
-                    shippableWeight = Double.valueOf(tmpValue);
+                    shippableWeight = new BigDecimal(tmpValue);
                 } catch (Exception e) {
                     return ServiceUtil.returnError("Cannot get DHL Estimate: Default shippable weight not configured (shipment.default.weight.value)");
                 }
@@ -215,11 +220,11 @@
         }
 
         // TODO: if a weight UOM is passed in, use convertUom service to convert it here
-        if (shippableWeight.doubleValue() < 1.0) {
+        if (shippableWeight.compareTo(BigDecimal.ONE) < 0) {
             Debug.logWarning("DHL Estimate: Weight is less than 1 lb, submitting DHL minimum of 1 lb for estimate.", module);
-            shippableWeight = Double.valueOf(1.0);
+            shippableWeight = BigDecimal.ONE;
         }
-        if ((dhlShipmentDetailCode.equals("G") && shippableWeight.doubleValue() > 999) || (shippableWeight.doubleValue() > 150)) {
+        if ((dhlShipmentDetailCode.equals("G") && shippableWeight.compareTo(new BigDecimal("999")) > 0) || (shippableWeight.compareTo(new BigDecimal("150")) > 0)) {
             return ServiceUtil.returnError("Cannot get DHL Estimate: Shippable weight cannot be greater than 999 lbs for ground or 150 lbs for all other services.");
         }
         String weight = (Integer.valueOf((int) shippableWeight.longValue())).toString();
@@ -362,7 +367,7 @@
                 chargeList.add(charge);
             }
         }
-        Double shippingEstimateAmount = Double.valueOf(responseTotalChargeEstimate);
+        BigDecimal shippingEstimateAmount = new BigDecimal(responseTotalChargeEstimate);
         dhlRateCodeMap.put("dateGenerated", dateGenerated);
         dhlRateCodeMap.put("serviceLevelCommitment",
                 responseServiceLevelCommitmentDescription);
@@ -586,9 +591,9 @@
 
             // get the weight from the ShipmentRouteSegment first, which overrides all later weight computations
             boolean hasBillingWeight = false;  // for later overrides
-            Double billingWeight = shipmentRouteSegment.getDouble("billingWeight");
+            BigDecimal billingWeight = shipmentRouteSegment.getBigDecimal("billingWeight");
             String billingWeightUomId = shipmentRouteSegment.getString("billingWeightUomId");
-            if ((billingWeight != null) && (billingWeight.doubleValue() > 0)) {
+            if ((billingWeight != null) && (billingWeight.compareTo(BigDecimal.ZERO) > 0)) {
                 hasBillingWeight = true;
                 if (billingWeightUomId == null) {
                     Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId,  module);
@@ -601,7 +606,7 @@
                     // try getting the weight from package instead
                     hasBillingWeight = false;
                 } else {
-                    billingWeight = (Double) results.get("convertedValue");
+                    billingWeight = (BigDecimal) results.get("convertedValue");
                 }
             }
 
@@ -609,7 +614,7 @@
             String length = null;
             String width = null;
             String height = null;
-            Double packageWeight = null;
+            BigDecimal packageWeight = null;
             for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegs) {
                 GenericValue shipmentPackage = shipmentPackageRouteSeg.getRelatedOne("ShipmentPackage");
                 GenericValue shipmentBoxType = shipmentPackage.getRelatedOne("ShipmentBoxType");
@@ -632,14 +637,14 @@
 
                 // compute total packageWeight (for now, just one package)
                 if (shipmentPackage.getString("weight") != null) {
-                    packageWeight = Double.valueOf(shipmentPackage.getString("weight"));
+                    packageWeight = new BigDecimal(shipmentPackage.getString("weight"));
                 } else {
                     // use default weight if available
                     try {
-                        packageWeight = Double.valueOf(UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.default.weight.value"));
+                        packageWeight = new BigDecimal(UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.default.weight.value"));
                     } catch (NumberFormatException ne) {
                         Debug.logWarning("Default shippable weight not configured (shipment.default.weight.value)", module);
-                        packageWeight = Double.valueOf(1.0);
+                        packageWeight = BigDecimal.ONE;
                     }
                 }
                 // convert weight
@@ -651,21 +656,21 @@
                 results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", weightUomId, "uomIdTo", DHL_WEIGHT_UOM_ID, "originalValue", packageWeight));
                 if ((results == null) || (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) || (results.get("convertedValue") == null)) {
                     Debug.logWarning("Unable to convert weights for shipmentId " + shipmentId , module);
-                    packageWeight = Double.valueOf(1.0);
+                    packageWeight = BigDecimal.ONE;
                 } else {
-                    packageWeight = (Double) results.get("convertedValue");
+                    packageWeight = (BigDecimal) results.get("convertedValue");
                 }
             }
 
             // pick which weight to use and round it
-            Double weight = null;
+            BigDecimal weight = null;
             if (hasBillingWeight) {
                 weight = billingWeight;
             } else {
                 weight = packageWeight;
             }
             // want the rounded weight as a string, so we use the "" + int shortcut
-            String roundedWeight = "" + Math.round(weight.doubleValue());
+            String roundedWeight = weight.setScale(0, BigDecimal.ROUND_HALF_UP).toPlainString();
             
             // translate shipmentMethodTypeId to DHL service code
             String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId");
@@ -838,12 +843,12 @@
         return ServiceUtil.returnSuccess("DHL Shipment Confirmed.");
     }
 
-    private static double getWeight(List<Map<String, Object>> shippableItemInfo) {
-        double totalWeight = 0;
+    private static BigDecimal getWeight(List<Map<String, Object>> shippableItemInfo) {
+        BigDecimal totalWeight = BigDecimal.ZERO;
         if (shippableItemInfo != null) {
             for (Map<String, Object> itemInfo: shippableItemInfo) {
-                double weight = ((Double) itemInfo.get("weight")).doubleValue();
-                totalWeight = totalWeight + weight;
+                BigDecimal weight = ((BigDecimal) itemInfo.get("weight"));
+                totalWeight = totalWeight.add(weight);
             }
         }
         return totalWeight;

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java Mon Jan  5 23:13:36 2009
@@ -24,7 +24,6 @@
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -373,9 +372,8 @@
     public static Map<String, Object> fedexShipRequest( DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
-        GenericValue userLogin = (GenericValue) context.get("userLogin");        
-        Locale locale = (Locale) context.get("locale");        
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        //GenericValue userLogin = (GenericValue) context.get("userLogin");        
+        //Locale locale = (Locale) context.get("locale");        
         
         String shipmentId = (String) context.get("shipmentId");
         String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
@@ -661,9 +659,9 @@
 
             // Get the weight from the ShipmentRouteSegment first, which overrides all later weight computations
             boolean hasBillingWeight = false;
-            Double billingWeight = shipmentRouteSegment.getDouble("billingWeight");
+            BigDecimal billingWeight = shipmentRouteSegment.getBigDecimal("billingWeight");
             String billingWeightUomId = shipmentRouteSegment.getString("billingWeightUomId");
-            if ((billingWeight != null) && (billingWeight.doubleValue() > 0)) {
+            if ((billingWeight != null) && (billingWeight.compareTo(BigDecimal.ZERO) > 0)) {
                 hasBillingWeight = true;
                 if (billingWeightUomId == null) {
                     Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId + ", assuming default shipment.fedex.weightUomId of " + weightUomId + " from " + shipmentPropertiesFile,  module);
@@ -679,7 +677,7 @@
                         // Try getting the weight from package instead
                         hasBillingWeight = false;
                     } else {
-                        billingWeight = (Double) results.get("convertedValue");
+                        billingWeight = (BigDecimal) results.get("convertedValue");
                     }
                 }
             }
@@ -713,13 +711,13 @@
                 packaging = carrierShipmentBoxType.getString("packagingTypeCode");
                 
                 // Determine the dimensions of the package
-                Double dimensionsLength = null;
-                Double dimensionsWidth = null;
-                Double dimensionsHeight = null;
+                BigDecimal dimensionsLength = null;
+                BigDecimal dimensionsWidth = null;
+                BigDecimal dimensionsHeight = null;
                 if (shipmentBoxType != null) {
-                    dimensionsLength = shipmentBoxType.getDouble("boxLength");
-                    dimensionsWidth = shipmentBoxType.getDouble("boxWidth");
-                    dimensionsHeight = shipmentBoxType.getDouble("boxHeight");
+                    dimensionsLength = shipmentBoxType.getBigDecimal("boxLength");
+                    dimensionsWidth = shipmentBoxType.getBigDecimal("boxWidth");
+                    dimensionsHeight = shipmentBoxType.getBigDecimal("boxHeight");
 
                     String boxDimensionsUomId = null;
                     GenericValue boxDimensionsUom = shipmentBoxType.getRelatedOne("DimensionUom");
@@ -729,38 +727,38 @@
                         Debug.logWarning("Packaging type for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId + " is missing dimensionUomId, assuming default shipment.default.dimension.uom of " + dimensionsUomId + " from " + shipmentPropertiesFile,  module);
                         boxDimensionsUomId = dimensionsUomId;
                     }
-                    if (dimensionsLength != null && dimensionsLength.doubleValue() > 0) {
+                    if (dimensionsLength != null && dimensionsLength.compareTo(BigDecimal.ZERO) > 0) {
                         if (! boxDimensionsUomId.equals(dimensionsUomId)) {
                             Map<String, Object> results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", boxDimensionsUomId, "uomIdTo", dimensionsUomId, "originalValue", dimensionsLength));
                             if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                 Debug.logWarning("Unable to convert length for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                 dimensionsLength = null;
                             } else {
-                                dimensionsLength = (Double) results.get("convertedValue");
+                                dimensionsLength = (BigDecimal) results.get("convertedValue");
                             }
                         }
                         
                     }
-                    if (dimensionsWidth != null && dimensionsWidth.doubleValue() > 0) {
+                    if (dimensionsWidth != null && dimensionsWidth.compareTo(BigDecimal.ZERO) > 0) {
                         if (! boxDimensionsUomId.equals(dimensionsUomId)) {
                             Map<String, Object> results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", boxDimensionsUomId, "uomIdTo", dimensionsUomId, "originalValue", dimensionsWidth));
                             if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                 Debug.logWarning("Unable to convert width for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                 dimensionsWidth = null;
                             } else {
-                                dimensionsWidth = (Double) results.get("convertedValue");
+                                dimensionsWidth = (BigDecimal) results.get("convertedValue");
                             }
                         }
                         
                     }
-                    if (dimensionsHeight != null && dimensionsHeight.doubleValue() > 0) {
+                    if (dimensionsHeight != null && dimensionsHeight.compareTo(BigDecimal.ZERO) > 0) {
                         if (! boxDimensionsUomId.equals(dimensionsUomId)) {
                             Map<String, Object> results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", boxDimensionsUomId, "uomIdTo", dimensionsUomId, "originalValue", dimensionsHeight));
                             if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                 Debug.logWarning("Unable to convert height for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                 dimensionsHeight = null;
                             } else {
-                                dimensionsHeight = (Double) results.get("convertedValue");
+                                dimensionsHeight = (BigDecimal) results.get("convertedValue");
                             }
                         }
                         
@@ -768,18 +766,18 @@
                 }
 
                 // Determine the package weight (possibly overriden by route segment billing weight)
-                Double packageWeight = null;
+                BigDecimal packageWeight = null;
                 if (! hasBillingWeight) {
                     if (UtilValidate.isNotEmpty(shipmentPackage.getString("weight"))) {
-                        packageWeight = shipmentPackage.getDouble("weight");
+                        packageWeight = shipmentPackage.getBigDecimal("weight");
                     } else {
 
                         // Use default weight if available
                         try {
-                            packageWeight = Double.valueOf(UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.default.weight.value"));
+                            packageWeight = new BigDecimal(UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.default.weight.value"));
                         } catch (NumberFormatException ne) {
                             Debug.logWarning("Default shippable weight not configured (shipment.default.weight.value), assuming 1.0" + weightUomId , module);
-                            packageWeight = Double.valueOf(1.0);
+                            packageWeight = BigDecimal.ONE;
                         }
                     }
                     
@@ -794,12 +792,12 @@
                         if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                             ServiceUtil.returnError("Unable to convert weight for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId);
                         } else {
-                            packageWeight = (Double) results.get("convertedValue");
+                            packageWeight = (BigDecimal) results.get("convertedValue");
                         }
                     }
                 }
-                Double weight = hasBillingWeight ? billingWeight : packageWeight;
-                if (weight == null || weight.doubleValue() < 0) {
+                BigDecimal weight = hasBillingWeight ? billingWeight : packageWeight;
+                if (weight == null || weight.compareTo(BigDecimal.ZERO) < 0) {
                     ServiceUtil.returnError("Unable to determine weight for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId);
                 }
                 
@@ -808,15 +806,15 @@
                 shipRequestContext.put("DropoffType", dropoffType);
                 shipRequestContext.put("Packaging", packaging);
                 if (UtilValidate.isNotEmpty(dimensionsUomId) &&
-                    dimensionsLength != null && Math.round(dimensionsLength.doubleValue()) > 0 &&
-                    dimensionsWidth != null && Math.round(dimensionsWidth.doubleValue()) > 0   &&
-                    dimensionsHeight != null && Math.round(dimensionsHeight.doubleValue()) > 0 ) {
+                    dimensionsLength != null && dimensionsLength.setScale(0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.ZERO) > 0 &&
+                    dimensionsWidth != null && dimensionsWidth.setScale(0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.ZERO) > 0   &&
+                    dimensionsHeight != null && dimensionsHeight.setScale(0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.ZERO) > 0 ) {
                         shipRequestContext.put("DimensionsUnits", dimensionsUomId.equals("LEN_in") ? "IN" : "CM");
-                        shipRequestContext.put("DimensionsLength", "" + Math.round(dimensionsLength.doubleValue()));
-                        shipRequestContext.put("DimensionsWidth", "" + Math.round(dimensionsWidth.doubleValue()));
-                        shipRequestContext.put("DimensionsHeight", "" + Math.round(dimensionsHeight.doubleValue()));
+                        shipRequestContext.put("DimensionsLength", dimensionsLength.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
+                        shipRequestContext.put("DimensionsWidth", dimensionsWidth.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
+                        shipRequestContext.put("DimensionsHeight", dimensionsHeight.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
                 }
-                shipRequestContext.put("Weight", new BigDecimal(weight.doubleValue()).setScale(1, BigDecimal.ROUND_UP).toString());
+                shipRequestContext.put("Weight", weight.setScale(1, BigDecimal.ROUND_UP).toString());
             }
         
             StringWriter outWriter = new StringWriter();

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java Mon Jan  5 23:13:36 2009
@@ -22,6 +22,8 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -82,6 +84,7 @@
     }
     public static final int decimals = UtilNumber.getBigDecimalScale("order.decimals");
     public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final MathContext generalRounding = new MathContext(10);
 
     public static Map<String, Object> upsShipmentConfirm(DispatchContext dctx, Map<String, ? extends Object> context) {
         Map<String, Object> result = FastMap.newInstance();
@@ -426,9 +429,9 @@
                         // I guess we'll default to inches...
                         UtilXml.addChildElementValue(unitOfMeasurementElement, "Code", "IN", shipmentConfirmRequestDoc);
                     }
-                    Double boxLength = shipmentBoxType.getDouble("boxLength");
-                    Double boxWidth = shipmentBoxType.getDouble("boxWidth");
-                    Double boxHeight = shipmentBoxType.getDouble("boxHeight");
+                    BigDecimal boxLength = shipmentBoxType.getBigDecimal("boxLength");
+                    BigDecimal boxWidth = shipmentBoxType.getBigDecimal("boxWidth");
+                    BigDecimal boxHeight = shipmentBoxType.getBigDecimal("boxHeight");
                     UtilXml.addChildElementValue(dimensionsElement, "Length", UtilValidate.isNotEmpty(boxLength) ? ""+boxLength.intValue() : "", shipmentConfirmRequestDoc);
                     UtilXml.addChildElementValue(dimensionsElement, "Width", UtilValidate.isNotEmpty(boxWidth) ? ""+boxWidth.intValue() : "", shipmentConfirmRequestDoc);
                     UtilXml.addChildElementValue(dimensionsElement, "Height", UtilValidate.isNotEmpty(boxHeight) ? ""+boxHeight.intValue() : "", shipmentConfirmRequestDoc);
@@ -447,7 +450,7 @@
                 if (shipmentPackage.getString("weight") == null) {
                     return ServiceUtil.returnError("Weight value not found for ShipmentRouteSegment with shipmentId " + shipmentId + ", shipmentRouteSegmentId " + shipmentRouteSegmentId + ", and shipmentPackageSeqId " + shipmentPackage.getString("shipmentPackageSeqId"));
                 }
-                Double boxWeight = shipmentPackage.getDouble("weight");
+                BigDecimal boxWeight = shipmentPackage.getBigDecimal("weight");
                 UtilXml.addChildElementValue(packageWeightElement, "Weight", UtilValidate.isNotEmpty(boxWeight) ? ""+boxWeight.intValue() : "", shipmentConfirmRequestDoc);
                 
                 Element referenceNumberElement = UtilXml.addChildElement(packageElement, "ReferenceNumber", shipmentConfirmRequestDoc);
@@ -492,10 +495,10 @@
                     BigDecimal packageValue = (BigDecimal) getPackageValueResult.get("packageValue");
                     
                     // Convert the value of the COD surcharge to the shipment currency, if necessary
-                    Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", codSurchargeCurrencyUomId, "uomIdTo", currencyCode, "originalValue", Double.valueOf(codSurchargePackageAmount.doubleValue())));
+                    Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", codSurchargeCurrencyUomId, "uomIdTo", currencyCode, "originalValue", codSurchargePackageAmount));
                     if (ServiceUtil.isError(convertUomResult)) return convertUomResult;
                     if (convertUomResult.containsKey("convertedValue")) {
-                        codSurchargePackageAmount = new BigDecimal(((Double) convertUomResult.get("convertedValue")).doubleValue()).setScale(decimals, rounding);
+                        codSurchargePackageAmount = ((BigDecimal) convertUomResult.get("convertedValue")).setScale(decimals, rounding);
                     }
                     
                     // Add the amount of the surcharge for the package, if the surcharge should be on all packages or the first and this is the first package
@@ -607,12 +610,12 @@
             
         // handle Response element info
         Element responseElement = UtilXml.firstChildElement(shipmentConfirmResponseElement, "Response");
-        Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
-        String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
-        String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
+        //Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
+        //String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
+        //String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
 
         String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
-        String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
+        //String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
         List<Object> errorList = FastList.newInstance();
         UpsServices.handleErrors(responseElement, errorList);
 
@@ -621,11 +624,11 @@
             Element shipmentChargesElement = UtilXml.firstChildElement(shipmentConfirmResponseElement, "ShipmentCharges");
 
             Element transportationChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "TransportationCharges");
-            String transportationCurrencyCode = UtilXml.childElementValue(transportationChargesElement, "CurrencyCode");
+            //String transportationCurrencyCode = UtilXml.childElementValue(transportationChargesElement, "CurrencyCode");
             String transportationMonetaryValue = UtilXml.childElementValue(transportationChargesElement, "MonetaryValue");
             
             Element serviceOptionsChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "ServiceOptionsCharges");
-            String serviceOptionsCurrencyCode = UtilXml.childElementValue(serviceOptionsChargesElement, "CurrencyCode");
+            //String serviceOptionsCurrencyCode = UtilXml.childElementValue(serviceOptionsChargesElement, "CurrencyCode");
             String serviceOptionsMonetaryValue = UtilXml.childElementValue(serviceOptionsChargesElement, "MonetaryValue");
 
             Element totalChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "TotalCharges");
@@ -642,21 +645,21 @@
             }
             
             try {
-                shipmentRouteSegment.set("actualTransportCost", Double.valueOf(transportationMonetaryValue));
+                shipmentRouteSegment.set("actualTransportCost", new BigDecimal(transportationMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the transportationMonetaryValue [" + transportationMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
                 errorList.add(excErrMsg);
             }
             try {
-                shipmentRouteSegment.set("actualServiceCost", Double.valueOf(serviceOptionsMonetaryValue));
+                shipmentRouteSegment.set("actualServiceCost", new BigDecimal(serviceOptionsMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the serviceOptionsMonetaryValue [" + serviceOptionsMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
                 errorList.add(excErrMsg);
             }
             try {
-                shipmentRouteSegment.set("actualCost", Double.valueOf(totalMonetaryValue));
+                shipmentRouteSegment.set("actualCost", new BigDecimal(totalMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the totalMonetaryValue [" + totalMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
@@ -669,7 +672,7 @@
             String billingWeightUnitOfMeasurement = UtilXml.childElementValue(billingWeightUnitOfMeasurementElement, "Code");
             String billingWeight = UtilXml.childElementValue(billingWeightElement, "Weight");
             try {
-                shipmentRouteSegment.set("billingWeight", Double.valueOf(billingWeight));
+                shipmentRouteSegment.set("billingWeight", new BigDecimal(billingWeight));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the billingWeight [" + billingWeight + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
@@ -711,7 +714,6 @@
     }
     
     public static Map<String, Object> upsShipmentAccept(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         String shipmentId = (String) context.get("shipmentId");
         String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
@@ -729,7 +731,7 @@
         String shipmentAcceptResponseString = null;
 
         try {
-            GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+            //GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
             GenericValue shipmentRouteSegment = delegator.findByPrimaryKey("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId));
 
             if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) {
@@ -867,12 +869,12 @@
             
         // handle Response element info
         Element responseElement = UtilXml.firstChildElement(shipmentAcceptResponseElement, "Response");
-        Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
-        String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
-        String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
+        //Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
+        //String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
+        //String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
 
         String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
-        String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
+        //String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
         List<Object> errorList = FastList.newInstance();
         UpsServices.handleErrors(responseElement, errorList);
 
@@ -888,11 +890,11 @@
             Element shipmentChargesElement = UtilXml.firstChildElement(shipmentResultsElement, "ShipmentCharges");
 
             Element transportationChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "TransportationCharges");
-            String transportationCurrencyCode = UtilXml.childElementValue(transportationChargesElement, "CurrencyCode");
+            //String transportationCurrencyCode = UtilXml.childElementValue(transportationChargesElement, "CurrencyCode");
             String transportationMonetaryValue = UtilXml.childElementValue(transportationChargesElement, "MonetaryValue");
             
             Element serviceOptionsChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "ServiceOptionsCharges");
-            String serviceOptionsCurrencyCode = UtilXml.childElementValue(serviceOptionsChargesElement, "CurrencyCode");
+            //String serviceOptionsCurrencyCode = UtilXml.childElementValue(serviceOptionsChargesElement, "CurrencyCode");
             String serviceOptionsMonetaryValue = UtilXml.childElementValue(serviceOptionsChargesElement, "MonetaryValue");
 
             Element totalChargesElement = UtilXml.firstChildElement(shipmentChargesElement, "TotalCharges");
@@ -909,21 +911,21 @@
             }
             
             try {
-                shipmentRouteSegment.set("actualTransportCost", Double.valueOf(transportationMonetaryValue));
+                shipmentRouteSegment.set("actualTransportCost", new BigDecimal(transportationMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the transportationMonetaryValue [" + transportationMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
                 errorList.add(excErrMsg);
             }
             try {
-                shipmentRouteSegment.set("actualServiceCost", Double.valueOf(serviceOptionsMonetaryValue));
+                shipmentRouteSegment.set("actualServiceCost", new BigDecimal(serviceOptionsMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the serviceOptionsMonetaryValue [" + serviceOptionsMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
                 errorList.add(excErrMsg);
             }
             try {
-                shipmentRouteSegment.set("actualCost", Double.valueOf(totalMonetaryValue));
+                shipmentRouteSegment.set("actualCost", new BigDecimal(totalMonetaryValue));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the totalMonetaryValue [" + totalMonetaryValue + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
@@ -936,7 +938,7 @@
             String billingWeightUnitOfMeasurement = UtilXml.childElementValue(billingWeightUnitOfMeasurementElement, "Code");
             String billingWeight = UtilXml.childElementValue(billingWeightElement, "Weight");
             try {
-                shipmentRouteSegment.set("billingWeight", Double.valueOf(billingWeight));
+                shipmentRouteSegment.set("billingWeight", new BigDecimal(billingWeight));
             } catch (NumberFormatException e) {
                 String excErrMsg = "Error parsing the billingWeight [" + billingWeight + "]: " + e.toString();
                 Debug.logError(e, excErrMsg, module);
@@ -967,10 +969,10 @@
                 String packageServiceOptionsMonetaryValue = UtilXml.childElementValue(packageServiceOptionsChargesElement, "MonetaryValue");
 
                 Element packageLabelImageElement = UtilXml.firstChildElement(packageResultsElement, "LabelImage");
-                Element packageLabelImageFormatElement = UtilXml.firstChildElement(packageResultsElement, "LabelImageFormat");
+                //Element packageLabelImageFormatElement = UtilXml.firstChildElement(packageResultsElement, "LabelImageFormat");
                 // will be EPL or GIF, should always be GIF since that is what we requested
-                String packageLabelImageFormatCode = UtilXml.childElementValue(packageLabelImageFormatElement, "Code");
-                String packageLabelImageFormatDescription = UtilXml.childElementValue(packageLabelImageFormatElement, "Description");
+                //String packageLabelImageFormatCode = UtilXml.childElementValue(packageLabelImageFormatElement, "Code");
+                //String packageLabelImageFormatDescription = UtilXml.childElementValue(packageLabelImageFormatElement, "Description");
                 String packageLabelGraphicImageString = UtilXml.childElementValue(packageLabelImageElement, "GraphicImage");
                 String packageLabelInternationalSignatureGraphicImageString = UtilXml.childElementValue(packageLabelImageElement, "InternationalSignatureGraphicImage");
                 String packageLabelHTMLImageString = UtilXml.childElementValue(packageLabelImageElement, "HTMLImage");
@@ -987,7 +989,7 @@
                 shipmentPackageRouteSeg.set("boxNumber", "");
                 shipmentPackageRouteSeg.set("currencyUomId", packageServiceOptionsCurrencyCode);
                 try {
-                    shipmentPackageRouteSeg.set("packageServiceCost", Double.valueOf(packageServiceOptionsMonetaryValue));
+                    shipmentPackageRouteSeg.set("packageServiceCost", new BigDecimal(packageServiceOptionsMonetaryValue));
                 } catch (NumberFormatException e) {
                     String excErrMsg = "Error parsing the packageServiceOptionsMonetaryValue [" + packageServiceOptionsMonetaryValue + "] for Package [" + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + "]: " + e.toString();
                     Debug.logError(e, excErrMsg, module);
@@ -1075,7 +1077,6 @@
     }
     
     public static Map<String, Object> upsVoidShipment(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         String shipmentId = (String) context.get("shipmentId");
         String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
@@ -1093,7 +1094,7 @@
         String voidShipmentResponseString = null;
 
         try {
-            GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+            //GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
             GenericValue shipmentRouteSegment = delegator.findByPrimaryKey("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId));
 
             if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) {
@@ -1216,12 +1217,12 @@
             
         // handle Response element info
         Element responseElement = UtilXml.firstChildElement(voidShipmentResponseElement, "Response");
-        Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
-        String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
-        String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
+        //Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
+        //String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
+        //String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
 
         String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
-        String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
+        //String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
         List<Object> errorList = FastList.newInstance();
         UpsServices.handleErrors(responseElement, errorList);
 
@@ -1262,7 +1263,6 @@
     }
     
     public static Map<String, Object> upsTrackShipment(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         String shipmentId = (String) context.get("shipmentId");
         String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
@@ -1280,7 +1280,7 @@
         String trackResponseString = null;
 
         try {
-            GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+            //GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
             GenericValue shipmentRouteSegment = delegator.findByPrimaryKey("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId));
 
             if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) {
@@ -1406,12 +1406,12 @@
             
         // handle Response element info
         Element responseElement = UtilXml.firstChildElement(trackResponseElement, "Response");
-        Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
-        String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
-        String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
+        //Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
+        //String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
+        //String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
 
         String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
-        String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
+        //String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
         List<Object> errorList = FastList.newInstance();
         UpsServices.handleErrors(responseElement, errorList);
 
@@ -1419,14 +1419,14 @@
             // TODO: handle other response elements
             Element shipmentElement = UtilXml.firstChildElement(trackResponseElement, "Shipment");
 
-            Element shipperElement = UtilXml.firstChildElement(shipmentElement, "Shipper");
-            String shipperNumber = UtilXml.childElementValue(shipperElement, "ShipperNumber");
+            //Element shipperElement = UtilXml.firstChildElement(shipmentElement, "Shipper");
+            //String shipperNumber = UtilXml.childElementValue(shipperElement, "ShipperNumber");
 
-            Element serviceElement = UtilXml.firstChildElement(shipmentElement, "Service");
-            String serviceCode = UtilXml.childElementValue(serviceElement, "Code");
-            String serviceDescription = UtilXml.childElementValue(serviceElement, "Description");
+            //Element serviceElement = UtilXml.firstChildElement(shipmentElement, "Service");
+            //String serviceCode = UtilXml.childElementValue(serviceElement, "Code");
+            //String serviceDescription = UtilXml.childElementValue(serviceElement, "Description");
 
-            String shipmentIdentificationNumber = UtilXml.childElementValue(shipmentElement, "ShipmentIdentificationNumber");
+            //String shipmentIdentificationNumber = UtilXml.childElementValue(shipmentElement, "ShipmentIdentificationNumber");
                 
             List<? extends Element> packageElements = UtilXml.childElementList(shipmentElement, "Package");
             for (Element packageElement: packageElements) {
@@ -1549,19 +1549,19 @@
         }
     }
 
-    private static void splitEstimatePackages(Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, double maxWeight, double minWeight) {
-        List<Map<String, Double>> packages = getPackageSplit(shippableItemInfo, maxWeight);
+    private static void splitEstimatePackages(Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, BigDecimal maxWeight, BigDecimal minWeight) {
+        List<Map<String, BigDecimal>> packages = getPackageSplit(shippableItemInfo, maxWeight);
         if (UtilValidate.isNotEmpty(packages)) {
-            for (Map<String, Double> packageMap: packages) {
+            for (Map<String, BigDecimal> packageMap: packages) {
                 addPackageElement(requestDoc, shipmentElement, shippableItemInfo, packageMap, minWeight);
             }
         } else {
             
             // Add a dummy package
             String totalWeightStr = UtilProperties.getPropertyValue("shipment", "shipment.ups.min.estimate.weight", "1");
-            double packageWeight = 1;
+            BigDecimal packageWeight = BigDecimal.ONE;
             try {
-                packageWeight = Double.parseDouble(totalWeightStr);
+                packageWeight = new BigDecimal(totalWeightStr);
             } catch (NumberFormatException e) {
                 Debug.logError(e, module);
             }
@@ -1573,15 +1573,15 @@
         }
     }
 
-    private static void addPackageElement(Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, Map<String, Double> packageMap, double minWeight) {
-        double packageWeight = checkForDefaultPackageWeight(calcPackageWeight(packageMap, shippableItemInfo, 0),minWeight);
+    private static void addPackageElement(Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, Map<String, BigDecimal> packageMap, BigDecimal minWeight) {
+        BigDecimal packageWeight = checkForDefaultPackageWeight(calcPackageWeight(packageMap, shippableItemInfo, BigDecimal.ZERO), minWeight);
         Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
         Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
         UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
         UtilXml.addChildElementValue(packagingTypeElement, "Description", "Unknown PackagingType", requestDoc);
         UtilXml.addChildElementValue(packageElement, "Description", "Package Description", requestDoc);
         Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
-        UtilXml.addChildElementValue(packageWeightElement, "Weight", Double.toString(packageWeight), requestDoc);
+        UtilXml.addChildElementValue(packageWeightElement, "Weight", packageWeight.toPlainString(), requestDoc);
         //If product is in shippable Package then it we should have one product per packagemap
         if (packageMap.size() ==1) {
             Iterator<String> i = packageMap.keySet().iterator();
@@ -1598,7 +1598,7 @@
         
     }
 
-    private static void addPackageElement(Document requestDoc, Element shipmentElement, Double packageWeight) {        
+    private static void addPackageElement(Document requestDoc, Element shipmentElement, BigDecimal packageWeight) {        
         Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
         Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
         UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
@@ -1609,61 +1609,61 @@
     }
     
     
-    private static double checkForDefaultPackageWeight(double weight, double minWeight) {
-        return (weight > 0 && weight > minWeight ? weight : minWeight);
+    private static BigDecimal checkForDefaultPackageWeight(BigDecimal weight, BigDecimal minWeight) {
+        return (weight.compareTo(BigDecimal.ZERO) > 0 && weight.compareTo(minWeight) > 0 ? weight : minWeight);
     }
     
-    private static List<Map<String, Double>> getPackageSplit(List<Map<String, Object>> shippableItemInfo, double maxWeight) {
+    private static List<Map<String, BigDecimal>> getPackageSplit(List<Map<String, Object>> shippableItemInfo, BigDecimal maxWeight) {
         // create the package list w/ the first package
-        List<Map<String, Double>> packages = FastList.newInstance();
+        List<Map<String, BigDecimal>> packages = FastList.newInstance();
 
         if (shippableItemInfo != null) {
             for (Map<String, Object> itemInfo: shippableItemInfo) {
                 long pieces = ((Long) itemInfo.get("piecesIncluded")).longValue();
-                double totalQuantity = ((Double) itemInfo.get("quantity")).doubleValue();
-                double totalWeight = ((Double) itemInfo.get("weight")).doubleValue();
+                BigDecimal totalQuantity = (BigDecimal) itemInfo.get("quantity");
+                BigDecimal totalWeight = (BigDecimal) itemInfo.get("weight");
                 String productId = (String) itemInfo.get("productId");
 
                 // sanity check
                 if (pieces < 1) {
                     pieces = 1; // can NEVER be less than one
                 }
-                double weight = totalWeight / pieces;
+                BigDecimal weight = totalWeight.divide(BigDecimal.valueOf(pieces), generalRounding);
 
-                for (int z = 1; z <= totalQuantity; z++) {
-                    double partialQty = pieces > 1 ? 1.000 / pieces : 1;
+                for (int z = 1; z <= totalQuantity.intValue(); z++) {
+                 BigDecimal partialQty = pieces > 1 ? BigDecimal.ONE.divide(BigDecimal.valueOf(pieces), generalRounding) : BigDecimal.ONE;
                     for (long x = 0; x < pieces; x++) {
                         if(itemInfo.get("inShippingBox") != null &&  ((String) itemInfo.get("inShippingBox")).equalsIgnoreCase("Y")) {
-                            Map<String, Double> newPackage = FastMap.newInstance();
-                            newPackage.put(productId, Double.valueOf(partialQty));
+                            Map<String, BigDecimal> newPackage = FastMap.newInstance();
+                            newPackage.put(productId, partialQty);
                             packages.add(newPackage);
-                        } else if (weight >= maxWeight) {
-                            Map<String, Double> newPackage = FastMap.newInstance();
-                            newPackage.put(productId, Double.valueOf(partialQty));
+                        } else if (weight.compareTo(maxWeight) >= 0) {
+                            Map<String, BigDecimal> newPackage = FastMap.newInstance();
+                            newPackage.put(productId, partialQty);
                             packages.add(newPackage);
-                        } else if (totalWeight > 0) {
+                        } else if (totalWeight.compareTo(BigDecimal.ZERO) > 0) {
                             // create the first package
                             if (packages.size() == 0) {
-                                packages.add(FastMap.<String, Double>newInstance());
+                                packages.add(FastMap.<String, BigDecimal>newInstance());
                             }
 
                             // package loop
-                            int packageSize = packages.size();
+                            //int packageSize = packages.size();
                             boolean addedToPackage = false;
-                            for (Map<String, Double> packageMap: packages) {
+                            for (Map<String, BigDecimal> packageMap: packages) {
                                 if (!addedToPackage) {
-                                    double packageWeight = calcPackageWeight(packageMap, shippableItemInfo, weight);
-                                    if (packageWeight <= maxWeight) {
-                                        Double qtyD = (Double) packageMap.get(productId);
-                                        double qty = qtyD == null ? 0 : qtyD.doubleValue();
-                                        packageMap.put(productId, Double.valueOf(qty + partialQty));
+                                    BigDecimal packageWeight = calcPackageWeight(packageMap, shippableItemInfo, weight);
+                                    if (packageWeight.compareTo(maxWeight) <= 0) {
+                                     BigDecimal qty = packageMap.get(productId);
+                                        qty = qty == null ? BigDecimal.ZERO : qty;
+                                        packageMap.put(productId, qty.add(partialQty));
                                         addedToPackage = true;
                                     }
                                 }
                             }
                             if (!addedToPackage) {
-                                Map<String, Double> packageMap = FastMap.newInstance();
-                                packageMap.put(productId, Double.valueOf(partialQty));
+                                Map<String, BigDecimal> packageMap = FastMap.newInstance();
+                                packageMap.put(productId, partialQty);
                                 packages.add(packageMap);
                             }
                         }
@@ -1674,16 +1674,16 @@
         return packages;
     }
 
-    private static double calcPackageWeight(Map<String, Double> packageMap, List<Map<String, Object>> shippableItemInfo, double additionalWeight) {
-        double totalWeight = 0.00;
-        for (Map.Entry<String, Double> entry: packageMap.entrySet()) {
+    private static BigDecimal calcPackageWeight(Map<String, BigDecimal> packageMap, List<Map<String, Object>> shippableItemInfo, BigDecimal additionalWeight) {
+        BigDecimal totalWeight = BigDecimal.ZERO;
+        for (Map.Entry<String, BigDecimal> entry: packageMap.entrySet()) {
             String productId = entry.getKey();
             Map<String, Object> productInfo = getProductItemInfo(shippableItemInfo, productId);
-            double productWeight = ((Double) productInfo.get("weight")).doubleValue();
-            double quantity = entry.getValue().doubleValue();
-            totalWeight += (productWeight * quantity);
+            BigDecimal productWeight = (BigDecimal) productInfo.get("weight");
+            BigDecimal quantity = (BigDecimal) packageMap.get(productId);
+            totalWeight = totalWeight.add(productWeight.multiply(quantity));
         }
-        return totalWeight + additionalWeight;
+        return totalWeight.add(additionalWeight);
     }
 
     private static Map<String, Object> getProductItemInfo(List<Map<String, Object>> shippableItemInfo, String productId) {
@@ -1704,19 +1704,19 @@
 
         // handle Response element info
         Element responseElement = UtilXml.firstChildElement(rateResponseElement, "Response");
-        Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
-        String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
-        String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
+        //Element responseTransactionReferenceElement = UtilXml.firstChildElement(responseElement, "TransactionReference");
+        //String responseTransactionReferenceCustomerContext = UtilXml.childElementValue(responseTransactionReferenceElement, "CustomerContext");
+        //String responseTransactionReferenceXpciVersion = UtilXml.childElementValue(responseTransactionReferenceElement, "XpciVersion");
 
         String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
-        String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
+        //String responseStatusDescription = UtilXml.childElementValue(responseElement, "ResponseStatusDescription");
         List<Object> errorList = FastList.newInstance();
         UpsServices.handleErrors(responseElement, errorList);
 
         if ("1".equals(responseStatusCode)) {
             List<? extends Element> rates = UtilXml.childElementList(rateResponseElement, "RatedShipment");
-            Map<String, Double> rateMap = FastMap.newInstance();
-            Double firstRate = null;
+            Map<String, BigDecimal> rateMap = FastMap.newInstance();
+            BigDecimal firstRate = null;
             if (rates == null || rates.size() == 0) {
                 return ServiceUtil.returnError("No rates available at this time");
             } else {
@@ -1729,7 +1729,7 @@
                     Element totalCharges = UtilXml.firstChildElement(element, "TotalCharges");
                     String totalString = UtilXml.childElementValue(totalCharges, "MonetaryValue");
 
-                    rateMap.put(serviceCode, Double.valueOf(totalString));
+                    rateMap.put(serviceCode, new BigDecimal(totalString));
                     if (firstRate == null) {
                         firstRate = rateMap.get(serviceCode);
                     }
@@ -1887,11 +1887,11 @@
        // String shippingContactMechId = (String) context.get("shippingContactMechId");
         String shippingPostalCode = (String) context.get("shippingPostalCode");
         String shippingCountryCode = (String) context.get("shippingCountryCode");
-        List<Double> packageWeights = UtilGenerics.checkList(context.get("packageWeights"));
+        List<BigDecimal> packageWeights = UtilGenerics.checkList(context.get("packageWeights"));
         List<Map<String, Object>> shippableItemInfo = UtilGenerics.checkList(context.get("shippableItemInfo"));
-        Double shippableTotal = (Double) context.get("shippableTotal");
-        Double shippableQuantity = (Double) context.get("shippableQuantity");
-        Double shippableWeight = (Double) context.get("shippableWeight");
+        BigDecimal shippableTotal = (BigDecimal) context.get("shippableTotal");
+        BigDecimal shippableQuantity = (BigDecimal) context.get("shippableQuantity");
+        BigDecimal shippableWeight = (BigDecimal) context.get("shippableWeight");
         String isResidentialAddress = (String)context.get("isResidentialAddress");
 
         // Important: DO NOT returnError here or you could trigger a transaction rollback and break other services.
@@ -1900,13 +1900,13 @@
         }
 
         if (shippableTotal == null) {
-            shippableTotal = Double.valueOf(0.00);
+            shippableTotal = BigDecimal.ZERO;
         }
         if (shippableQuantity == null) {
-            shippableQuantity = Double.valueOf(0.00);
+            shippableQuantity = BigDecimal.ZERO;
         }
         if (shippableWeight == null) {
-            shippableWeight = Double.valueOf(0.00);
+            shippableWeight = BigDecimal.ZERO;
         }
         if (serviceConfigProps == null) {
             serviceConfigProps = "shipment.properties";
@@ -2007,26 +2007,25 @@
 
         // package info
         String maxWeightStr = UtilProperties.getPropertyValue(serviceConfigProps, "shipment.ups.max.estimate.weight", "99");
-        double maxWeight = 99;
+        BigDecimal maxWeight = new BigDecimal("99");
         try {
-            maxWeight = Double.parseDouble(maxWeightStr);
+            maxWeight = new BigDecimal(maxWeightStr);
         } catch (NumberFormatException e) {
-            maxWeight = 99;
+            maxWeight = new BigDecimal("99");
         }
         String minWeightStr = UtilProperties.getPropertyValue(serviceConfigProps, "shipment.ups.min.estimate.weight", ".1");
-        double minWeight = .1;
+        BigDecimal minWeight = new BigDecimal("0.1");
         try {
-            minWeight = Double.parseDouble(minWeightStr);
+            minWeight = new BigDecimal(minWeightStr);
         } catch (NumberFormatException e) {
-            minWeight = .1;
+            minWeight = new BigDecimal("0.1");
         }
         
         // Passing in a list of package weights overrides the calculation of same via shippableItemInfo
         if (UtilValidate.isEmpty(packageWeights)) {          
-                        
             splitEstimatePackages(rateRequestDoc, shipmentElement, shippableItemInfo, maxWeight, minWeight);
         } else {
-            for (Double packageWeight: packageWeights) {
+            for (BigDecimal packageWeight: packageWeights) {
                 addPackageElement(rateRequestDoc,  shipmentElement, packageWeight);
             }
         }