You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2008/12/01 07:51:15 UTC

svn commit: r721986 [4/13] - in /ofbiz/branches/typecheckcleanup200810: applications/accounting/script/org/ofbiz/accounting/olap/ applications/order/entitydef/ applications/order/script/org/ofbiz/order/order/ applications/order/script/org/ofbiz/order/q...

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sun Nov 30 22:51:11 2008
@@ -43,6 +43,7 @@
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.math.MathContext;
 import java.sql.Timestamp;
 import java.util.*;
 
@@ -60,8 +61,10 @@
     public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals");
     public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
-    public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(scale, rounding);    
-    public static final BigDecimal percentage = (new BigDecimal("0.01")).setScale(scale, rounding);    
+    public static final BigDecimal ZERO = BigDecimal.ZERO;    
+    public static final BigDecimal percentage = new BigDecimal("0.01");    
+    public static final MathContext generalRounding = new MathContext(10);
+
 
     private String orderType = "SALES_ORDER"; // default orderType
     private String channel = "UNKNWN_SALES_CHANNEL"; // default channel enum
@@ -73,7 +76,7 @@
     private String externalId = null;
     private String internalCode = null;
     private String billingAccountId = null;
-    private double billingAccountAmt = 0.00;
+    private BigDecimal billingAccountAmt = BigDecimal.ZERO;
     private String agreementId = null;
     private String quoteId = null;
     private String workEffortId = null;
@@ -418,12 +421,12 @@
         return this.cartCreatedTs;
     }
 
-    private GenericValue getSupplierProduct(String productId, double quantity, LocalDispatcher dispatcher) {
+    private GenericValue getSupplierProduct(String productId, BigDecimal quantity, LocalDispatcher dispatcher) {
         GenericValue supplierProduct = null;
         Map params = UtilMisc.toMap("productId", productId,
                                     "partyId", this.getPartyId(),
                                     "currencyUomId", this.getCurrency(),
-                                    "quantity", new Double(quantity));
+                                    "quantity", quantity);
         try {
             Map result = dispatcher.runSync("getSuppliersForProduct", params);
             List productSuppliers = (List)result.get("supplierProducts");
@@ -445,17 +448,17 @@
      * @return the new/increased item index
      * @throws CartItemModifyException
      */
-    public int addOrIncreaseItem(String productId, Double selectedAmountDbl, double quantity, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, 
+    public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, 
             Timestamp shipBeforeDate, Timestamp shipAfterDate, Map features, Map attributes, String prodCatalogId, 
             ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
     
-       return addOrIncreaseItem(productId,selectedAmountDbl,quantity,reservStart,reservLengthDbl,reservPersonsDbl, 
+       return addOrIncreaseItem(productId,selectedAmount,quantity,reservStart,reservLength,reservPersons, 
                        null,null,shipBeforeDate,shipAfterDate,features,attributes,prodCatalogId, 
                 configWrapper,itemType,itemGroupNumber,parentProductId,dispatcher);
     }
     
     /** add rental (with accommodation) item to cart  */
-    public int addOrIncreaseItem(String productId, Double selectedAmountDbl, double quantity, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, 
+    public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, 
                String accommodationMapId, String accommodationSpotId,
             Timestamp shipBeforeDate, Timestamp shipAfterDate, Map features, Map attributes, String prodCatalogId, 
             ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
@@ -463,9 +466,9 @@
            throw new CartItemModifyException("Cart items cannot be changed");
         }
         
-        double selectedAmount = selectedAmountDbl == null ? 0.0 : selectedAmountDbl.doubleValue();
-        double reservLength = reservLengthDbl == null ? 0.0 : reservLengthDbl.doubleValue();
-        double reservPersons = reservPersonsDbl == null ? 0.0 : reservPersonsDbl.doubleValue();
+        selectedAmount = selectedAmount == null ? BigDecimal.ZERO : selectedAmount;
+        reservLength = reservLength == null ? BigDecimal.ZERO : reservLength;
+        reservPersons = reservPersons == null ? BigDecimal.ZERO : reservPersons;
         
         ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber);
         GenericValue supplierProduct = null;
@@ -475,7 +478,7 @@
 
             
             if (sci.equals(productId, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, features, attributes, prodCatalogId,selectedAmount, configWrapper, itemType, itemGroup, false)) {
-                double newQuantity = sci.getQuantity() + quantity;
+                BigDecimal newQuantity = sci.getQuantity().add(quantity);
                 if (sci.getItemType().equals("RENTAL_ORDER_ITEM")) {
                     // check to see if the related fixed asset is available for the new quantity
                     String isAvailable = ShoppingCartItem.checkAvailability(productId, newQuantity, reservStart, reservLength, this);
@@ -492,8 +495,8 @@
 
                 if (getOrderType().equals("PURCHASE_ORDER")) {
                     supplierProduct = getSupplierProduct(productId, newQuantity, dispatcher);
-                    if (supplierProduct != null && supplierProduct.getDouble("lastPrice") != null) {
-                        sci.setBasePrice(supplierProduct.getDouble("lastPrice").doubleValue());
+                    if (supplierProduct != null && supplierProduct.getBigDecimal("lastPrice") != null) {
+                        sci.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
                         sci.setName(ShoppingCartItem.getPurchaseOrderItemDescription(sci.getProduct(), supplierProduct, this.getLocale()));
                     } else {
                        throw new CartItemModifyException("SupplierProduct not found");
@@ -507,13 +510,13 @@
             //GenericValue productSupplier = null;
             supplierProduct = getSupplierProduct(productId, quantity, dispatcher);
             if (supplierProduct != null || "_NA_".equals(this.getPartyId())) {
-                 return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmountDbl, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate));
+                 return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmount, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate));
             } else {
                 throw new CartItemModifyException("SupplierProduct not found");
             }
         } else {
-            return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), productId, selectedAmountDbl, quantity, null, 
-                    reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, 
+            return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), productId, selectedAmount, quantity, null, 
+                    reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, 
                     features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, 
                     this, Boolean.TRUE, Boolean.TRUE, parentProductId, Boolean.FALSE, Boolean.FALSE));
         }
@@ -523,7 +526,7 @@
      * @return the new item index
      * @throws CartItemModifyException
      */
-    public int addNonProductItem(String itemType, String description, String categoryId, Double price, double quantity, 
+    public int addNonProductItem(String itemType, String description, String categoryId, BigDecimal price, BigDecimal quantity, 
             Map attributes, String prodCatalogId, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException {
         ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber);
         return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), itemType, description, categoryId, price, null, quantity, attributes, prodCatalogId, itemGroup, dispatcher, this, Boolean.TRUE));
@@ -554,47 +557,47 @@
     }
 
     /** Add an item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
         return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, null, null, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
     }
 
     /** Add an item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
         return addItemToEnd(productId, amount, quantity, unitPrice, features, attributes, prodCatalogId, itemType, dispatcher, triggerExternalOps, triggerPriceRules, Boolean.FALSE, Boolean.FALSE);
     }
 
     /** Add an (rental)item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
     }    
 
     /** Add an (rental)item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
     }
 
     /** Add an (rental/aggregated)item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
     }
 
     /** Add an accommodation(rental )item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
     }    
 
     /** Add an accommodation(rental)item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
     }
 
     /** Add an accommodation(rental/aggregated)item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
-        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersonsDbl,String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
+        return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
     }
     
     /** Add an item to the shopping cart. */
-    public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
+    public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
         return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, null, null, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
     }
 
@@ -604,7 +607,7 @@
     }
 
     /** Get a ShoppingCartItem from the cart object. */
-    public ShoppingCartItem findCartItem(String productId, Map features, Map attributes, String prodCatalogId, double selectedAmount) {
+    public ShoppingCartItem findCartItem(String productId, Map features, Map attributes, String prodCatalogId, BigDecimal selectedAmount) {
         // Check for existing cart item.
         for (int i = 0; i < this.cartLines.size(); i++) {
             ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i);
@@ -675,7 +678,7 @@
         for (int i = 0; i < this.cartLines.size();) {
             ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i);
 
-            if (cartItem.getQuantity() == 0.0) {
+            if (cartItem.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
                 this.clearItemShipInfo(cartItem);
                 cartLines.remove(i);
             } else {
@@ -701,12 +704,12 @@
         }
     }
 
-    public static double getItemsTotalQuantity(List cartItems) {
-        double totalQuantity = 0;
+    public static BigDecimal getItemsTotalQuantity(List cartItems) {
+        BigDecimal totalQuantity = BigDecimal.ZERO;
         Iterator localIter = cartItems.iterator();
         while (localIter.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) localIter.next();
-            totalQuantity += item.getQuantity();
+            totalQuantity = totalQuantity.add(item.getQuantity());
         }
         return totalQuantity;
     }
@@ -724,7 +727,7 @@
         return productList;
     }
     
-    public void ensureItemsQuantity(List cartItems, LocalDispatcher dispatcher, double quantity) throws CartItemModifyException {
+    public void ensureItemsQuantity(List cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException {
         Iterator localIter = cartItems.iterator();
         while (localIter.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) localIter.next();
@@ -734,28 +737,28 @@
         }
     }
     
-    public double ensureItemsTotalQuantity(List cartItems, LocalDispatcher dispatcher, double quantity) throws CartItemModifyException {
-        double quantityRemoved = 0;
+    public BigDecimal ensureItemsTotalQuantity(List cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException {
+        BigDecimal quantityRemoved = BigDecimal.ZERO;
         // go through the items and reduce quantityToKeep by the item quantities until it is 0, then remove the remaining...
-        double quantityToKeep = quantity;
+        BigDecimal quantityToKeep = quantity;
         Iterator localIter = cartItems.iterator();
         while (localIter.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) localIter.next();
             
-            if (quantityToKeep >= item.getQuantity()) {
+            if (quantityToKeep.compareTo(item.getQuantity()) >= 0) {
                 // quantityToKeep sufficient to keep it all... just reduce quantityToKeep and move on  
-                quantityToKeep = quantityToKeep - item.getQuantity();
+                quantityToKeep = quantityToKeep.subtract(item.getQuantity());
             } else {
                 // there is more in this than we want to keep, so reduce the quantity, or remove altogether...
-                if (quantityToKeep == 0) {
+                if (quantityToKeep.compareTo(BigDecimal.ZERO) == 0) {
                     // nothing left to keep, just remove it...
-                    quantityRemoved += item.getQuantity();
+                    quantityRemoved = quantityRemoved.add(item.getQuantity());
                     this.removeCartItem(item, dispatcher);
                 } else {
                     // there is some to keep, so reduce quantity to quantityToKeep, at this point we know we'll take up all of the rest of the quantityToKeep
-                    quantityRemoved += (item.getQuantity() - quantityToKeep);
+                    quantityRemoved = quantityRemoved.add(item.getQuantity().subtract(quantityToKeep));
                     item.setQuantity(quantityToKeep, dispatcher, this);
-                    quantityToKeep = 0;
+                    quantityToKeep = BigDecimal.ZERO;
                 }
             }
         }
@@ -848,10 +851,10 @@
         ShoppingCartItem item = (ShoppingCartItem) cartLines.remove(index);
 
         // set quantity to 0 to trigger necessary events
-        item.setQuantity(0.0, dispatcher, this);
+        item.setQuantity(BigDecimal.ZERO, dispatcher, this);
     }
 
-    /** Moves a line item to a differnt index. */
+    /** Moves a line item to a different index. */
     public void moveCartItem(int fromIndex, int toIndex) {
         if (toIndex < fromIndex) {
             cartLines.add(toIndex, cartLines.remove(fromIndex));
@@ -1230,7 +1233,7 @@
         return this.lastListRestore;
     }
 
-    public Double getPartyDaysSinceCreated(Timestamp nowTimestamp) {
+    public BigDecimal getPartyDaysSinceCreated(Timestamp nowTimestamp) {
         String partyId = this.getPartyId();
         if (UtilValidate.isEmpty(partyId)) {
             return null;
@@ -1244,9 +1247,9 @@
             if (createdDate == null) {
                 return null;
             }
-            double diffMillis = nowTimestamp.getTime() - createdDate.getTime();
+            BigDecimal diffMillis = new BigDecimal(nowTimestamp.getTime() - createdDate.getTime());
             // millis per day: 1000.0 * 60.0 * 60.0 * 24.0 = 86400000.0
-            return new Double((diffMillis) / 86400000.0);
+            return (diffMillis).divide(new BigDecimal("86400000"), generalRounding);
         } catch (GenericEntityException e) {
             Debug.logError(e, "Error looking up party when getting createdDate", module);
             return null;
@@ -1263,7 +1266,7 @@
         this.orderId = null;
         this.firstAttemptOrderId = null;
         this.billingAccountId = null;
-        this.billingAccountAmt = 0.00;
+        this.billingAccountAmt = BigDecimal.ZERO;
         this.nextItemSeq = 1;
 
         this.agreementId = null;
@@ -1420,7 +1423,7 @@
     }
 
     /** Creates a CartPaymentInfo object */
-    public CartPaymentInfo makePaymentInfo(String id, String refNum, Double amount) {
+    public CartPaymentInfo makePaymentInfo(String id, String refNum, BigDecimal amount) {
         CartPaymentInfo inf = new CartPaymentInfo();
         inf.refNum[0] = refNum;
         inf.amount = amount;
@@ -1475,7 +1478,7 @@
     }
 
     /** Locates an existing (or creates a new) CartPaymentInfo object */
-    public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, Double amount, boolean update) {
+    public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, BigDecimal amount, boolean update) {
         CartPaymentInfo thisInf = this.makePaymentInfo(id, refNum, amount);
         Iterator i = paymentInfo.iterator();
         while (i.hasNext()) {
@@ -1497,7 +1500,7 @@
     }
 
     /** Locates an existing (or creates a new) CartPaymentInfo object */
-    public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, Double amount) {
+    public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, BigDecimal amount) {
         return this.getPaymentInfo(id, refNum, authCode, amount, false);
     }
 
@@ -1507,7 +1510,7 @@
     }
 
     /** adds a payment method/payment method type */
-    public CartPaymentInfo addPaymentAmount(String id, Double amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) {
+    public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) {
         CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, replace);
         if (isSalesOrder()) {
             GenericValue billingAddress = inf.getBillingAddress(this.getDelegator());
@@ -1535,32 +1538,22 @@
     }
 
     /** adds a payment method/payment method type */
-    public CartPaymentInfo addPaymentAmount(String id, Double amount, boolean isSingleUse) {
+    public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, boolean isSingleUse) {
         return this.addPaymentAmount(id, amount, null, null, isSingleUse, false, true);
     }
 
     /** adds a payment method/payment method type */
-    public CartPaymentInfo addPaymentAmount(String id, double amount, boolean isSingleUse) {
-        return this.addPaymentAmount(id, new Double(amount), isSingleUse);
-    }
-
-    /** adds a payment method/payment method type */
-    public CartPaymentInfo addPaymentAmount(String id, Double amount) {
+    public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount) {
         return this.addPaymentAmount(id, amount, false);
     }
 
     /** adds a payment method/payment method type */
-    public CartPaymentInfo addPaymentAmount(String id, double amount) {
-        return this.addPaymentAmount(id, new Double(amount), false);
-    }
-
-    /** adds a payment method/payment method type */
     public CartPaymentInfo addPayment(String id) {
         return this.addPaymentAmount(id, null, false);
     }
 
     /** returns the payment method/payment method type amount */
-    public Double getPaymentAmount(String id) {
+    public BigDecimal getPaymentAmount(String id) {
         return this.getPaymentInfo(id).amount;
     }
 
@@ -1581,13 +1574,13 @@
     }
     
     /** returns the total payment amounts */
-    public double getPaymentTotal() {
-        double total = 0.00;
+    public BigDecimal getPaymentTotal() {
+    	BigDecimal total = BigDecimal.ZERO;
         Iterator i = paymentInfo.iterator();
         while (i.hasNext()) {
             CartPaymentInfo inf = (CartPaymentInfo) i.next();
             if (inf.amount != null) {
-                total += inf.amount.doubleValue();
+                total = total.add(inf.amount);
             }
         }
         return total;
@@ -1878,7 +1871,7 @@
     // =======================================================================
 
     /** Sets the billing account id string. */
-    public void setBillingAccount(String billingAccountId, double amount) {
+    public void setBillingAccount(String billingAccountId, BigDecimal amount) {
         this.billingAccountId = billingAccountId;
         this.billingAccountAmt = amount;
     }
@@ -1889,7 +1882,7 @@
     }
 
     /** Returns the amount to be billed to the billing account.*/
-    public double getBillingAccountAmount() {
+    public BigDecimal getBillingAccountAmount() {
         return this.billingAccountAmt;
     }
 
@@ -1899,7 +1892,7 @@
 
     /** Returns the order level shipping amount */
     public BigDecimal getOrderShipping() {
-        return OrderReadHelper.calcOrderAdjustments(this.getAdjustments(), new BigDecimal(this.getSubTotal()), false, false, true);
+        return OrderReadHelper.calcOrderAdjustments(this.getAdjustments(), this.getSubTotal(), false, false, true);
     }
 
     // ----------------------------------------
@@ -1925,7 +1918,7 @@
                 CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) csi.shipItemInfo.get(item);
                 if (csii != null) {
                     if (this.checkShipItemInfo(csi, csii)) {
-                        shipGroups.put(new Integer(i), new Double(csii.quantity));
+                        shipGroups.put(new Integer(i), csii.quantity);
                     }
                 }
             }
@@ -1963,7 +1956,7 @@
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) csi.shipItemInfo.get(item);
-            qtyMap.put(item, new Double(csii.quantity));
+            qtyMap.put(item, csii.quantity);
         }
         return qtyMap;
     }
@@ -1976,7 +1969,7 @@
         this.cleanUpShipGroups();
     }
 
-    public void setItemShipGroupEstimate(double amount, int idx) {
+    public void setItemShipGroupEstimate(BigDecimal amount, int idx) {
         CartShipInfo csi = this.getShipInfo(idx);
         csi.shipEstimate = amount;
     }
@@ -2001,30 +1994,30 @@
         }
     }
     
-    public double getItemShipGroupEstimate(int idx) {
+    public BigDecimal getItemShipGroupEstimate(int idx) {
         CartShipInfo csi = this.getShipInfo(idx);
         return csi.shipEstimate;
     }
 
-    public void setItemShipGroupQty(int itemIndex, double quantity, int idx) {
+    public void setItemShipGroupQty(int itemIndex, BigDecimal quantity, int idx) {
         this.setItemShipGroupQty(this.findCartItem(itemIndex), itemIndex, quantity, idx);
     }
 
-    public void setItemShipGroupQty(ShoppingCartItem item, double quantity, int idx) {
+    public void setItemShipGroupQty(ShoppingCartItem item, BigDecimal quantity, int idx) {
         this.setItemShipGroupQty(item, this.getItemIndex(item), quantity, idx);
     }
 
-    public void setItemShipGroupQty(ShoppingCartItem item, int itemIndex, double quantity, int idx) {
+    public void setItemShipGroupQty(ShoppingCartItem item, int itemIndex, BigDecimal quantity, int idx) {
         if (itemIndex > -1) {
             CartShipInfo csi = this.getShipInfo(idx);
 
             // never set less than zero
-            if (quantity < 0) {
-                quantity = 0;
+            if (quantity.compareTo(BigDecimal.ZERO) < 0) {
+                quantity = BigDecimal.ZERO;
             }
 
             // never set more than quantity ordered
-            if (quantity > item.getQuantity()) {
+            if (quantity.compareTo(item.getQuantity()) > 0) {
                 quantity = item.getQuantity();
             }
             
@@ -2037,7 +2030,7 @@
         }
     }
 
-    public double getItemShipGroupQty(ShoppingCartItem item, int idx) {
+    public BigDecimal getItemShipGroupQty(ShoppingCartItem item, int idx) {
         if (item != null) {
             CartShipInfo csi = this.getShipInfo(idx);
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) csi.shipItemInfo.get(item);
@@ -2045,19 +2038,19 @@
                 return csii.quantity;
             }
         }
-        return 0;
+        return BigDecimal.ZERO;
     }
 
-    public double getItemShipGroupQty(int itemIndex, int idx) {
+    public BigDecimal getItemShipGroupQty(int itemIndex, int idx) {
         return this.getItemShipGroupQty(this.findCartItem(itemIndex), idx);
     }
 
-    public void positionItemToGroup(int itemIndex, double quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) {
+    public void positionItemToGroup(int itemIndex, BigDecimal quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) {
         this.positionItemToGroup(this.findCartItem(itemIndex), quantity, fromIndex, toIndex, clearEmptyGroups);
     }
 
-    public void positionItemToGroup(ShoppingCartItem item, double quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) {
-        if (fromIndex == toIndex || quantity <= 0) {
+    public void positionItemToGroup(ShoppingCartItem item, BigDecimal quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) {
+        if (fromIndex == toIndex || quantity.compareTo(BigDecimal.ZERO) <= 0) {
             // do nothing
             return;
         }
@@ -2076,14 +2069,14 @@
 
         // adjust the quantities
         if (fromGroup != null && toGroup != null) {
-            double fromQty = this.getItemShipGroupQty(item, fromIndex);
-            double toQty = this.getItemShipGroupQty(item, toIndex);
-            if (fromQty > 0) {
-                if (quantity > fromQty) {
+            BigDecimal fromQty = this.getItemShipGroupQty(item, fromIndex);
+            BigDecimal toQty = this.getItemShipGroupQty(item, toIndex);
+            if (fromQty.compareTo(BigDecimal.ZERO) > 0) {
+                if (quantity.compareTo(fromQty) > 0) {
                     quantity = fromQty;
                 }
-                fromQty -= quantity;
-                toQty += quantity;
+                fromQty = fromQty.subtract(quantity);
+                toQty = toQty.add(quantity);
                 this.setItemShipGroupQty(item, fromQty, fromIndex);
                 this.setItemShipGroupQty(item, toQty, toIndex);
             }
@@ -2097,7 +2090,7 @@
 
     // removes 0 quantity items
     protected boolean checkShipItemInfo(CartShipInfo csi, CartShipInfo.CartShipItemInfo csii) {
-        if (csii.quantity == 0 || csii.item.getQuantity() == 0) {
+        if (csii.quantity.compareTo(BigDecimal.ZERO) == 0 || csii.item.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
             csi.shipItemInfo.remove(csii.item);
             return false;
         }
@@ -2110,7 +2103,7 @@
             Iterator si = csi.shipItemInfo.keySet().iterator();
             while (si.hasNext()) {
                 ShoppingCartItem item = (ShoppingCartItem) si.next();
-                if (item.getQuantity() == 0.0) {
+                if (item.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
                     si.remove();
                 }
             }
@@ -2427,29 +2420,29 @@
     }
 
     // Returns the tax amount for a ship group. */
-    public double getTotalSalesTax(int shipGroup) {
+    public BigDecimal getTotalSalesTax(int shipGroup) {
         CartShipInfo csi = this.getShipInfo(shipGroup);
         return csi.getTotalTax(this);
     }
 
     /** Returns the tax amount from the cart object. */
-    public double getTotalSalesTax() {
+    public BigDecimal getTotalSalesTax() {
         BigDecimal totalTax = ZERO;
         for (int i = 0; i < shipInfo.size(); i++) {
             CartShipInfo csi = this.getShipInfo(i);
-            totalTax = totalTax.add(new BigDecimal(csi.getTotalTax(this))).setScale(taxCalcScale, taxRounding);
+            totalTax = totalTax.add(csi.getTotalTax(this)).setScale(taxCalcScale, taxRounding);
         }
-        return totalTax.setScale(taxFinalScale, taxRounding).doubleValue();
+        return totalTax.setScale(taxFinalScale, taxRounding);
     }
 
     /** Returns the shipping amount from the cart object. */
-    public double getTotalShipping() {
-        double tempShipping = 0.0;
+    public BigDecimal getTotalShipping() {
+        BigDecimal tempShipping = BigDecimal.ZERO;
 
         Iterator shipIter = this.shipInfo.iterator();
         while (shipIter.hasNext()) {
             CartShipInfo csi = (CartShipInfo) shipIter.next();
-            tempShipping += csi.shipEstimate;
+            tempShipping = tempShipping.add(csi.shipEstimate);
 
         }
 
@@ -2457,64 +2450,64 @@
     }
 
     /** Returns the item-total in the cart (not including discount/tax/shipping). */
-    public double getItemTotal() {
-        double itemTotal = 0.00;
+    public BigDecimal getItemTotal() {
+        BigDecimal itemTotal = BigDecimal.ZERO;
         Iterator i = iterator();
 
         while (i.hasNext()) {
-            itemTotal += ((ShoppingCartItem) i.next()).getBasePrice();
+            itemTotal = itemTotal.add(((ShoppingCartItem) i.next()).getBasePrice());
         }
         return itemTotal;
     }
 
     /** Returns the sub-total in the cart (item-total - discount). */
-    public double getSubTotal() {
-        double itemsTotal = 0.00;
+    public BigDecimal getSubTotal() {
+        BigDecimal itemsTotal = BigDecimal.ZERO;
         Iterator i = iterator();
 
         while (i.hasNext()) {
-            itemsTotal += ((ShoppingCartItem) i.next()).getItemSubTotal();
+            itemsTotal = itemsTotal.add(((ShoppingCartItem) i.next()).getItemSubTotal());
         }
         return itemsTotal;
     }
 
     /** Returns the total from the cart, including tax/shipping. */
-    public double getGrandTotal() {
+    public BigDecimal getGrandTotal() {
         // sales tax and shipping are not stored as adjustments but rather as part of the ship group
         // Debug.logInfo("Subtotal:" + this.getSubTotal() + " Shipping:" + this.getTotalShipping() + "SalesTax: "+ this.getTotalSalesTax() + " others: " + this.getOrderOtherAdjustmentTotal(),module);
-        return this.getSubTotal() + this.getTotalShipping() + this.getTotalSalesTax() + this.getOrderOtherAdjustmentTotal();
+        return this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal());
     }
 
-    public double getDisplaySubTotal() {
-        double itemsTotal = 0.00;
+    public BigDecimal getDisplaySubTotal() {
+        BigDecimal itemsTotal = BigDecimal.ZERO;
         Iterator i = iterator();
         while (i.hasNext()) {
-            itemsTotal += ((ShoppingCartItem) i.next()).getDisplayItemSubTotal();
+            itemsTotal = itemsTotal.add(((ShoppingCartItem) i.next()).getDisplayItemSubTotal());
         }
         return itemsTotal;
     }
 
-    public double getDisplayRecurringSubTotal() {
-        double itemsTotal = 0.00;
+    public BigDecimal getDisplayRecurringSubTotal() {
+        BigDecimal itemsTotal = BigDecimal.ZERO;
         Iterator i = iterator();
         while (i.hasNext()) {
-            itemsTotal += ((ShoppingCartItem) i.next()).getDisplayItemRecurringSubTotal();
+            itemsTotal = itemsTotal.add(((ShoppingCartItem) i.next()).getDisplayItemRecurringSubTotal());
         }
         return itemsTotal;
     }
 
     /** Returns the total from the cart, including tax/shipping. */
-    public double getDisplayGrandTotal() {
-        return this.getDisplaySubTotal() + this.getTotalShipping() + this.getTotalSalesTax() + this.getOrderOtherAdjustmentTotal();
+    public BigDecimal getDisplayGrandTotal() {
+        return this.getDisplaySubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal());
     }
 
-    public double getOrderOtherAdjustmentTotal() {
-        return OrderReadHelper.calcOrderAdjustments(this.getAdjustments(), new BigDecimal(this.getSubTotal()), true, false, false).doubleValue();
+    public BigDecimal getOrderOtherAdjustmentTotal() {
+        return OrderReadHelper.calcOrderAdjustments(this.getAdjustments(), this.getSubTotal(), true, false, false);
     }
 
     /** Returns the sub-total in the cart (item-total - discount). */
-    public double getSubTotalForPromotions() {
-        double itemsTotal = 0.00;
+    public BigDecimal getSubTotalForPromotions() {
+    	BigDecimal itemsTotal = BigDecimal.ZERO;
         Iterator i = iterator();
 
         while (i.hasNext()) {
@@ -2524,7 +2517,7 @@
                 // don't include in total if this is the case...
                 continue;
             }
-            itemsTotal += cartItem.getItemSubTotal();
+            itemsTotal = itemsTotal.add(cartItem.getItemSubTotal());
         }
         return itemsTotal;
     }
@@ -2533,8 +2526,8 @@
      * Get the total payment amount by payment type.  Specify null to get amount
      * over all types.
      */
-    public double getOrderPaymentPreferenceTotalByType(String paymentMethodTypeId) {
-        double total = 0.0;
+    public BigDecimal getOrderPaymentPreferenceTotalByType(String paymentMethodTypeId) {
+        BigDecimal total = BigDecimal.ZERO;
         String thisPaymentMethodTypeId = null;
         for (Iterator iter = paymentInfo.iterator(); iter.hasNext(); ) {
             CartPaymentInfo payment = (CartPaymentInfo) iter.next();
@@ -2555,21 +2548,21 @@
 
             // add the amount according to paymentMethodType
             if (paymentMethodTypeId == null || paymentMethodTypeId.equals(thisPaymentMethodTypeId)) {
-                total += payment.amount.doubleValue();
+                total = total.add(payment.amount);
             }
         }
         return total;
     }
 
-    public double getCreditCardPaymentPreferenceTotal() {
+    public BigDecimal getCreditCardPaymentPreferenceTotal() {
         return getOrderPaymentPreferenceTotalByType("CREDIT_CARD");
     }
 
-    public double getBillingAccountPaymentPreferenceTotal() {
+    public BigDecimal getBillingAccountPaymentPreferenceTotal() {
         return getOrderPaymentPreferenceTotalByType("EXT_BILLACT");
     }
 
-    public double getGiftCardPaymentPreferenceTotal() {
+    public BigDecimal getGiftCardPaymentPreferenceTotal() {
         return getOrderPaymentPreferenceTotalByType("GIFT_CARD");
     }
 
@@ -2614,12 +2607,12 @@
     }
 
     /** Add an orderTerm to the order */
-    public int addOrderTerm(String termTypeId,Double termValue,Long termDays) {
+    public int addOrderTerm(String termTypeId, BigDecimal termValue, Long termDays) {
         return addOrderTerm(termTypeId, termValue, termDays, null);
     }
     
     /** Add an orderTerm to the order */
-    public int addOrderTerm(String termTypeId,Double termValue,Long termDays, String textValue) {
+    public int addOrderTerm(String termTypeId, BigDecimal termValue, Long termDays, String textValue) {
         GenericValue orderTerm = GenericValue.create(delegator.getModelEntity("OrderTerm"));
         orderTerm.put("termTypeId", termTypeId);
         orderTerm.put("termValue", termValue);
@@ -2712,41 +2705,41 @@
     }
 
     /** Returns the total weight in the cart. */
-    public double getTotalWeight() {
-        double weight = 0.0;
+    public BigDecimal getTotalWeight() {
+        BigDecimal weight = BigDecimal.ZERO;
         Iterator i = iterator();
 
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
 
-            weight += (item.getWeight() * item.getQuantity());
+            weight = weight.add(item.getWeight().multiply(item.getQuantity()));
         }
         return weight;
     }
 
     /** Returns the total quantity in the cart. */
-    public double getTotalQuantity() {
-        double count = 0.0;
+    public BigDecimal getTotalQuantity() {
+        BigDecimal count = BigDecimal.ZERO;
         Iterator i = iterator();
 
         while (i.hasNext()) {
-            count += ((ShoppingCartItem) i.next()).getQuantity();
+            count = count.add(((ShoppingCartItem) i.next()).getQuantity());
         }
         return count;
     }
 
     /** Returns the SHIPPABLE item-total in the cart for a specific ship group. */
-    public double getShippableTotal(int idx) {
+    public BigDecimal getShippableTotal(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        double itemTotal = 0.0;
+        BigDecimal itemTotal = BigDecimal.ZERO;
 
         Iterator i = info.shipItemInfo.keySet().iterator();
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
-                    itemTotal += item.getItemSubTotal(csii.quantity);
+                    itemTotal = itemTotal.add(item.getItemSubTotal(csii.quantity));
                 }
             }
         }
@@ -2755,17 +2748,17 @@
     }
 
     /** Returns the total SHIPPABLE quantity in the cart for a specific ship group. */
-    public double getShippableQuantity(int idx) {
+    public BigDecimal getShippableQuantity(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        double count = 0.0;
+        BigDecimal count = BigDecimal.ZERO;
 
         Iterator i = info.shipItemInfo.keySet().iterator();
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
-                    count += csii.quantity;
+                    count = count.add(csii.quantity);
                 }
             }
         }
@@ -2774,17 +2767,17 @@
     }
 
     /** Returns the total SHIPPABLE weight in the cart for a specific ship group. */
-    public double getShippableWeight(int idx) {
+    public BigDecimal getShippableWeight(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        double weight = 0.0;
+        BigDecimal weight = BigDecimal.ZERO;
 
         Iterator i = info.shipItemInfo.keySet().iterator();
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
-                    weight += (item.getWeight() * csii.quantity);
+                    weight = weight.add(item.getWeight().multiply(csii.quantity));
                 }
             }
         }
@@ -2801,9 +2794,9 @@
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
-                    shippableSizes.add(new Double(item.getSize()));
+                    shippableSizes.add(item.getSize());
                 }
             }
         }
@@ -2820,10 +2813,10 @@
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
                     Map itemInfo = item.getItemProductInfo();
-                    itemInfo.put("quantity", Double.valueOf(csii.quantity));
+                    itemInfo.put("quantity", csii.quantity);
                     itemInfos.add(itemInfo);
                 }
             }
@@ -2869,7 +2862,7 @@
         while (i.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) i.next();
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);
-            if (csii != null && csii.quantity > 0) {
+            if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 featureMap.putAll(item.getFeatureIdQtyMap(csii.quantity));
             }
         }
@@ -2956,7 +2949,7 @@
         return new HashMap(this.desiredAlternateGiftByAction);
     }
 
-    public void addProductPromoUse(String productPromoId, String productPromoCodeId, double totalDiscountAmount, double quantityLeftInActions) {
+    public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions) {
         if (UtilValidate.isNotEmpty(productPromoCodeId) && !this.productPromoCodes.contains(productPromoCodeId)) {
             throw new IllegalStateException("Cannot add a use to a promo code use for a code that has not been entered.");
         }
@@ -2982,8 +2975,8 @@
         return productPromoUseInfoList.iterator();
     }
     
-    public double getProductPromoTotal() {
-        double totalDiscount = 0;
+    public BigDecimal getProductPromoTotal() {
+        BigDecimal totalDiscount = BigDecimal.ZERO;
         List cartAdjustments = this.getAdjustments();
         if (cartAdjustments != null) {
             Iterator cartAdjustmentIter = cartAdjustments.iterator();
@@ -2993,7 +2986,7 @@
                         UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoRuleId")) &&
                         UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoActionSeqId"))) {
                     if (checkOrderAdjustment.get("amount") != null) {
-                        totalDiscount += checkOrderAdjustment.getDouble("amount").doubleValue();
+                        totalDiscount = totalDiscount.add(checkOrderAdjustment.getBigDecimal("amount"));
                     }
                 }
             }
@@ -3010,7 +3003,7 @@
                         UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoRuleId")) &&
                         UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoActionSeqId"))) {
                     if (checkOrderAdjustment.get("amount") != null) {
-                        totalDiscount += checkOrderAdjustment.getDouble("amount").doubleValue();
+                        totalDiscount = totalDiscount.add(checkOrderAdjustment.getBigDecimal("amount"));
                     }
                 }
             }
@@ -3020,13 +3013,13 @@
     }
 
     /** Get total discount for a given ProductPromo, or for ANY ProductPromo if the passed in productPromoId is null. */
-    public double getProductPromoUseTotalDiscount(String productPromoId) {
-        double totalDiscount = 0;
+    public BigDecimal getProductPromoUseTotalDiscount(String productPromoId) {
+        BigDecimal totalDiscount = BigDecimal.ZERO;
         Iterator productPromoUseInfoIter = this.productPromoUseInfoList.iterator();
         while (productPromoUseInfoIter.hasNext()) {
             ProductPromoUseInfo productPromoUseInfo = (ProductPromoUseInfo) productPromoUseInfoIter.next();
             if (productPromoId == null || productPromoId.equals(productPromoUseInfo.productPromoId)) {
-                totalDiscount += productPromoUseInfo.getTotalDiscountAmount();
+                totalDiscount = totalDiscount.add(productPromoUseInfo.getTotalDiscountAmount());
             }
         }
         return totalDiscount;
@@ -3410,10 +3403,10 @@
                 orderItem.set("productId", UtilValidate.isNotEmpty(aggregatedInstanceId) ? aggregatedInstanceId : item.getProductId());
                 orderItem.set("prodCatalogId", item.getProdCatalogId());
                 orderItem.set("productCategoryId", item.getProductCategoryId());
-                orderItem.set("quantity", new BigDecimal(item.getQuantity()));
-                orderItem.set("selectedAmount", new BigDecimal(item.getSelectedAmount()));
-                orderItem.set("unitPrice", new BigDecimal(item.getBasePrice()));
-                orderItem.set("unitListPrice", new BigDecimal(item.getListPrice()));
+                orderItem.set("quantity", item.getQuantity());
+                orderItem.set("selectedAmount", item.getSelectedAmount());
+                orderItem.set("unitPrice", item.getBasePrice());
+                orderItem.set("unitListPrice", item.getListPrice());
                 orderItem.set("isModifiedPrice",item.getIsModifiedPrice() ? "Y" : "N");
                 orderItem.set("isPromo", item.getIsPromo() ? "Y" : "N");
 
@@ -3455,9 +3448,9 @@
                 workEffort.set("workEffortId",item.getOrderItemSeqId());  // fill temporary with sequence number
                 workEffort.set("estimatedStartDate",item.getReservStart());
                 workEffort.set("estimatedCompletionDate",item.getReservStart(item.getReservLength()));
-                workEffort.set("reservPersons",new Double(item.getReservPersons()));
-                workEffort.set("reserv2ndPPPerc", new Double(item.getReserv2ndPPPerc()));
-                workEffort.set("reservNthPPPerc", new Double(item.getReservNthPPPerc()));
+                workEffort.set("reservPersons", item.getReservPersons());
+                workEffort.set("reserv2ndPPPerc", item.getReserv2ndPPPerc());
+                workEffort.set("reservNthPPPerc", item.getReservNthPPPerc());
                 workEffort.set("accommodationMapId", item.getAccommodationMapId());
                 workEffort.set("accommodationSpotId",item.getAccommodationSpotId());
                 allWorkEfforts.add(workEffort);
@@ -3604,25 +3597,25 @@
     /** make a list of all OrderPaymentPreferences and Billing info including all payment methods and types */
     public List makeAllOrderPaymentInfos(LocalDispatcher dispatcher) {
         List allOpPrefs = new LinkedList();
-        BigDecimal remainingAmount = new BigDecimal(this.getGrandTotal() - this.getPaymentTotal());
+        BigDecimal remainingAmount = this.getGrandTotal().subtract(this.getPaymentTotal());
         remainingAmount = remainingAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
-        if (getBillingAccountId() != null && this.billingAccountAmt <= 0) {
-            double billingAccountAvailableAmount = CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher);
-            if (this.billingAccountAmt == 0.0 && billingAccountAvailableAmount > 0) {
+        if (getBillingAccountId() != null && this.billingAccountAmt.compareTo(BigDecimal.ZERO) <= 0) {
+            BigDecimal billingAccountAvailableAmount = CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher);
+            if (this.billingAccountAmt.compareTo(BigDecimal.ZERO) == 0 && billingAccountAvailableAmount.compareTo(BigDecimal.ZERO) > 0) {
                 this.billingAccountAmt = billingAccountAvailableAmount;
             }
-            if (remainingAmount.doubleValue() < getBillingAccountAmount()) {
-                this.billingAccountAmt = remainingAmount.doubleValue();
+            if (remainingAmount.compareTo(getBillingAccountAmount()) < 0) {
+                this.billingAccountAmt = remainingAmount;
             }
-            if (billingAccountAvailableAmount < getBillingAccountAmount()) {
+            if (billingAccountAvailableAmount.compareTo(getBillingAccountAmount()) < 0) {
                 this.billingAccountAmt = billingAccountAvailableAmount;
             }
-            BigDecimal billingAccountAmountSelected = new BigDecimal(getBillingAccountAmount());
+            BigDecimal billingAccountAmountSelected = getBillingAccountAmount();
             GenericValue opp = delegator.makeValue("OrderPaymentPreference", new HashMap());
             opp.set("paymentMethodTypeId", "EXT_BILLACT");
             opp.set("presentFlag", "N");
             opp.set("overflowFlag", "N");
-            opp.set("maxAmount", new Double(billingAccountAmountSelected.doubleValue()));
+            opp.set("maxAmount", billingAccountAmountSelected);
             opp.set("statusId", "PAYMENT_NOT_RECEIVED");
             allOpPrefs.add(opp);
             remainingAmount = remainingAmount.subtract(billingAccountAmountSelected);
@@ -3634,7 +3627,7 @@
         while (i.hasNext()) {
             CartPaymentInfo inf = (CartPaymentInfo) i.next();
             if (inf.amount == null) {
-                inf.amount = new Double(remainingAmount.doubleValue());
+                inf.amount = remainingAmount;
                 remainingAmount = BigDecimal.ZERO;
             }
             allOpPrefs.addAll(inf.makeOrderPaymentInfos(this.getDelegator(), this));
@@ -3679,8 +3672,8 @@
             productPromoUse.set("promoSequenceId", UtilFormatOut.formatPaddedNumber(sequenceValue, 5));
             productPromoUse.set("productPromoId", productPromoUseInfo.getProductPromoId());
             productPromoUse.set("productPromoCodeId", productPromoUseInfo.getProductPromoCodeId());
-            productPromoUse.set("totalDiscountAmount", new BigDecimal(productPromoUseInfo.getTotalDiscountAmount()));
-            productPromoUse.set("quantityLeftInActions", new BigDecimal(productPromoUseInfo.getQuantityLeftInActions()));
+            productPromoUse.set("totalDiscountAmount", productPromoUseInfo.getTotalDiscountAmount());
+            productPromoUse.set("quantityLeftInActions", productPromoUseInfo.getQuantityLeftInActions());
             productPromoUse.set("partyId", partyId);
             productPromoUses.add(productPromoUse);
             sequenceValue++;
@@ -3973,8 +3966,8 @@
                 
                 ShoppingCartItem cartItem = (ShoppingCartItem) siit.next();
 
-                double itemQuantity = cartItem.getQuantity();
-                double dropShipQuantity = 0;
+                BigDecimal itemQuantity = cartItem.getQuantity();
+                BigDecimal dropShipQuantity = BigDecimal.ZERO;
 
                 GenericValue product = cartItem.getProduct();
                 if (product == null) {
@@ -3995,12 +3988,12 @@
 
                         // Get ATP for the product
                         Map getProductInventoryAvailableResult = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId));
-                        double availableToPromise = ((Double) getProductInventoryAvailableResult.get("availableToPromiseTotal")).doubleValue();
+                        BigDecimal availableToPromise = (BigDecimal) getProductInventoryAvailableResult.get("availableToPromiseTotal");
 
-                        if (itemQuantity <= availableToPromise) {
-                            dropShipQuantity = 0;
+                        if (itemQuantity.compareTo(availableToPromise) <= 0) {
+                            dropShipQuantity = BigDecimal.ZERO;
                         } else {
-                            dropShipQuantity = itemQuantity - availableToPromise;
+                            dropShipQuantity = itemQuantity.subtract(availableToPromise);
                         }
 
                     } catch (Exception e) {
@@ -4009,15 +4002,15 @@
                 } else {
                     
                     // Don't drop ship anything if the product isn't so marked
-                    dropShipQuantity = 0;
+                    dropShipQuantity = BigDecimal.ZERO;
                 }
 
-                if (dropShipQuantity <= 0) continue;
+                if (dropShipQuantity.compareTo(BigDecimal.ZERO) <= 0) continue;
                 
                 // Find a supplier for the product
                 String supplierPartyId = null;
                 try {
-                    Map getSuppliersForProductResult = dispatcher.runSync("getSuppliersForProduct", UtilMisc.<String, Object>toMap("productId", productId, "quantity", new Double(dropShipQuantity), "canDropShip", "Y", "currencyUomId", getCurrency()));
+                    Map getSuppliersForProductResult = dispatcher.runSync("getSuppliersForProduct", UtilMisc.<String, Object>toMap("productId", productId, "quantity", dropShipQuantity, "canDropShip", "Y", "currencyUomId", getCurrency()));
                     List supplierProducts = (List) getSuppliersForProductResult.get("supplierProducts");
                     
                     // Order suppliers by supplierPrefOrderId so that preferred suppliers are used first
@@ -4039,7 +4032,7 @@
                 if (! supplierCartItems.containsKey(cartItem)) supplierCartItems.put(cartItem, new HashMap());
                 Map cartItemGroupQuantities = (Map) supplierCartItems.get(cartItem);
 
-                cartItemGroupQuantities.put(new Integer(shipGroupIndex), new Double(dropShipQuantity));
+                cartItemGroupQuantities.put(new Integer(shipGroupIndex), dropShipQuantity);
             }
         }
 
@@ -4073,7 +4066,7 @@
                 while (cigit.hasNext()) {
 
                     Integer previousShipGroupIndex = (Integer) cigit.next();
-                    double dropShipQuantity = ((Double) cartItemGroupQuantities.get(previousShipGroupIndex)).doubleValue();
+                    BigDecimal dropShipQuantity = (BigDecimal) cartItemGroupQuantities.get(previousShipGroupIndex);
                     positionItemToGroup(cartItem, dropShipQuantity, previousShipGroupIndex.intValue(), newShipGroupIndex, true);
                 }
             }
@@ -4091,7 +4084,7 @@
             ShoppingCartItem cartItem = (ShoppingCartItem) obj;
             ShoppingCartItem cartItem1 = (ShoppingCartItem) obj1;
 
-            int compareValue = new Double(cartItem.getBasePrice()).compareTo(new Double(cartItem1.getBasePrice()));
+            int compareValue = cartItem.getBasePrice().compareTo(cartItem1.getBasePrice());
             if (this.ascending) {
                 return compareValue;
             } else {
@@ -4178,10 +4171,10 @@
     public static class ProductPromoUseInfo implements Serializable {
         public String productPromoId = null;
         public String productPromoCodeId = null;
-        public double totalDiscountAmount = 0;
-        public double quantityLeftInActions = 0;
+        public BigDecimal totalDiscountAmount = BigDecimal.ZERO;
+        public BigDecimal quantityLeftInActions = BigDecimal.ZERO;
 
-        public ProductPromoUseInfo(String productPromoId, String productPromoCodeId, double totalDiscountAmount, double quantityLeftInActions) {
+        public ProductPromoUseInfo(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions) {
             this.productPromoId = productPromoId;
             this.productPromoCodeId = productPromoCodeId;
             this.totalDiscountAmount = totalDiscountAmount;
@@ -4190,8 +4183,8 @@
 
         public String getProductPromoId() { return this.productPromoId; }
         public String getProductPromoCodeId() { return this.productPromoCodeId; }
-        public double getTotalDiscountAmount() { return this.totalDiscountAmount; }
-        public double getQuantityLeftInActions() { return this.quantityLeftInActions; }
+        public BigDecimal getTotalDiscountAmount() { return this.totalDiscountAmount; }
+        public BigDecimal getQuantityLeftInActions() { return this.quantityLeftInActions; }
     }
 
     public static class CartShipInfo implements Serializable {
@@ -4208,7 +4201,7 @@
         public String shippingInstructions = null;
         public String maySplit = "N";
         public String isGift = "N";
-        public double shipEstimate = 0.00;
+        public BigDecimal shipEstimate = BigDecimal.ZERO;
         public Timestamp shipBeforeDate = null;
         public Timestamp shipAfterDate = null;
         public String shipGroupSeqId = null;
@@ -4223,7 +4216,7 @@
         public String getCarrierPartyId() { return carrierPartyId; }
         public String getSupplierPartyId() { return supplierPartyId; }
         public String getShipmentMethodTypeId() { return shipmentMethodTypeId; }
-        public double getShipEstimate() { return shipEstimate; }
+        public BigDecimal getShipEstimate() { return shipEstimate; }
         public String getShipGroupSeqId() { return shipGroupSeqId; }
         public String getFacilityId() { return facilityId; }
         public void setShipGroupSeqId(String shipGroupSeqId) {
@@ -4276,10 +4269,10 @@
             values.add(shipGroup);
 
             // create the shipping estimate adjustments
-            if (shipEstimate != 0) {
+            if (shipEstimate.compareTo(BigDecimal.ZERO) != 0) {
                 GenericValue shipAdj = delegator.makeValue("OrderAdjustment");
                 shipAdj.set("orderAdjustmentTypeId", "SHIPPING_CHARGES");
-                shipAdj.set("amount", new BigDecimal(shipEstimate));
+                shipAdj.set("amount", shipEstimate);
                 shipAdj.set("shipGroupSeqId", shipGroupSeqId);
                 values.add(shipAdj);
             }
@@ -4301,7 +4294,7 @@
                 GenericValue assoc = delegator.makeValue("OrderItemShipGroupAssoc");
                 assoc.set("orderItemSeqId", item.getOrderItemSeqId());
                 assoc.set("shipGroupSeqId", shipGroupSeqId);
-                assoc.set("quantity", new BigDecimal(itemInfo.quantity));
+                assoc.set("quantity", itemInfo.quantity);
                 values.add(assoc);
 
                 // create the item tax adjustment
@@ -4317,7 +4310,7 @@
             return values;
         }
 
-        public CartShipItemInfo setItemInfo(ShoppingCartItem item, double quantity, List taxAdj) {
+        public CartShipItemInfo setItemInfo(ShoppingCartItem item, BigDecimal quantity, List taxAdj) {
             CartShipItemInfo itemInfo = (CartShipItemInfo) shipItemInfo.get(item);
             if (itemInfo == null) {
                 if (!isShippableToAddress(item)) {
@@ -4327,7 +4320,7 @@
                 itemInfo.item = item;
                 shipItemInfo.put(item, itemInfo);
             }
-            if (quantity >= 0) {
+            if (quantity.compareTo(BigDecimal.ZERO) >= 0) {
                 itemInfo.quantity = quantity;
             }
             if (taxAdj != null) {
@@ -4338,10 +4331,10 @@
         }
 
         public CartShipItemInfo setItemInfo(ShoppingCartItem item, List taxAdj) {
-            return setItemInfo(item, -1, taxAdj);
+            return setItemInfo(item, BigDecimal.ONE.negate(), taxAdj);
         }
 
-        public CartShipItemInfo setItemInfo(ShoppingCartItem item, double quantity) {
+        public CartShipItemInfo setItemInfo(ShoppingCartItem item, BigDecimal quantity) {
             return setItemInfo(item, quantity, null);
         }
 
@@ -4397,58 +4390,58 @@
             }
         }
         
-        public double getTotalTax(ShoppingCart cart) {
+        public BigDecimal getTotalTax(ShoppingCart cart) {
             BigDecimal taxTotal = ZERO;
             for (int i = 0; i < shipTaxAdj.size(); i++) {
                 GenericValue v = (GenericValue) shipTaxAdj.get(i);
-                taxTotal = taxTotal.add(OrderReadHelper.calcOrderAdjustment(v, new BigDecimal(cart.getSubTotal())));
+                taxTotal = taxTotal.add(OrderReadHelper.calcOrderAdjustment(v, cart.getSubTotal()));
             }
 
             Iterator iter = shipItemInfo.values().iterator();
             while (iter.hasNext()) {
                 CartShipItemInfo info = (CartShipItemInfo) iter.next();
-                taxTotal = taxTotal.add(new BigDecimal(info.getItemTax(cart)));
+                taxTotal = taxTotal.add(info.getItemTax(cart));
             }
 
-            return taxTotal.doubleValue();
+            return taxTotal;
         }
         
-        public double getTotal() {
+        public BigDecimal getTotal() {
             BigDecimal shipItemTotal = ZERO;
             Iterator iter = shipItemInfo.values().iterator();
             while (iter.hasNext()) {
                 CartShipItemInfo info = (CartShipItemInfo) iter.next();
-                shipItemTotal = shipItemTotal.add(new BigDecimal(info.getItemSubTotal()));
+                shipItemTotal = shipItemTotal.add(info.getItemSubTotal());
             }
 
-            return shipItemTotal.doubleValue();
+            return shipItemTotal;
         }
 
         public static class CartShipItemInfo implements Serializable {
             public List itemTaxAdj = new LinkedList();
             public ShoppingCartItem item = null;
-            public double quantity = 0;
+            public BigDecimal quantity = BigDecimal.ZERO;
 
-            public double getItemTax(ShoppingCart cart) {
+            public BigDecimal getItemTax(ShoppingCart cart) {
                 BigDecimal itemTax = ZERO;
 
                 for (int i = 0; i < itemTaxAdj.size(); i++) {
                     GenericValue v = (GenericValue) itemTaxAdj.get(i);
-                    itemTax = itemTax.add(OrderReadHelper.calcItemAdjustment(v, new BigDecimal(quantity), new BigDecimal(item.getBasePrice())));
+                    itemTax = itemTax.add(OrderReadHelper.calcItemAdjustment(v, quantity, item.getBasePrice()));
                 }
 
-                return itemTax.setScale(taxCalcScale, taxRounding).doubleValue();
+                return itemTax.setScale(taxCalcScale, taxRounding);
             }
 
             public ShoppingCartItem getItem() {
                 return this.item;
             }
             
-            public double getItemQuantity() {
+            public BigDecimal getItemQuantity() {
                 return this.quantity;
             }
             
-            public double getItemSubTotal() {
+            public BigDecimal getItemSubTotal() {
                 return item.getItemSubTotal(quantity);
             }
         }
@@ -4462,7 +4455,7 @@
         public String postalCode = null;
         public String[] refNum = new String[2];
         public String track2 = null;
-        public Double amount = null;
+        public BigDecimal amount = null;
         public boolean singleUse = false;
         public boolean isPresent = false;    
         public boolean isSwiped = false;
@@ -4566,7 +4559,7 @@
                     Iterator shipIter = cart.getShipGroups().iterator();
                     while (shipIter.hasNext()) {
                         CartShipInfo csi = (CartShipInfo) shipIter.next();
-                        maxAmount = new BigDecimal(csi.getTotal()).add(new BigDecimal(cart.getOrderOtherAdjustmentTotal() / cart.getShipGroupSize())).add(new BigDecimal(csi.getShipEstimate()).add(new BigDecimal(csi.getTotalTax(cart))));
+                        maxAmount = csi.getTotal().add(cart.getOrderOtherAdjustmentTotal().divide(new BigDecimal(cart.getShipGroupSize()), generalRounding)).add(csi.getShipEstimate().add(csi.getTotalTax(cart)));
                         maxAmount = maxAmount.setScale(scale, rounding);
                         
                         // create the OrderPaymentPreference record
@@ -4606,7 +4599,7 @@
                         values.add(opp);
                     }
                 } else if ("N".equals(splitPayPrefPerShpGrp)) {
-                    maxAmount = maxAmount.add(new BigDecimal(amount));
+                    maxAmount = maxAmount.add(amount);
                     maxAmount = maxAmount.setScale(scale, rounding);
                     
                     // create the OrderPaymentPreference record

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,8 @@
  *******************************************************************************/
 package org.ofbiz.order.shoppingcart;
 
+import java.math.BigDecimal;
+import java.math.MathContext;
 import java.text.NumberFormat;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -73,6 +75,8 @@
     private static final String NON_CRITICAL_ERROR = "noncritical";
     private static final String ERROR = "error";
 
+    public static final MathContext generalRounding = new MathContext(10);
+
     public static String addProductPromoCode(HttpServletRequest request, HttpServletResponse response) {
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         ShoppingCart cart = getCartObject(request);
@@ -122,17 +126,17 @@
         String itemDescription = null;
         String productCategoryId = null;
         String priceStr = null;
-        Double price = null;
+        BigDecimal price = null;
         String quantityStr = null;
-        double quantity = 0;
+        BigDecimal quantity = BigDecimal.ZERO;
         String reservStartStr = null;
         String reservEndStr = null;
         java.sql.Timestamp reservStart = null;
         java.sql.Timestamp reservEnd = null;
         String reservLengthStr = null;
-        Double reservLength = null;
+        BigDecimal reservLength = null;
         String reservPersonsStr = null;
-        Double reservPersons = null;
+        BigDecimal reservPersons = null;
         String accommodationMapId = null;
         String accommodationSpotId = null;
         String shipBeforeDateStr = null;
@@ -323,18 +327,18 @@
             }
 
             if (reservStart != null && reservEnd != null) {
-            	reservLength = new Double(UtilDateTime.getInterval(reservStart,reservEnd)/86400000);
+            	reservLength = new BigDecimal(UtilDateTime.getInterval(reservStart,reservEnd)).divide(new BigDecimal("86400000"), generalRounding);
             }
 
             if (reservStart != null && paramMap.containsKey("reservLength")) {
                 reservLengthStr = (String) paramMap.remove("reservLength");
                 // parse the reservation Length
                 try {
-                    reservLength = new Double(nf.parse(reservLengthStr).doubleValue());
+                    reservLength = new BigDecimal(nf.parse(reservLengthStr).doubleValue());
                 } catch (Exception e) {
                     Debug.logWarning(e,"Problems parsing reservation length string: "
                                     + reservLengthStr, module);
-                    reservLength = new Double(1);
+                    reservLength = BigDecimal.ONE;
                     request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderReservationLengthShouldBeAPositiveNumber", locale));
                     return "error";
                 }
@@ -344,10 +348,10 @@
                 reservPersonsStr = (String) paramMap.remove("reservPersons");
                 // parse the number of persons
                 try {
-                    reservPersons = new Double(nf.parse(reservPersonsStr).doubleValue());
+                    reservPersons = new BigDecimal(nf.parse(reservPersonsStr).doubleValue());
                 } catch (Exception e) {
                     Debug.logWarning(e,"Problems parsing reservation number of persons string: " + reservPersonsStr, module);
-                    reservPersons = new Double(1);
+                    reservPersons = BigDecimal.ONE;
                     request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderNumberOfPersonsShouldBeOneOrLarger", locale));
                     return "error";
                 }
@@ -379,7 +383,7 @@
 
         // parse the price
         try {
-            price = new Double(nf.parse(priceStr).doubleValue());
+            price = new BigDecimal(nf.parse(priceStr).doubleValue());
         } catch (Exception e) {
             Debug.logWarning(e, "Problems parsing price string: " + priceStr, module);
             price = null;
@@ -387,10 +391,10 @@
 
         // parse the quantity
         try {
-            quantity = nf.parse(quantityStr).doubleValue();
+            quantity = new BigDecimal(nf.parse(quantityStr).doubleValue());
         } catch (Exception e) {
             Debug.logWarning(e, "Problems parsing quantity string: " + quantityStr, module);
-            quantity = 1;
+            quantity = BigDecimal.ONE;
         }
 
         // get the selected amount
@@ -402,10 +406,10 @@
         }
 
         // parse the amount
-        Double amount = null;
+        BigDecimal amount = null;
         if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
             try {
-                amount = new Double(nf.parse(selectedAmountStr).doubleValue());
+                amount = new BigDecimal(nf.parse(selectedAmountStr).doubleValue());
             } catch (Exception e) {
                 Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
                 amount = null;
@@ -685,7 +689,7 @@
         ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);
         String controlDirective;
         Map result;
-        Double totalQuantity;
+        BigDecimal totalQuantity;
         Locale locale = UtilHttp.getLocale(request);
 
         result = cartHelper.addCategoryDefaults(catalogId, categoryId, itemGroupNumber);
@@ -695,8 +699,8 @@
         if (controlDirective.equals(ERROR)) {
             return "error";
         } else {
-            totalQuantity = (Double)result.get("totalQuantity");
-            Map messageMap = UtilMisc.toMap("totalQuantity", UtilFormatOut.formatQuantity(totalQuantity) );
+            totalQuantity = (BigDecimal)result.get("totalQuantity");
+            Map messageMap = UtilMisc.toMap("totalQuantity", UtilFormatOut.formatQuantity(totalQuantity.doubleValue()) );
 
             request.setAttribute("_EVENT_MESSAGE_",
                                   UtilProperties.getMessage(resource, "cart.add_category_defaults",
@@ -1143,44 +1147,44 @@
         ShoppingCart cart = getCartObject(request);
         ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);
         String termTypeId = request.getParameter("termTypeId");
-        String termValue = request.getParameter("termValue");
-        String termDays = request.getParameter("termDays");
+        String termValueStr = request.getParameter("termValue");
+        String termDaysStr = request.getParameter("termDays");
         String termIndex = request.getParameter("termIndex");
         String textValue = request.getParameter("textValue");
         Locale locale = UtilHttp.getLocale(request);
 
-        Double dTermValue = null;
-        Long lTermDays = null;
+        BigDecimal termValue = null;
+        Long termDays = null;
 
-        if (termValue.trim().equals("")) {
+        if (termValueStr.trim().equals("")) {
             termValue = null;
         }
-        if (termDays.trim().equals("")) {
+        if (termDaysStr.trim().equals("")) {
             termDays = null;
         }
         if (UtilValidate.isEmpty(termTypeId)) {
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermTypeIsRequired", locale));
             return "error";
         }
-        if (!UtilValidate.isSignedDouble(termValue)) {
+        if (!UtilValidate.isSignedDouble(termValueStr)) {
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermValue", UtilMisc.toMap("orderTermValue",UtilValidate.isSignedFloatMsg), locale));
             return "error";
         }
         if (termValue != null) {
-            dTermValue =new Double(termValue);
+            termValue = new BigDecimal(termValueStr);
         }
-        if (!UtilValidate.isInteger(termDays)) {
+        if (!UtilValidate.isInteger(termDaysStr)) {
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermDays", UtilMisc.toMap("orderTermDays",UtilValidate.isLongMsg), locale));
             return "error";
         }
         if (termDays != null) {
-            lTermDays = new Long(termDays);
+            termDays = new Long(termDaysStr);
         }
         if ((termIndex != null) && (!"-1".equals(termIndex)) && (UtilValidate.isInteger(termIndex))) {
             cartHelper.removeOrderTerm(Integer.parseInt(termIndex));
         }
 
-        Map result = cartHelper.addOrderTerm(termTypeId, dTermValue, lTermDays, textValue);
+        Map result = cartHelper.addOrderTerm(termTypeId, termValue, termDays, textValue);
         if (ServiceUtil.isError(result)) {
             request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));
             return "error";
@@ -1540,7 +1544,7 @@
         String productCategoryId = null;
         String quantityStr = null;
         String itemDesiredDeliveryDateStr = null;
-        double quantity = 0;
+        BigDecimal quantity = BigDecimal.ZERO;
         String catalogId = CatalogWorker.getCurrentCatalogId(request);
         String itemType = null;
         String itemDescription = "";
@@ -1577,10 +1581,10 @@
 
                 // parse the quantity
                 try {
-                    quantity = NumberFormat.getNumberInstance().parse(quantityStr).doubleValue();
+                    quantity = new BigDecimal(quantityStr);
                 } catch (Exception e) {
                     Debug.logWarning(e, "Problems parsing quantity string: " + quantityStr, module);
-                    quantity = 0;
+                    quantity = BigDecimal.ZERO;
                 }
 
                 // get the selected amount
@@ -1590,10 +1594,10 @@
                 }
 
                 // parse the amount
-                Double amount = null;
+                BigDecimal amount = null;
                 if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
                     try {
-                        amount = new Double(NumberFormat.getNumberInstance().parse(selectedAmountStr).doubleValue());
+                        amount = new BigDecimal(selectedAmountStr);
                     } catch (Exception e) {
                         Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
                         amount = null;
@@ -1614,7 +1618,7 @@
 
                 Map itemAttributes = UtilMisc.toMap("itemDesiredDeliveryDate", itemDesiredDeliveryDateStr);
 
-                if (quantity > 0) {
+                if (quantity.compareTo(BigDecimal.ZERO) > 0) {
                     Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + productCategoryId +
                             ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, module);
                     result = cartHelper.addToCart(catalogId, shoppingListId, shoppingListItemSeqId, productId,