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 [6/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/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Sun Nov 30 22:51:11 2008
@@ -19,6 +19,7 @@
 package org.ofbiz.order.shoppingcart;
 
 import java.math.BigDecimal;
+import java.math.MathContext;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -60,12 +61,14 @@
     public static final String resource = "OrderUiLabels";
     public static final String resource_error = "OrderErrorUiLabels";
 
+    public static final MathContext generalRounding = new MathContext(10);
+
     public static Map assignItemShipGroup(DispatchContext dctx, Map context) {
         ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
         Integer fromGroupIndex = (Integer) context.get("fromGroupIndex");
         Integer toGroupIndex = (Integer) context.get("toGroupIndex");
         Integer itemIndex = (Integer) context.get("itemIndex");
-        Double quantity = (Double) context.get("quantity");
+        BigDecimal quantity = (BigDecimal) context.get("quantity");
         Boolean clearEmptyGroups = (Boolean) context.get("clearEmptyGroups");
 
         if (clearEmptyGroups == null) {
@@ -78,7 +81,7 @@
             return ServiceUtil.returnSuccess();
         }
 
-        cart.positionItemToGroup(itemIndex.intValue(), quantity.doubleValue(),
+        cart.positionItemToGroup(itemIndex.intValue(), quantity,
                 fromGroupIndex.intValue(), toGroupIndex.intValue(), clearEmptyGroups.booleanValue());
         Debug.log("Called cart.positionItemToGroup()", module);
 
@@ -246,7 +249,7 @@
                 if (paymentId == null) {
                     paymentId = opp.getString("paymentMethodTypeId");
                 }
-                Double maxAmount = opp.getDouble("maxAmount");
+                BigDecimal maxAmount = opp.getBigDecimal("maxAmount");
                 String overflow = opp.getString("overflowFlag");
 
                 ShoppingCart.CartPaymentInfo cpi = null;
@@ -294,19 +297,18 @@
                 }
 
                 // not a promo item; go ahead and add it in
-                Double amount = item.getDouble("selectedAmount");
+                BigDecimal amount = item.getBigDecimal("selectedAmount");
                 if (amount == null) {
-                    amount = new Double(0);
+                    amount = BigDecimal.ZERO;
                 }
-                double quantityDbl = 0;
                 BigDecimal quantity = item.getBigDecimal("quantity");
-                if (quantity != null) {
-                    quantityDbl = quantity.doubleValue();
+                if (quantity == null) {
+                    quantity = BigDecimal.ZERO;
                 }
                 
-                Double unitPrice = null;
+                BigDecimal unitPrice = null;
                 if ("Y".equals(item.getString("isModifiedPrice"))) {
-                    unitPrice = item.getDouble("unitPrice");
+                    unitPrice = item.getBigDecimal("unitPrice");
                 }
                 
                 int itemIndex = -1;
@@ -316,7 +318,7 @@
                     String desc = item.getString("itemDescription");
                     try {
                         // TODO: passing in null now for itemGroupNumber, but should reproduce from OrderItemGroup records
-                        itemIndex = cart.addNonProductItem(itemType, desc, null, unitPrice, quantity.doubleValue(), null, null, null, dispatcher);
+                        itemIndex = cart.addNonProductItem(itemType, desc, null, unitPrice, quantity, null, null, null, dispatcher);
                     } catch (CartItemModifyException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
@@ -328,8 +330,8 @@
                     
                     //prepare the rental data
                     Timestamp reservStart = null;
-                    Double reservLength = null;
-                    Double reservPersons = null;
+                    BigDecimal reservLength = null;
+                    BigDecimal reservPersons = null;
                     String accommodationMapId = null;
                     String accommodationSpotId = null;
                     
@@ -344,8 +346,8 @@
                     }             
                     if (workEffort != null && "ASSET_USAGE".equals(workEffort.getString("workEffortTypeId"))){
                         reservStart = workEffort.getTimestamp("estimatedStartDate");
-                        reservLength = OrderReadHelper.getWorkEffortRentalLenght(workEffort);
-                        reservPersons = workEffort.getDouble("reservPersons");
+                        reservLength = OrderReadHelper.getWorkEffortRentalLength(workEffort);
+                        reservPersons = workEffort.getBigDecimal("reservPersons");
                         accommodationMapId = workEffort.getString("accommodationMapId");
                         accommodationSpotId = workEffort.getString("accommodationSpotId");
                         
@@ -372,7 +374,7 @@
                         configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, prodCatalogId, website, currency, locale, userLogin);
                     }                     
                     try {
-                        itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, unitPrice, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, skipProductChecks);
+                        itemIndex = cart.addItemToEnd(productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, skipProductChecks);
                     } catch (ItemNotFoundException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
@@ -406,9 +408,9 @@
                 List shipGroups = orh.getOrderItemShipGroupAssocs(item);
                 for (int g = 0; g < shipGroups.size(); g++) {
                     GenericValue sgAssoc = (GenericValue) shipGroups.get(g);
-                    Double shipGroupQty = OrderReadHelper.getOrderItemShipGroupQuantity(sgAssoc);
+                    BigDecimal shipGroupQty = OrderReadHelper.getOrderItemShipGroupQuantity(sgAssoc);
                     if (shipGroupQty == null) {
-                        shipGroupQty = new Double(0);
+                        shipGroupQty = BigDecimal.ZERO;
                     }
 
                     GenericValue sg = null;
@@ -427,7 +429,7 @@
                     cart.setGiftMessage(g, sg.getString("giftMessage"));
                     cart.setShippingContactMechId(g, sg.getString("contactMechId"));
                     cart.setShippingInstructions(g, sg.getString("shippingInstructions"));
-                    cart.setItemShipGroupQty(itemIndex, shipGroupQty.doubleValue(), g);
+                    cart.setItemShipGroupQty(itemIndex, shipGroupQty, g);
                 }
             }
 
@@ -600,28 +602,28 @@
                 }
 
                 // not a promo item; go ahead and add it in
-                Double amount = item.getDouble("selectedAmount");
+                BigDecimal amount = item.getBigDecimal("selectedAmount");
                 if (amount == null) {
-                    amount = new Double(0);
+                    amount = BigDecimal.ZERO;
                 }
-                Double quantity = item.getDouble("quantity");
+                BigDecimal quantity = item.getBigDecimal("quantity");
                 if (quantity == null) {
-                    quantity = new Double(0);
+                    quantity = BigDecimal.ZERO;
                 }
-                Double quoteUnitPrice = item.getDouble("quoteUnitPrice");
+                BigDecimal quoteUnitPrice = item.getBigDecimal("quoteUnitPrice");
                 if (quoteUnitPrice == null) {
-                    quoteUnitPrice = new Double(0);
+                    quoteUnitPrice = BigDecimal.ZERO;
                 }
-                if (amount.doubleValue() > 0) {
+                if (amount.compareTo(BigDecimal.ZERO) > 0) {
                     // If, in the quote, an amount is set, we need to
                     // pass to the cart the quoteUnitPrice/amount value.
-                    quoteUnitPrice = new Double(quoteUnitPrice.doubleValue() / amount.doubleValue());
+                    quoteUnitPrice = quoteUnitPrice.divide(amount, generalRounding);
                 }
                 
                 //rental product data
                 Timestamp reservStart = item.getTimestamp("reservStart");
-                Double reservLength = item.getDouble("reservLength");
-                Double reservPersons = item.getDouble("reservPersons");
+                BigDecimal reservLength = item.getBigDecimal("reservLength");
+                BigDecimal reservPersons = item.getBigDecimal("reservPersons");
                 //String accommodationMapId = item.getString("accommodationMapId");
                 //String accommodationSpotId = item.getString("accommodationSpotId");
                 
@@ -631,7 +633,7 @@
                     String desc = item.getString("comments");
                     try {
                         // note that passing in null for itemGroupNumber as there is no real grouping concept in the quotes right now
-                        itemIndex = cart.addNonProductItem(null, desc, null, null, quantity.doubleValue(), null, null, null, dispatcher);
+                        itemIndex = cart.addNonProductItem(null, desc, null, null, quantity, null, null, null, dispatcher);
                     } catch (CartItemModifyException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
@@ -644,7 +646,7 @@
                         configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, item.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin);
                     }                    
                     try {
-                            itemIndex = cart.addItemToEnd(productId, amount, quantity.doubleValue(), quoteUnitPrice, reservStart, reservLength, reservPersons,null,null, null, null, null, configWrapper, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.doubleValue() == 0), Boolean.FALSE, Boolean.FALSE);
+                            itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons,null,null, null, null, null, configWrapper, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0), Boolean.FALSE, Boolean.FALSE);
                             
                     } catch (ItemNotFoundException e) {
                         Debug.logError(e, module);
@@ -782,14 +784,14 @@
                     return ServiceUtil.returnError(e.getMessage());
                 }
                 /*
-                Double amount = item.getDouble("selectedAmount");
+                BigDecimal amount = item.getBigDecimal("selectedAmount");
                 if (amount == null) {
-                    amount = new Double(0);
+                    amount = BigDecimal.ZERO;
                 }
                  */
-                Double quantity = item.getDouble("quantity");
+                BigDecimal quantity = item.getBigDecimal("quantity");
                 if (quantity == null) {
-                    quantity = new Double(0);
+                    quantity = BigDecimal.ZERO;
                 }
                 int itemIndex = -1;
                 if (item.get("productId") != null) {
@@ -800,7 +802,7 @@
                         configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, item.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin);
                     }
                     try {
-                        itemIndex = cart.addItemToEnd(productId, null, quantity.doubleValue(), null, null, null, null, null, configWrapper, dispatcher, Boolean.TRUE, Boolean.TRUE);
+                        itemIndex = cart.addItemToEnd(productId, null, quantity, null, null, null, null, null, configWrapper, dispatcher, Boolean.TRUE, Boolean.TRUE);
                     } catch (ItemNotFoundException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
@@ -840,25 +842,25 @@
         ShoppingCart shoppingCart = (ShoppingCart) context.get("shoppingCart");
         if(shoppingCart != null){
             String isoCode = shoppingCart.getCurrency();
-            result.put("totalQuantity",new Double(shoppingCart.getTotalQuantity()));
+            result.put("totalQuantity", shoppingCart.getTotalQuantity());
             result.put("currencyIsoCode",isoCode);
-            result.put("subTotal",new Double(shoppingCart.getSubTotal()));
-            result.put("subTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getSubTotal(),isoCode,locale));
-            result.put("totalShipping",new Double(shoppingCart.getTotalShipping()));
-            result.put("totalShippingCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalShipping(),isoCode,locale));
-            result.put("totalSalesTax",new Double(shoppingCart.getTotalSalesTax()));
-            result.put("totalSalesTaxCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalSalesTax(),isoCode,locale));
-            result.put("displayGrandTotal",new Double(shoppingCart.getDisplayGrandTotal()));
-            result.put("displayGrandTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(),isoCode,locale));
-            double orderAdjustmentsTotal = OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), BigDecimal.valueOf(shoppingCart.getSubTotal()), true, true, true).doubleValue();
+            result.put("subTotal", shoppingCart.getSubTotal());
+            result.put("subTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getSubTotal(), isoCode, locale));
+            result.put("totalShipping", shoppingCart.getTotalShipping());
+            result.put("totalShippingCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalShipping(), isoCode, locale));
+            result.put("totalSalesTax",shoppingCart.getTotalSalesTax());
+            result.put("totalSalesTaxCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalSalesTax(), isoCode, locale));
+            result.put("displayGrandTotal", shoppingCart.getDisplayGrandTotal());
+            result.put("displayGrandTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(), isoCode, locale));
+            BigDecimal orderAdjustmentsTotal = OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), shoppingCart.getSubTotal(), true, true, true);
             result.put("displayOrderAdjustmentsTotalCurrencyFormatted", org.ofbiz.base.util.UtilFormatOut.formatCurrency(orderAdjustmentsTotal, isoCode, locale));
             Iterator i = shoppingCart.iterator();
             Map cartItemData = FastMap.newInstance();
             while (i.hasNext()) {
                 ShoppingCartItem cartLine = (ShoppingCartItem) i.next();
                 int cartLineIndex = shoppingCart.getItemIndex(cartLine);
-                cartItemData.put("displayItemSubTotal_" + cartLineIndex ,new Double(cartLine.getDisplayItemSubTotal()));
-                cartItemData.put("displayItemSubTotalCurrencyFormatted_" + cartLineIndex ,org.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayItemSubTotal(),isoCode,locale));
+                cartItemData.put("displayItemSubTotal_" + cartLineIndex, cartLine.getDisplayItemSubTotal());
+                cartItemData.put("displayItemSubTotalCurrencyFormatted_" + cartLineIndex ,org.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayItemSubTotal(), isoCode, locale));
                 cartItemData.put("displayItemAdjustment_" + cartLineIndex ,org.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getOtherAdjustments(), isoCode, locale));
             }
             result.put("cartItemData",cartItemData);

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,8 @@
  *******************************************************************************/
 package org.ofbiz.order.shoppingcart.product;
 
+import java.math.BigDecimal;
+import java.math.MathContext;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -131,7 +133,7 @@
 
             // randomly remove products while there are more than 3
             while (cartAssocs.size() > 3) {
-                int toRemove = (int) (Math.random() * (double) (cartAssocs.size()));
+                int toRemove = (int) (Math.random() *  cartAssocs.size());
                 cartAssocs.remove(toRemove);
             }
         } catch (GenericEntityException e) {
@@ -188,13 +190,13 @@
 
                                 products.put(product.get("productId"), product);
 
-                                Integer curQuant = (Integer) productQuantities.get(product.get("productId"));
+                                BigDecimal curQuant = (BigDecimal) productQuantities.get(product.get("productId"));
 
-                                if (curQuant == null) curQuant = new Integer(0);
-                                Double orderQuant = orderItem.getDouble("quantity");
+                                if (curQuant == null) curQuant = BigDecimal.ZERO;
+                                BigDecimal orderQuant = orderItem.getBigDecimal("quantity");
 
-                                if (orderQuant == null) orderQuant = new Double(0.0);
-                                productQuantities.put(product.get("productId"), new Integer(curQuant.intValue() + orderQuant.intValue()));
+                                if (orderQuant == null) orderQuant = BigDecimal.ZERO;
+                                productQuantities.put(product.get("productId"), curQuant.add(orderQuant));
 
                                 Integer curOcc = (Integer) productOccurances.get(product.get("productId"));
 
@@ -211,12 +213,12 @@
                 while (quantEntries.hasNext()) {
                     Map.Entry entry = (Map.Entry) quantEntries.next();
                     Object prodId = entry.getKey();
-                    Integer quantity = (Integer) entry.getValue();
+                    BigDecimal quantity = (BigDecimal) entry.getValue();
                     Integer occs = (Integer) productOccurances.get(prodId);
-                    int nqint = quantity.intValue() / occs.intValue();
+                    BigDecimal nqint = quantity.divide(new BigDecimal(occs), new MathContext(10));
 
-                    if (nqint < 1) nqint = 1;
-                    productQuantities.put(prodId, new Integer(nqint));
+                    if (nqint.compareTo(BigDecimal.ONE) < 0) nqint = BigDecimal.ONE;
+                    productQuantities.put(prodId, nqint);
                 }
 
                 httpRequest.getSession().setAttribute("_QUICK_REORDER_PRODUCTS_", new HashMap(products));
@@ -272,8 +274,8 @@
              */
 
             // sort descending by new metric...
-            double occurancesModifier = 1.0;
-            double quantityModifier = 1.0;
+            BigDecimal occurancesModifier = BigDecimal.ONE;
+            BigDecimal quantityModifier = BigDecimal.ONE;
             Map newMetric = new HashMap();
             Iterator occurEntries = productOccurances.entrySet().iterator();
 
@@ -281,10 +283,10 @@
                 Map.Entry entry = (Map.Entry) occurEntries.next();
                 Object prodId = entry.getKey();
                 Integer quantity = (Integer) entry.getValue();
-                Integer occs = (Integer) productQuantities.get(prodId);
-                double nqdbl = quantity.doubleValue() * quantityModifier + occs.doubleValue() * occurancesModifier;
+                BigDecimal occs = (BigDecimal) productQuantities.get(prodId);
+                BigDecimal nqdbl = quantityModifier.multiply(new BigDecimal(quantity)).add(occs.multiply(occurancesModifier));
 
-                newMetric.put(prodId, new Double(nqdbl));
+                newMetric.put(prodId, nqdbl);
             }
             reorderProds = productOrderByMap(reorderProds, newMetric, true);
 

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Sun Nov 30 22:51:11 2008
@@ -19,6 +19,7 @@
 package org.ofbiz.order.shoppingcart.product;
 
 import java.math.BigDecimal;
+import java.math.MathContext;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -72,6 +73,8 @@
 
     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 List getStoreProductPromos(GenericDelegator delegator, LocalDispatcher dispatcher, ServletRequest request) {
         List productPromos = FastList.newInstance();
@@ -286,7 +289,7 @@
             Iterator productPromoIter = productPromoList.iterator();
             while (productPromoIter.hasNext()) {
                 GenericValue productPromo = (GenericValue) productPromoIter.next();
-                Map productPromoDiscountMap = UtilMisc.toMap("productPromo", productPromo, "totalDiscountAmount", new Double(cart.getProductPromoUseTotalDiscount(productPromo.getString("productPromoId"))));
+                Map productPromoDiscountMap = UtilMisc.toMap("productPromo", productPromo, "totalDiscountAmount", cart.getProductPromoUseTotalDiscount(productPromo.getString("productPromoId")));
                 if (hasOrderTotalCondition(productPromo, delegator)) {
                     productPromoDiscountMapListOrderTotal.add(productPromoDiscountMap);
                 } else {
@@ -347,7 +350,7 @@
         
         // set a max limit on how many times each promo can be run, for cases where there is no use limit this will be the use limit
         //default to 2 times the number of items in the cart
-        long maxUseLimit = 2 * Math.round(cart.getTotalQuantity());
+        long maxUseLimit = cart.getTotalQuantity().multiply(BigDecimal.valueOf(2)).setScale(0, BigDecimal.ROUND_CEILING).longValue();
         
         try {
             // repeat until no more rules to run: either all rules are run, or no changes to the cart in a loop
@@ -685,8 +688,8 @@
                 (!requireCode || UtilValidate.isNotEmpty(productPromoCodeId)) &&
                 (codeUseLimit == null || codeUseLimit.longValue() > cart.getProductPromoCodeUse(productPromoCodeId))) {
             boolean promoUsed = false;
-            double totalDiscountAmount = 0;
-            double quantityLeftInActions = 0;
+            BigDecimal totalDiscountAmount = BigDecimal.ZERO;
+            BigDecimal quantityLeftInActions = BigDecimal.ZERO;
 
             Iterator promoRulesIter = productPromoRules.iterator();
             while (promoRulesIter != null && promoRulesIter.hasNext()) {
@@ -726,8 +729,8 @@
                         // Debug.logInfo("Doing action: " + productPromoAction, module);
                         try {
                             ActionResultInfo actionResultInfo = performAction(productPromoAction, cart, delegator, dispatcher, nowTimestamp);
-                            totalDiscountAmount += actionResultInfo.totalDiscountAmount;
-                            quantityLeftInActions += actionResultInfo.quantityLeftInAction;
+                            totalDiscountAmount = totalDiscountAmount.add(actionResultInfo.totalDiscountAmount);
+                            quantityLeftInActions = quantityLeftInActions.add(actionResultInfo.quantityLeftInAction);
                             
                             // only set if true, don't set back to false: implements OR logic (ie if ANY actions change content, redo loop)
                             boolean actionChangedCart = actionResultInfo.ranAction;
@@ -778,9 +781,9 @@
             operatorEnumId = "PPC_EQ";
             
             // this type of condition requires items involved to not be involved in any other quantity consuming cond/action, and does not pro-rate the price, just uses the base price
-            double amountNeeded = 0.0;
+            BigDecimal amountNeeded = BigDecimal.ZERO;
             if (UtilValidate.isNotEmpty(condValue)) {
-                amountNeeded = Double.parseDouble(condValue);
+                amountNeeded = new BigDecimal(condValue);
             }
 
             // Debug.logInfo("Doing Amount Cond with Value: " + amountNeeded, module);
@@ -789,7 +792,7 @@
 
             List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
             Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
-            while (amountNeeded > 0 && lineOrderedByBasePriceIter.hasNext()) {
+            while (amountNeeded.compareTo(BigDecimal.ZERO) > 0 && lineOrderedByBasePriceIter.hasNext()) {
                 ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();
                 // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
                 GenericValue product = cartItem.getProduct();
@@ -798,21 +801,21 @@
                         (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) && 
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     
-                    double basePrice = cartItem.getBasePrice();
+                    BigDecimal basePrice = cartItem.getBasePrice();
                     // get a rough price, round it up to an integer
-                    double quantityNeeded = Math.ceil(amountNeeded / basePrice);
+                    BigDecimal quantityNeeded = amountNeeded.divide(basePrice, generalRounding).setScale(0, BigDecimal.ROUND_CEILING);
                     
                     // reduce amount still needed to qualify for promo (amountNeeded)
-                    double quantity = cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false);
+                    BigDecimal quantity = cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false);
                     // get pro-rated amount based on discount
-                    amountNeeded -= (quantity * basePrice);
+                    amountNeeded = amountNeeded.subtract(quantity.multiply(basePrice));
                 }
             }
 
             // Debug.logInfo("Doing Amount Cond with Value after finding applicable cart lines: " + amountNeeded, module);
             
             // if amountNeeded > 0 then the promo condition failed, so remove candidate promo uses and increment the promoQuantityUsed to restore it
-            if (amountNeeded > 0) {
+            if (amountNeeded.compareTo(BigDecimal.ZERO) > 0) {
                 // failed, reset the entire rule, ie including all other conditions that might have been done before
                 cart.resetPromoRuleUse(productPromoCond.getString("productPromoId"), productPromoCond.getString("productPromoRuleId"));
                 compareBase = new Integer(-1);
@@ -823,8 +826,8 @@
             }
         } else if ("PPIP_PRODUCT_TOTAL".equals(inputParamEnumId)) {
             // this type of condition allows items involved to be involved in other quantity consuming cond/action, and does pro-rate the price
-            Double amountNeeded = Double.valueOf(condValue);
-            double amountAvailable = 0;
+        	BigDecimal amountNeeded = new BigDecimal(condValue);
+        	BigDecimal amountAvailable = BigDecimal.ZERO;
 
             // Debug.logInfo("Doing Amount Not Counted Cond with Value: " + amountNeeded, module);
             
@@ -842,27 +845,27 @@
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     
                     // just count the entire sub-total of the item
-                    amountAvailable += cartItem.getItemSubTotal();
+                    amountAvailable = amountAvailable.add(cartItem.getItemSubTotal());
                 }
             }
 
             // Debug.logInfo("Doing Amount Not Counted Cond with Value after finding applicable cart lines: " + amountNeeded, module);
             
-            compareBase = new Integer(new Double(amountAvailable).compareTo(amountNeeded));
+            compareBase = new Integer(amountAvailable.compareTo(amountNeeded));
         } else if ("PPIP_PRODUCT_QUANT".equals(inputParamEnumId)) {
             // for this type of promo force the operatorEnumId = PPC_EQ, effectively ignore that setting because the comparison is implied in the code
             operatorEnumId = "PPC_EQ";
             
-            double quantityNeeded = 1.0;
+            BigDecimal quantityNeeded = BigDecimal.ONE;
             if (UtilValidate.isNotEmpty(condValue)) {
-                quantityNeeded = Double.parseDouble(condValue);
+                quantityNeeded = new BigDecimal(condValue);
             }
 
             Set productIds = ProductPromoWorker.getPromoRuleCondProductIds(productPromoCond, delegator, nowTimestamp);
 
             List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
             Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
-            while (quantityNeeded > 0 && lineOrderedByBasePriceIter.hasNext()) {
+            while (quantityNeeded.compareTo(BigDecimal.ZERO) > 0 && lineOrderedByBasePriceIter.hasNext()) {
                 ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();
                 // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
                 GenericValue product = cartItem.getProduct();
@@ -871,12 +874,12 @@
                         (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) && 
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     // reduce quantity still needed to qualify for promo (quantityNeeded)
-                    quantityNeeded -= cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false);
+                    quantityNeeded = quantityNeeded.subtract(cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false));
                 }
             }
 
             // if quantityNeeded > 0 then the promo condition failed, so remove candidate promo uses and increment the promoQuantityUsed to restore it
-            if (quantityNeeded > 0) {
+            if (quantityNeeded.compareTo(BigDecimal.ZERO) > 0) {
                 // failed, reset the entire rule, ie including all other conditions that might have been done before
                 cart.resetPromoRuleUse(productPromoCond.getString("productPromoId"), productPromoCond.getString("productPromoRuleId"));
                 compareBase = new Integer(-1);
@@ -944,12 +947,12 @@
             }
         */
         } else if ("PPIP_NEW_ACCT".equals(inputParamEnumId)) {
-            Double acctDays = cart.getPartyDaysSinceCreated(nowTimestamp);
+            BigDecimal acctDays = cart.getPartyDaysSinceCreated(nowTimestamp);
             if (acctDays == null) {
                 // condition always fails if we don't know how many days since account created
                 return false;
             }
-            compareBase = new Integer(acctDays.compareTo(Double.valueOf(condValue)));
+            compareBase = acctDays.compareTo(new BigDecimal(condValue));
         } else if ("PPIP_PARTY_ID".equals(inputParamEnumId)) {
             if (partyId != null) {
                 compareBase = new Integer(partyId.compareTo(condValue));
@@ -1008,9 +1011,9 @@
                 compareBase = new Integer(1);
             }
         } else if ("PPIP_ORDER_TOTAL".equals(inputParamEnumId)) {
-            Double orderSubTotal = new Double(cart.getSubTotalForPromotions());
+            BigDecimal orderSubTotal = cart.getSubTotalForPromotions();
             if (Debug.verboseOn()) Debug.logVerbose("Doing order total compare: orderSubTotal=" + orderSubTotal, module);
-            compareBase = new Integer(orderSubTotal.compareTo(Double.valueOf(condValue)));
+            compareBase = new Integer(orderSubTotal.compareTo(new BigDecimal(condValue)));
         } else if ("PPIP_ORST_HIST".equals(inputParamEnumId)) {
             // description="Order sub-total X in last Y Months"
             if (partyId != null && userLogin != null) {
@@ -1026,9 +1029,9 @@
                         Debug.logError("Error calling getOrderedSummaryInformation service for the PPIP_ORST_HIST ProductPromo condition input value: " + ServiceUtil.getErrorMessage(result), module);
                         return false;
                     } else {
-                        Double orderSubTotal = (Double) result.get("totalSubRemainingAmount");
+                        BigDecimal orderSubTotal = (BigDecimal) result.get("totalSubRemainingAmount");
                         if (Debug.verboseOn()) Debug.logVerbose("Doing order history sub-total compare: orderSubTotal=" + orderSubTotal + ", for the last " + monthsToInclude + " months.", module);
-                        compareBase = new Integer(orderSubTotal.compareTo(Double.valueOf(condValue)));
+                        compareBase = new Integer(orderSubTotal.compareTo(new BigDecimal(condValue)));
                     }
                 } catch (GenericServiceException e) {
                     Debug.logError(e, "Error getting order history sub-total in the getOrderedSummaryInformation service, evaluating condition to false.", module);
@@ -1087,8 +1090,8 @@
     
     public static class ActionResultInfo {
         public boolean ranAction = false;
-        public double totalDiscountAmount = 0;
-        public double quantityLeftInAction = 0;
+        public BigDecimal totalDiscountAmount = BigDecimal.ZERO;
+        public BigDecimal quantityLeftInAction = BigDecimal.ZERO;
     }
 
     /** returns true if the cart was changed and rules need to be re-evaluted */
@@ -1108,7 +1111,7 @@
                 if (Debug.verboseOn()) Debug.logVerbose("Not adding promo item, already there; action: " + productPromoAction, module);
                 actionResultInfo.ranAction = false;
             } else {
-                double quantity = productPromoAction.get("quantity") == null ? 0.0 : productPromoAction.getDouble("quantity").doubleValue();
+                BigDecimal quantity = productPromoAction.get("quantity") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("quantity");
                 
                 List optionProductIds = FastList.newInstance();
                 String productId = productPromoAction.getString("productId");
@@ -1137,7 +1140,7 @@
                         // check inventory on this product, make sure it is available before going on
                         //NOTE: even though the store may not require inventory for purchase, we will always require inventory for gifts
                         try {
-                            Map invReqResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productId, "product", product, "quantity", new Double(quantity)));
+                            Map invReqResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productId, "product", product, "quantity", quantity));
                             if (ServiceUtil.isError(invReqResult)) {
                                 Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invReqResult, module);
                                 throw new CartItemModifyException((String) invReqResult.get(ModelService.ERROR_MESSAGE));
@@ -1166,7 +1169,7 @@
                     String optionProductId = (String) optionProductIdIter.next();
 
                     try {
-                        Map invReqResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", optionProductId, "product", product, "quantity", new Double(quantity)));
+                        Map invReqResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", optionProductId, "product", product, "quantity", quantity));
                         if (ServiceUtil.isError(invReqResult)) {
                             Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invReqResult, module);
                             throw new CartItemModifyException((String) invReqResult.get(ModelService.ERROR_MESSAGE));
@@ -1227,7 +1230,7 @@
                     throw e;
                 }
 
-                double discountAmount = -(quantity * gwpItem.getBasePrice());
+                BigDecimal discountAmount = quantity.multiply(gwpItem.getBasePrice()).negate();
 
                 doOrderItemPromoAction(productPromoAction, gwpItem, discountAmount, "amount", delegator);
                 
@@ -1247,15 +1250,15 @@
             actionResultInfo.ranAction = true;
             // should probably set the totalDiscountAmount to something, but we have no idea what it will be, so leave at 0, will still get run
         } else if ("PROMO_PROD_DISC".equals(productPromoActionEnumId)) {
-            double quantityDesired = productPromoAction.get("quantity") == null ? 1.0 : productPromoAction.getDouble("quantity").doubleValue();
-            double startingQuantity = quantityDesired;
-            double discountAmountTotal = 0;
+            BigDecimal quantityDesired = productPromoAction.get("quantity") == null ? BigDecimal.ONE : productPromoAction.getBigDecimal("quantity");
+            BigDecimal startingQuantity = quantityDesired;
+            BigDecimal discountAmountTotal = BigDecimal.ZERO;
 
             Set productIds = ProductPromoWorker.getPromoRuleActionProductIds(productPromoAction, delegator, nowTimestamp);
 
             List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
             Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
-            while (quantityDesired > 0 && lineOrderedByBasePriceIter.hasNext()) {
+            while (quantityDesired.compareTo(BigDecimal.ZERO) > 0 && lineOrderedByBasePriceIter.hasNext()) {
                 ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();
                 // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
                 GenericValue product = cartItem.getProduct();
@@ -1264,27 +1267,27 @@
                         (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) &&
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     // reduce quantity still needed to qualify for promo (quantityNeeded)
-                    double quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
-                    if (quantityUsed > 0) {
-                        quantityDesired -= quantityUsed;
+                    BigDecimal quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
+                    if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
+                        quantityDesired = quantityDesired.subtract(quantityUsed);
 
                         // create an adjustment and add it to the cartItem that implements the promotion action
-                        double percentModifier = productPromoAction.get("amount") == null ? 0.0 : (productPromoAction.getDouble("amount").doubleValue()/100.0);
-                        double lineAmount = quantityUsed * cartItem.getBasePrice() * cartItem.getRentalAdjustment();
-                        double discountAmount = -(lineAmount * percentModifier);
-                        discountAmountTotal += discountAmount;
+                        BigDecimal percentModifier = productPromoAction.get("amount") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("amount").movePointLeft(2);
+                        BigDecimal lineAmount = quantityUsed.multiply(cartItem.getBasePrice()).multiply(cartItem.getRentalAdjustment());
+                        BigDecimal discountAmount = lineAmount.multiply(percentModifier).negate();
+                        discountAmountTotal = discountAmountTotal.add(discountAmount);
                         // not doing this any more, now distributing among conditions and actions (see call below): doOrderItemPromoAction(productPromoAction, cartItem, discountAmount, "amount", delegator);
                     }
                 }
             }
 
-            if (quantityDesired == startingQuantity || quantityDesired > 0) {
+            if (quantityDesired == startingQuantity || quantityDesired.compareTo(BigDecimal.ZERO) > 0) {
                 // couldn't find any (or enough) cart items to give a discount to, don't consider action run
                 actionResultInfo.ranAction = false;
                 // clear out any action uses for this so they don't become part of anything else
                 cart.resetPromoRuleUse(productPromoAction.getString("productPromoId"), productPromoAction.getString("productPromoRuleId"));
             } else {
-                double totalAmount = getCartItemsUsedTotalAmount(cart, productPromoAction);
+            	BigDecimal totalAmount = getCartItemsUsedTotalAmount(cart, productPromoAction);
                 if (Debug.verboseOn()) Debug.logVerbose("Applying promo [" + productPromoAction.getPrimaryKey() + "]\n totalAmount=" + totalAmount + ", discountAmountTotal=" + discountAmountTotal, module);
                 distributeDiscountAmount(discountAmountTotal, totalAmount, getCartItemsUsed(cart, productPromoAction), productPromoAction, delegator);
                 actionResultInfo.ranAction = true;
@@ -1292,15 +1295,15 @@
                 actionResultInfo.quantityLeftInAction = quantityDesired;
             }
         } else if ("PROMO_PROD_AMDISC".equals(productPromoActionEnumId)) {
-            double quantityDesired = productPromoAction.get("quantity") == null ? 1.0 : productPromoAction.getDouble("quantity").doubleValue();
-            double startingQuantity = quantityDesired;
-            double discountAmountTotal = 0;
+            BigDecimal quantityDesired = productPromoAction.get("quantity") == null ? BigDecimal.ONE : productPromoAction.getBigDecimal("quantity");
+            BigDecimal startingQuantity = quantityDesired;
+            BigDecimal discountAmountTotal = BigDecimal.ZERO;
             
             Set productIds = ProductPromoWorker.getPromoRuleActionProductIds(productPromoAction, delegator, nowTimestamp);
 
             List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
             Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
-            while (quantityDesired > 0 && lineOrderedByBasePriceIter.hasNext()) {
+            while (quantityDesired.compareTo(BigDecimal.ZERO) > 0 && lineOrderedByBasePriceIter.hasNext()) {
                 ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();
                 // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
                 String parentProductId = cartItem.getParentProductId();
@@ -1309,17 +1312,17 @@
                         (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) &&
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     // reduce quantity still needed to qualify for promo (quantityNeeded)
-                    double quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
-                    quantityDesired -= quantityUsed;
+                    BigDecimal quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
+                    quantityDesired = quantityDesired.subtract(quantityUsed);
 
                     // create an adjustment and add it to the cartItem that implements the promotion action
-                    double discount = productPromoAction.get("amount") == null ? 0.0 : productPromoAction.getDouble("amount").doubleValue();
+                    BigDecimal discount = productPromoAction.get("amount") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("amount");
                     // don't allow the discount to be greater than the price
-                    if (discount > cartItem.getBasePrice() * cartItem.getRentalAdjustment()) {
-                        discount = cartItem.getBasePrice() * cartItem.getRentalAdjustment();
+                    if (discount.compareTo(cartItem.getBasePrice().multiply(cartItem.getRentalAdjustment())) > 0) {
+                        discount = cartItem.getBasePrice().multiply(cartItem.getRentalAdjustment());
                     }
-                    double discountAmount = -(quantityUsed * discount);
-                    discountAmountTotal += discountAmount;
+                    BigDecimal discountAmount = quantityUsed.multiply(discount).negate();
+                    discountAmountTotal = discountAmountTotal.add(discountAmount);
                     // not doing this any more, now distributing among conditions and actions (see call below): doOrderItemPromoAction(productPromoAction, cartItem, discountAmount, "amount", delegator);
                 }
             }
@@ -1328,7 +1331,7 @@
                 // couldn't find any cart items to give a discount to, don't consider action run
                 actionResultInfo.ranAction = false;
             } else {
-                double totalAmount = getCartItemsUsedTotalAmount(cart, productPromoAction);
+                BigDecimal totalAmount = getCartItemsUsedTotalAmount(cart, productPromoAction);
                 if (Debug.verboseOn()) Debug.logVerbose("Applying promo [" + productPromoAction.getPrimaryKey() + "]\n totalAmount=" + totalAmount + ", discountAmountTotal=" + discountAmountTotal, module);
                 distributeDiscountAmount(discountAmountTotal, totalAmount, getCartItemsUsed(cart, productPromoAction), productPromoAction, delegator);
                 actionResultInfo.ranAction = true;
@@ -1337,16 +1340,16 @@
             }
         } else if ("PROMO_PROD_PRICE".equals(productPromoActionEnumId)) {
             // with this we want the set of used items to be one price, so total the price for all used items, subtract the amount we want them to cost, and create an adjustment for what is left
-            double quantityDesired = productPromoAction.get("quantity") == null ? 1.0 : productPromoAction.getDouble("quantity").doubleValue();
-            double desiredAmount = productPromoAction.get("amount") == null ? 0.0 : productPromoAction.getDouble("amount").doubleValue();
-            double totalAmount = 0;
+            BigDecimal quantityDesired = productPromoAction.get("quantity") == null ? BigDecimal.ONE : productPromoAction.getBigDecimal("quantity");
+            BigDecimal desiredAmount = productPromoAction.get("amount") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("amount");
+            BigDecimal totalAmount = BigDecimal.ZERO;
 
             Set productIds = ProductPromoWorker.getPromoRuleActionProductIds(productPromoAction, delegator, nowTimestamp);
 
             List cartItemsUsed = FastList.newInstance();
             List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
             Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
-            while (quantityDesired > 0 && lineOrderedByBasePriceIter.hasNext()) {
+            while (quantityDesired.compareTo(BigDecimal.ZERO) > 0 && lineOrderedByBasePriceIter.hasNext()) {
                 ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();
                 // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
                 String parentProductId = cartItem.getParentProductId();
@@ -1354,17 +1357,17 @@
                 if (!cartItem.getIsPromo() && (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) &&
                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                     // reduce quantity still needed to qualify for promo (quantityNeeded)
-                    double quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
-                    if (quantityUsed > 0) {
-                        quantityDesired -= quantityUsed;
-                        totalAmount += quantityUsed * cartItem.getBasePrice() * cartItem.getRentalAdjustment();
+                	BigDecimal quantityUsed = cartItem.addPromoQuantityCandidateUse(quantityDesired, productPromoAction, false);
+                    if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
+                        quantityDesired = quantityDesired.subtract(quantityUsed);
+                        totalAmount = totalAmount.add(quantityUsed.multiply(cartItem.getBasePrice()).multiply(cartItem.getRentalAdjustment()));
                         cartItemsUsed.add(cartItem);
                     }
                 }
             }
 
-            if (totalAmount > desiredAmount && quantityDesired == 0) {
-                double discountAmountTotal = -(totalAmount - desiredAmount);
+            if (totalAmount.compareTo(desiredAmount) > 0 && quantityDesired.compareTo(BigDecimal.ZERO) == 0) {
+            	BigDecimal discountAmountTotal = totalAmount.subtract(desiredAmount).negate();
                 distributeDiscountAmount(discountAmountTotal, totalAmount, cartItemsUsed, productPromoAction, delegator);
                 actionResultInfo.ranAction = true;
                 actionResultInfo.totalDiscountAmount = discountAmountTotal;
@@ -1375,21 +1378,21 @@
                 cart.resetPromoRuleUse(productPromoAction.getString("productPromoId"), productPromoAction.getString("productPromoRuleId"));
             }
         } else if ("PROMO_ORDER_PERCENT".equals(productPromoActionEnumId)) {
-            double percentage = -(productPromoAction.get("amount") == null ? 0.0 : (productPromoAction.getDouble("amount").doubleValue() / 100.0));
-            double amount = cart.getSubTotalForPromotions() * percentage;
-            if (amount != 0) {
+            BigDecimal percentage = (productPromoAction.get("amount") == null ? BigDecimal.ZERO : (productPromoAction.getBigDecimal("amount").movePointLeft(2))).negate();
+            BigDecimal amount = cart.getSubTotalForPromotions().multiply(percentage);
+            if (amount.compareTo(BigDecimal.ZERO) != 0) {
                 doOrderPromoAction(productPromoAction, cart, amount, "amount", delegator);
                 actionResultInfo.ranAction = true;
                 actionResultInfo.totalDiscountAmount = amount;
             }
         } else if ("PROMO_ORDER_AMOUNT".equals(productPromoActionEnumId)) {
-            double amount = -(productPromoAction.get("amount") == null ? 0.0 : productPromoAction.getDouble("amount").doubleValue());
+        	BigDecimal amount = (productPromoAction.get("amount") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("amount")).negate();
             // if amount is greater than the order sub total, set equal to order sub total, this normally wouldn't happen because there should be a condition that the order total be above a certain amount, but just in case...
-            double subTotal = cart.getSubTotalForPromotions();
-            if (-amount > subTotal) {
-                amount = -subTotal;
+        	BigDecimal subTotal = cart.getSubTotalForPromotions();
+            if (amount.negate().compareTo(subTotal) > 0) {
+                amount = subTotal.negate();
             }
-            if (amount != 0) {
+            if (amount.compareTo(BigDecimal.ZERO) != 0) {
                 doOrderPromoAction(productPromoAction, cart, amount, "amount", delegator);
                 actionResultInfo.ranAction = true;
                 actionResultInfo.totalDiscountAmount = amount;
@@ -1416,12 +1419,12 @@
                 }
                 
                 // get difference between basePrice and specialPromoPrice and adjust for that
-                double difference = -(cartItem.getBasePrice() * cartItem.getRentalAdjustment() - cartItem.getSpecialPromoPrice().doubleValue());
+                BigDecimal difference = cartItem.getBasePrice().multiply(cartItem.getRentalAdjustment()).subtract(cartItem.getSpecialPromoPrice()).negate();
 
-                if (difference != 0.0) {
-                    double quantityUsed = cartItem.addPromoQuantityCandidateUse(cartItem.getQuantity(), productPromoAction, false);
-                    if (quantityUsed > 0) {
-                        double amount = difference * quantityUsed;
+                if (difference.compareTo(BigDecimal.ZERO) != 0) {
+                	BigDecimal quantityUsed = cartItem.addPromoQuantityCandidateUse(cartItem.getQuantity(), productPromoAction, false);
+                    if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
+                    	BigDecimal amount = difference.multiply(quantityUsed);
                         doOrderItemPromoAction(productPromoAction, cartItem, amount, "amount", delegator);
                         actionResultInfo.ranAction = true;
                         actionResultInfo.totalDiscountAmount = amount;
@@ -1448,43 +1451,41 @@
         Iterator cartItemsIter = cart.iterator();
         while (cartItemsIter.hasNext()) {
             ShoppingCartItem cartItem = (ShoppingCartItem) cartItemsIter.next();
-            double quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
-            if (quantityUsed > 0) {
+            BigDecimal quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
+            if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
                 cartItemsUsed.add(cartItem);
             }
         }
         return cartItemsUsed;
     }
     
-    protected static double getCartItemsUsedTotalAmount(ShoppingCart cart, GenericValue productPromoAction) {
-        double totalAmount = 0;
+    protected static BigDecimal getCartItemsUsedTotalAmount(ShoppingCart cart, GenericValue productPromoAction) {
+        BigDecimal totalAmount = BigDecimal.ZERO;
         Iterator cartItemsIter = cart.iterator();
         while (cartItemsIter.hasNext()) {
             ShoppingCartItem cartItem = (ShoppingCartItem) cartItemsIter.next();
-            double quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
-            if (quantityUsed > 0) {
-                totalAmount += quantityUsed * cartItem.getBasePrice();
+            BigDecimal quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
+            if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
+                totalAmount = totalAmount.add(quantityUsed.multiply(cartItem.getBasePrice()));
             }
         }
         return totalAmount;
     }
     
-    protected static void distributeDiscountAmount(double discountAmountTotal, double totalAmount, List cartItemsUsed, GenericValue productPromoAction, GenericDelegator delegator) {
-        double discountAmount = discountAmountTotal;
+    protected static void distributeDiscountAmount(BigDecimal discountAmountTotal, BigDecimal totalAmount, List cartItemsUsed, GenericValue productPromoAction, GenericDelegator delegator) {
+    	BigDecimal discountAmount = discountAmountTotal;
         // distribute the discount evenly weighted according to price over the order items that the individual quantities came from; avoids a number of issues with tax/shipping calc, inclusion in the sub-total for other promotions, etc
         Iterator cartItemsUsedIter = cartItemsUsed.iterator();
         while (cartItemsUsedIter.hasNext()) {
             ShoppingCartItem cartItem = (ShoppingCartItem) cartItemsUsedIter.next();
             // to minimize rounding issues use the remaining total for the last one, otherwise use a calculated value
             if (cartItemsUsedIter.hasNext()) {
-                double quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
-                double ratioOfTotal = (quantityUsed * cartItem.getBasePrice()) / totalAmount;
-                double weightedAmount = ratioOfTotal * discountAmountTotal;
+                BigDecimal quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
+                BigDecimal ratioOfTotal = quantityUsed.multiply(cartItem.getBasePrice()).divide(totalAmount, generalRounding);
+                BigDecimal weightedAmount = ratioOfTotal.multiply(discountAmountTotal);
                 // round the weightedAmount to 2 decimal places, ie a whole number of cents or 2 decimal place monetary units
-                weightedAmount = weightedAmount * 100.0;
-                long roundedAmount = Math.round(weightedAmount);
-                weightedAmount = ((double) roundedAmount) / 100.0;
-                discountAmount -= weightedAmount;
+                weightedAmount = weightedAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
+                discountAmount = discountAmount.subtract(weightedAmount);
                 doOrderItemPromoAction(productPromoAction, cartItem, weightedAmount, "amount", delegator);
             } else {
                 // last one, just use discountAmount
@@ -1516,11 +1517,11 @@
         return null;
     }
 
-    public static void doOrderItemPromoAction(GenericValue productPromoAction, ShoppingCartItem cartItem, double amount, String amountField, GenericDelegator delegator) {
+    public static void doOrderItemPromoAction(GenericValue productPromoAction, ShoppingCartItem cartItem, BigDecimal amount, String amountField, GenericDelegator delegator) {
         // round the amount before setting to make sure we don't get funny numbers in there
-        BigDecimal amountBd = (new BigDecimal(amount)).setScale(decimals, rounding);
+        amount = amount.setScale(decimals, rounding);
         GenericValue orderAdjustment = delegator.makeValue("OrderAdjustment",
-                UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", amountField, amountBd,
+                UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", amountField, amount,
                     "productPromoId", productPromoAction.get("productPromoId"),
                     "productPromoRuleId", productPromoAction.get("productPromoRuleId"),
                     "productPromoActionSeqId", productPromoAction.get("productPromoActionSeqId")));
@@ -1533,11 +1534,11 @@
         cartItem.addAdjustment(orderAdjustment);
     }
 
-    public static void doOrderPromoAction(GenericValue productPromoAction, ShoppingCart cart, double amount, String amountField, GenericDelegator delegator) {
+    public static void doOrderPromoAction(GenericValue productPromoAction, ShoppingCart cart, BigDecimal amount, String amountField, GenericDelegator delegator) {
         // round the amount before setting to make sure we don't get funny numbers in there
-        BigDecimal amountBd = (new BigDecimal(amount)).setScale(decimals, rounding);
+        amount = amount.setScale(decimals, rounding);
         GenericValue orderAdjustment = delegator.makeValue("OrderAdjustment",
-                UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", amountField, amountBd,
+                UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", amountField, amount,
                     "productPromoId", productPromoAction.get("productPromoId"),
                     "productPromoRuleId", productPromoAction.get("productPromoRuleId"),
                     "productPromoActionSeqId", productPromoAction.get("productPromoActionSeqId")));

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.order.shoppingcart.shipping;
 
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -46,9 +47,9 @@
     protected List shippableItemSizes = null;
     protected List shippableItemInfo = null;
     protected String productStoreId = null;
-    protected double shippableQuantity = 0;
-    protected double shippableWeight = 0;
-    protected double shippableTotal = 0;
+    protected BigDecimal shippableQuantity = BigDecimal.ZERO;
+    protected BigDecimal shippableWeight = BigDecimal.ZERO;
+    protected BigDecimal shippableTotal = BigDecimal.ZERO;
     protected String partyId = null;
     protected String supplierPartyId = null;
 
@@ -100,7 +101,7 @@
                         supplierPartyId, shippableItemInfo, shippableWeight, shippableQuantity, shippableTotal, partyId);
 
                 if (!ServiceUtil.isError(estimateMap)) {
-                    Double shippingTotal = (Double) estimateMap.get("shippingTotal");
+                    BigDecimal shippingTotal = (BigDecimal) estimateMap.get("shippingTotal");
                     shippingEstimates.put(shipMethod, shippingTotal);
                 }
             }
@@ -115,8 +116,8 @@
         return shippingEstimates;
     }
 
-    public Double getShippingEstimate(GenericValue storeCarrierShipMethod) {
-        return (Double) shippingEstimates.get(storeCarrierShipMethod);
+    public BigDecimal getShippingEstimate(GenericValue storeCarrierShipMethod) {
+        return (BigDecimal) shippingEstimates.get(storeCarrierShipMethod);
     }
 
 }

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.order.shoppingcart.shipping;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -76,11 +77,11 @@
                 return "error";
             }
 
-            Double shippingTotal = (Double) result.get("shippingTotal");
+            BigDecimal shippingTotal = (BigDecimal) result.get("shippingTotal");
             if (shippingTotal == null) {
-                shippingTotal = new Double(0.00);
+                shippingTotal = BigDecimal.ZERO;
             }
-            cart.setItemShipGroupEstimate(shippingTotal.doubleValue(), i);
+            cart.setItemShipGroupEstimate(shippingTotal, i);
         }
 
         // all done
@@ -91,7 +92,7 @@
         // check for shippable items
         if (!cart.shippingApplies()) {
             Map responseResult = ServiceUtil.returnSuccess();
-            responseResult.put("shippingTotal", new Double(0.00));
+            responseResult.put("shippingTotal", BigDecimal.ZERO);
             return responseResult;
         }
 
@@ -107,7 +108,7 @@
         // check for shippable items
         if (!orh.shippingApplies()) {
             Map responseResult = ServiceUtil.returnSuccess();
-            responseResult.put("shippingTotal", new Double(0.00));
+            responseResult.put("shippingTotal", BigDecimal.ZERO);
             return responseResult;
         }
 
@@ -119,7 +120,7 @@
 
         GenericValue shipAddr = orh.getShippingAddress(shipGroupSeqId);
         if (shipAddr == null) {
-            return UtilMisc.toMap("shippingTotal", new Double(0));
+            return UtilMisc.toMap("shippingTotal", BigDecimal.ZERO);
         }
         
         String contactMechId = shipAddr.getString("contactMechId");
@@ -129,15 +130,15 @@
              partyId = partyObject.getString("partyId");
         }
         return getShipGroupEstimate(dispatcher, delegator, orh.getOrderTypeId(), shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId,
-                contactMechId, orh.getProductStoreId(), supplierPartyId, orh.getShippableItemInfo(shipGroupSeqId), orh.getShippableWeight(shipGroupSeqId).doubleValue(),
-                orh.getShippableQuantity(shipGroupSeqId).doubleValue(), orh.getShippableTotal(shipGroupSeqId).doubleValue(), partyId);
+                contactMechId, orh.getProductStoreId(), supplierPartyId, orh.getShippableItemInfo(shipGroupSeqId), orh.getShippableWeight(shipGroupSeqId),
+                orh.getShippableQuantity(shipGroupSeqId), orh.getShippableTotal(shipGroupSeqId), partyId);
     }
 
     // version with no support for using the supplier's address as the origin
     public static Map getShipGroupEstimate(LocalDispatcher dispatcher, GenericDelegator delegator, String orderTypeId,
             String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId,
-            String productStoreId, List itemInfo, double shippableWeight, double shippableQuantity,
-            double shippableTotal, String partyId) {
+            String productStoreId, List itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
+            BigDecimal shippableTotal, String partyId) {
         return getShipGroupEstimate(dispatcher, delegator, orderTypeId, shipmentMethodTypeId, carrierPartyId,
                 carrierRoleTypeId, shippingContactMechId, productStoreId, null, itemInfo,
                 shippableWeight, shippableQuantity, shippableTotal, partyId);
@@ -145,8 +146,8 @@
 
     public static Map getShipGroupEstimate(LocalDispatcher dispatcher, GenericDelegator delegator, String orderTypeId,
             String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId,
-            String productStoreId, String supplierPartyId, List itemInfo, double shippableWeight, double shippableQuantity,
-            double shippableTotal, String partyId) {
+            String productStoreId, String supplierPartyId, List itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
+            BigDecimal shippableTotal, String partyId) {
         String standardMessage = "A problem occurred calculating shipping. Fees will be calculated offline.";
         List errorMessageList = new ArrayList();
 
@@ -185,9 +186,9 @@
         }
 
         // no shippable items; we won't change any shipping at all
-        if (shippableQuantity == 0) {
+        if (shippableQuantity.compareTo(BigDecimal.ZERO) == 0) {
             Map result = ServiceUtil.returnSuccess();
-            result.put("shippingTotal", new Double(0));
+            result.put("shippingTotal", BigDecimal.ZERO);
             return result;
         }
 
@@ -201,14 +202,14 @@
         }
 
         // the initial amount before manual estimates
-        double shippingTotal = 0.00;
+        BigDecimal shippingTotal = BigDecimal.ZERO;
 
         // prepare the service invocation fields
         Map serviceFields = new HashMap();
-        serviceFields.put("initialEstimateAmt", new Double(shippingTotal));
-        serviceFields.put("shippableTotal", new Double(shippableTotal));
-        serviceFields.put("shippableQuantity", new Double(shippableQuantity));
-        serviceFields.put("shippableWeight", new Double(shippableWeight));        
+        serviceFields.put("initialEstimateAmt", shippingTotal);
+        serviceFields.put("shippableTotal", shippableTotal);
+        serviceFields.put("shippableQuantity", shippableQuantity);
+        serviceFields.put("shippableWeight", shippableWeight);        
         serviceFields.put("shippableItemInfo", itemInfo);
         serviceFields.put("productStoreId", productStoreId);
         serviceFields.put("carrierRoleTypeId", "CARRIER");
@@ -220,22 +221,22 @@
 
         // call the external shipping service
         try {
-            Double externalAmt = getExternalShipEstimate(dispatcher, storeShipMethod, serviceFields);
+            BigDecimal externalAmt = getExternalShipEstimate(dispatcher, storeShipMethod, serviceFields);
             if (externalAmt != null) {
-                shippingTotal += externalAmt.doubleValue();
+                shippingTotal = shippingTotal.add(externalAmt);
             }
         } catch (GeneralException e) {
             return ServiceUtil.returnError(standardMessage);
         }
 
         // update the initial amount
-        serviceFields.put("initialEstimateAmt", new Double(shippingTotal));
+        serviceFields.put("initialEstimateAmt", shippingTotal);
 
         // call the generic estimate service
         try {
-            Double genericAmt = getGenericShipEstimate(dispatcher, storeShipMethod, serviceFields);
+        	BigDecimal genericAmt = getGenericShipEstimate(dispatcher, storeShipMethod, serviceFields);
             if (genericAmt != null) {
-                shippingTotal += genericAmt.doubleValue();
+                shippingTotal = shippingTotal.add(genericAmt);
             }
         } catch (GeneralException e) {
             return ServiceUtil.returnError(standardMessage);
@@ -243,14 +244,14 @@
 
         // return the totals
         Map responseResult = ServiceUtil.returnSuccess();
-        responseResult.put("shippingTotal", new Double(shippingTotal));
+        responseResult.put("shippingTotal", shippingTotal);
         return responseResult;
     }
 
-    public static Double getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map context) throws GeneralException {
+    public static BigDecimal getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map context) throws GeneralException {
         // invoke the generic estimate service next -- append to estimate amount
         Map genericEstimate = null;
-        Double genericShipAmt = null;
+        BigDecimal genericShipAmt = null;
         try {
             genericEstimate = dispatcher.runSync("calcShipmentCostEstimate", context);
         } catch (GenericServiceException e) {
@@ -261,17 +262,17 @@
             Debug.logError(ServiceUtil.getErrorMessage(genericEstimate), module);
             throw new GeneralException();
         } else if (ServiceUtil.isFailure(genericEstimate)) {
-            genericShipAmt = new Double(-1);
+            genericShipAmt = BigDecimal.ONE.negate();
         } else {
-            genericShipAmt = (Double) genericEstimate.get("shippingEstimateAmount");
+            genericShipAmt = (BigDecimal) genericEstimate.get("shippingEstimateAmount");
         }
         return genericShipAmt;
     }
 
-    public static Double getExternalShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map context) throws GeneralException {
+    public static BigDecimal getExternalShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map context) throws GeneralException {
         // invoke the external shipping estimate service
         String serviceName = (String)storeShipMeth.get("serviceName");
-        Double externalShipAmt = null;
+        BigDecimal externalShipAmt = null;
         if(serviceName != null){
             String doEstimates = UtilProperties.getPropertyValue("shipment.properties", "shipment.doratecheck", "true");
             //If all estimates are not turned off, check for the individual one
@@ -309,7 +310,7 @@
                     Debug.logError(errMsg, module);
                     // should not throw an Exception here, otherwise getShipGroupEstimate would return an error, causing all sorts of services like add or update order item to abort
                 } else {
-                    externalShipAmt = (Double) serviceResp.get("shippingEstimateAmount");
+                    externalShipAmt = (BigDecimal) serviceResp.get("shippingEstimateAmount");
                 }
             }
         }

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.order.shoppinglist;
 
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -146,12 +147,12 @@
                     Debug.logInfo("Adding cart item to shopping list [" + shoppingListId + "], allowPromo=" + allowPromo + ", item.getIsPromo()=" + item.getIsPromo() + ", item.getProductId()=" + item.getProductId() + ", item.getQuantity()=" + item.getQuantity(), module);
                     Map serviceResult = null;
                     try {
-                        Map ctx = UtilMisc.toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", item.getProductId(), "quantity", new Double(item.getQuantity()));
+                        Map ctx = UtilMisc.toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", item.getProductId(), "quantity", item.getQuantity());
                         ctx.put("reservStart", item.getReservStart());
-                        ctx.put("reservLength", new Double(item.getReservLength()));
-                        ctx.put("reservPersons", new Double(item.getReservPersons()));
-                  //    ctx.put("accommodationMapId", new Double(item.getAccommodationMapId()));
-                  //    ctx.put("accommodationSpotId", new Double(item.getAccommodationSpotId()));
+                        ctx.put("reservLength", item.getReservLength());
+                        ctx.put("reservPersons", item.getReservPersons());
+                  //    ctx.put("accommodationMapId", item.getAccommodationMapId());
+                  //    ctx.put("accommodationSpotId", item.getAccommodationSpotId());
                         if (item.getConfigWrapper() != null) {
                             ctx.put("configId", item.getConfigWrapper().getConfigId());                            
                         }
@@ -259,10 +260,10 @@
         while (i.hasNext()) {
             GenericValue shoppingListItem = (GenericValue) i.next();
             String productId = shoppingListItem.getString("productId");
-            Double quantity = shoppingListItem.getDouble("quantity");
+            BigDecimal quantity = shoppingListItem.getBigDecimal("quantity");
             Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
-            Double reservLength = shoppingListItem.getDouble("reservLength");
-            Double reservPersons = shoppingListItem.getDouble("reservPersons");
+            BigDecimal reservLength = shoppingListItem.getBigDecimal("reservLength");
+            BigDecimal reservPersons = shoppingListItem.getBigDecimal("reservPersons");
       //    String accommodationMapId = shoppingListItem.getString("accommodationMapId");
       //    String accommodationSpotId = shoppingListItem.getString("accommodationSpotId");            
             String configId = shoppingListItem.getString("configId");
@@ -290,9 +291,9 @@
                 
                 // i cannot get the addOrDecrease function to accept a null reservStart field: i get a null pointer exception a null constant works....
                 if (reservStart == null) {
-                       cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
+                       cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
                 }else{                
-                    cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
+                    cart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
                 }
                 Map messageMap = UtilMisc.toMap("productId", productId);
                 errMsg = UtilProperties.getMessage(resource,"shoppinglistevents.added_product_to_cart", messageMap, cart.getLocale());
@@ -326,9 +327,9 @@
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
         Locale locale = UtilHttp.getLocale(request);
                 
-        Double quantity = null;
+        BigDecimal quantity = null;
         try {
-            quantity = Double.valueOf(quantityStr);
+            quantity = new BigDecimal(quantityStr);
         } catch (Exception e) {
             // do nothing, just won't pass to service if it is null
         }

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java Sun Nov 30 22:51:11 2008
@@ -23,6 +23,7 @@
 import java.util.Locale;
 import java.util.Iterator;
 import java.util.HashMap;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 
 import org.ofbiz.service.DispatchContext;
@@ -471,19 +472,19 @@
                 while (i.hasNext()) {
                     GenericValue shoppingListItem = (GenericValue) i.next();
                     String productId = shoppingListItem.getString("productId");
-                    Double quantity = shoppingListItem.getDouble("quantity");
+                    BigDecimal quantity = shoppingListItem.getBigDecimal("quantity");
                     Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
-                    Double reservLength = null;
+                    BigDecimal reservLength = null;
                     String configId = shoppingListItem.getString("configId");
               //    String accommodationMapId = shoppingListItem.getString("accommodationMapId");
               //    String accommodationSpotId = shoppingListItem.getString("accommodationSpotId");
 
                     if (shoppingListItem.get("reservLength") != null) {
-                        reservLength = shoppingListItem.getDouble("reservLength");
+                        reservLength = shoppingListItem.getBigDecimal("reservLength");
                     }
-                    Double reservPersons = null;
+                    BigDecimal reservPersons = null;
                     if (shoppingListItem.get("reservPersons") != null) {
-                        reservPersons = shoppingListItem.getDouble("reservPersons");
+                        reservPersons = shoppingListItem.getBigDecimal("reservPersons");
                     }
                /*   if (shoppingListItem.get("accommodationMapId") != null) {
                        accommodationMapId = shoppingListItem.getString("accommodationMapId");
@@ -502,7 +503,7 @@
                         Map attributes = UtilMisc.toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId);
 
                         try { 
-                            listCart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher);
+                            listCart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher);
                         } catch (CartItemModifyException e) {
                             Debug.logError(e, "Unable to add product to List Cart - " + productId, module);
                         } catch (ItemNotFoundException e) {
@@ -569,10 +570,10 @@
                     GenericValue shoppingListItem=delegator.findByPrimaryKey("ShoppingListItem", UtilMisc.toMap("shoppingListId",
                                 shoppingListId, "shoppingListItemSeqId", shoppingListItemSeqId));
                     if (shoppingListItem != null) {
-                        Double quantityPurchased = shoppingListItem.getDouble("quantityPurchased");
-                        Double orderQuantity = orderItem.getDouble("quantity");
+                    	BigDecimal quantityPurchased = shoppingListItem.getBigDecimal("quantityPurchased");
+                    	BigDecimal orderQuantity = orderItem.getBigDecimal("quantity");
                         if (quantityPurchased != null) {
-                            shoppingListItem.set("quantityPurchased", new Double(orderQuantity.doubleValue() + quantityPurchased.doubleValue()));
+                            shoppingListItem.set("quantityPurchased", orderQuantity.add(quantityPurchased));
                         }else{
                             shoppingListItem.set("quantityPurchased", orderQuantity);
                         }

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/OrderTestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/OrderTestServices.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/OrderTestServices.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/OrderTestServices.java Sun Nov 30 22:51:11 2008
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.order.test;
 
+import java.math.BigDecimal;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -126,7 +127,7 @@
             // get a product
             int k = r.nextInt(productsList.size());
             try {
-                cart.addOrIncreaseItem((String) productsList.get(k), null, 1, null, null, null,
+                cart.addOrIncreaseItem((String) productsList.get(k), null, BigDecimal.ONE, null, null, null,
                                        null, null, null, null, 
                                        null /*catalogId*/, null, null/*itemType*/, null/*itemGroupNumber*/, null, dispatcher);
             } catch (Exception exc) {

Modified: ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java?rev=721986&r1=721985&r2=721986&view=diff
==============================================================================
--- ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java (original)
+++ ofbiz/branches/typecheckcleanup200810/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java Sun Nov 30 22:51:11 2008
@@ -24,6 +24,8 @@
 import org.ofbiz.service.GenericDispatcher;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.base.util.UtilMisc;
+
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -58,9 +60,9 @@
         ctx.put("currencyUom", "USD");
         ctx.put("productStoreId","9000");
 
-        GenericValue orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00001", "orderItemTypeId", "PRODUCT_ORDER_ITEM", "prodCatalogId", "DemoCatalog", "productId", "GZ-1000", "quantity", new Double(2), "isPromo", "N"));
-        orderItem.set("unitPrice", new Double(1399.5));
-        orderItem.set("unitListPrice", new Double(0));
+        GenericValue orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00001", "orderItemTypeId", "PRODUCT_ORDER_ITEM", "prodCatalogId", "DemoCatalog", "productId", "GZ-1000", "quantity", new BigDecimal("2"), "isPromo", "N"));
+        orderItem.set("unitPrice", new BigDecimal("1399.5"));
+        orderItem.set("unitListPrice", BigDecimal.ZERO);
         orderItem.set("isModifiedPrice", "N");
         orderItem.set("statusId", "ITEM_CREATED");
         List <GenericValue> orderItems = FastList.newInstance();