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

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

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

jonesde
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Mon Jan  5 23:13:36 2009
@@ -192,11 +192,10 @@
             partyId = userLogin.getString("partyId");
         }
 
-        Double quantityDbl = (Double) context.get("quantity");
-        if (quantityDbl == null) quantityDbl = Double.valueOf(1.0);
-        double quantity = quantityDbl.doubleValue();
+        BigDecimal quantity = (BigDecimal) context.get("quantity");
+        if (quantity == null) quantity = BigDecimal.ONE;
 
-        Double amountDbl = (Double) context.get("amount");
+        BigDecimal amount = (BigDecimal) context.get("amount");
 
         List<EntityCondition> productPriceEcList = FastList.newInstance();
         productPriceEcList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
@@ -229,13 +228,13 @@
         List<GenericValue> listPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
         GenericValue listPriceValue = EntityUtil.getFirst(listPrices);
         if (listPrices != null && listPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + listPriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> defaultPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
         GenericValue defaultPriceValue = EntityUtil.getFirst(defaultPrices);
         if (defaultPrices != null && defaultPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + defaultPriceValue.getBigDecimal("price"), module);
         }
 
         // If there is an agreement between the company and the client, and there is
@@ -258,43 +257,43 @@
         List<GenericValue> competitivePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
         GenericValue competitivePriceValue = EntityUtil.getFirst(competitivePrices);
         if (competitivePrices != null && competitivePrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + competitivePriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + competitivePriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> averageCosts = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
         GenericValue averageCostValue = EntityUtil.getFirst(averageCosts);
         if (averageCosts != null && averageCosts.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + averageCostValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> promoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
         GenericValue promoPriceValue = EntityUtil.getFirst(promoPrices);
         if (promoPrices != null && promoPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + promoPriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> minimumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
         GenericValue minimumPriceValue = EntityUtil.getFirst(minimumPrices);
         if (minimumPrices != null && minimumPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + minimumPriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> maximumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
         GenericValue maximumPriceValue = EntityUtil.getFirst(maximumPrices);
         if (maximumPrices != null && maximumPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + maximumPriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> wholesalePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
         GenericValue wholesalePriceValue = EntityUtil.getFirst(wholesalePrices);
         if (wholesalePrices != null && wholesalePrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + wholesalePriceValue.getBigDecimal("price"), module);
         }
 
         List<GenericValue> specialPromoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
         GenericValue specialPromoPriceValue = EntityUtil.getFirst(specialPromoPrices);
         if (specialPromoPrices != null && specialPromoPrices.size() > 1) {
-            if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + specialPromoPriceValue.getDouble("price"), module);
+            if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + specialPromoPriceValue.getBigDecimal("price"), module);
         }
 
         // if any of these prices is missing and this product is a variant, default to the corresponding price on the virtual product
@@ -303,56 +302,56 @@
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
                 listPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + listPriceValue.getBigDecimal("price"), module);
                 }
             }
             if (defaultPriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
                 defaultPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + defaultPriceValue.getBigDecimal("price"), module);
                 }
             }
             if (averageCostValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
                 averageCostValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + averageCostValue.getBigDecimal("price"), module);
                 }
             }
             if (promoPriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
                 promoPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + promoPriceValue.getBigDecimal("price"), module);
                 }
             }
             if (minimumPriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
                 minimumPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + minimumPriceValue.getBigDecimal("price"), module);
                 }
             }
             if (maximumPriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
                 maximumPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + maximumPriceValue.getBigDecimal("price"), module);
                 }
             }
             if (wholesalePriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
                 wholesalePriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + wholesalePriceValue.getBigDecimal("price"), module);
                 }
             }
             if (specialPromoPriceValue == null) {
                 List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
                 specialPromoPriceValue = EntityUtil.getFirst(virtualTempPrices);
                 if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                    if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + specialPromoPriceValue.getDouble("price"), module);
+                    if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + specialPromoPriceValue.getBigDecimal("price"), module);
                 }
             }
         }
@@ -366,7 +365,7 @@
                 //use the cache to find the variant with the lowest default price
                 try {
                     List<GenericValue> variantAssocList = EntityUtil.filterByDate(delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate")));
-                    double minDefaultPrice = Double.MAX_VALUE;
+                    BigDecimal minDefaultPrice = null;
                     List<GenericValue> variantProductPrices = null;
                     String variantProductId = null;
                     for (GenericValue variantAssoc: variantAssocList) {
@@ -375,14 +374,14 @@
                         List<GenericValue> tempDefaultPriceList = EntityUtil.filterByAnd(curVariantPriceList, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
                         GenericValue curDefaultPriceValue = EntityUtil.getFirst(tempDefaultPriceList);
                         if (curDefaultPriceValue != null) {
-                            Double curDefaultPrice = curDefaultPriceValue.getDouble("price");
-                            if (curDefaultPrice.doubleValue() < minDefaultPrice) {
+                         BigDecimal curDefaultPrice = curDefaultPriceValue.getBigDecimal("price");
+                            if (minDefaultPrice == null || curDefaultPrice.compareTo(minDefaultPrice) < 0) {
                                 // check to see if the product is discontinued for sale before considering it the lowest price
                                 GenericValue curVariantProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", curVariantProductId));
                                 if (curVariantProduct != null) {
                                     Timestamp salesDiscontinuationDate = curVariantProduct.getTimestamp("salesDiscontinuationDate");
                                     if (salesDiscontinuationDate == null || salesDiscontinuationDate.after(nowTimestamp)) {
-                                        minDefaultPrice = curDefaultPrice.doubleValue();
+                                        minDefaultPrice = curDefaultPrice;
                                         variantProductPrices = curVariantPriceList;
                                         variantProductId = curVariantProductId;
                                         // Debug.logInfo("Found new lowest price " + minDefaultPrice + " for variant with ID " + variantProductId, module);
@@ -398,63 +397,63 @@
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
                             listPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + listPriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (defaultPriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
                             defaultPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + defaultPriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (competitivePriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
                             competitivePriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + competitivePriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + competitivePriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (averageCostValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
                             averageCostValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + averageCostValue.getBigDecimal("price"), module);
                             }
                         }
                         if (promoPriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
                             promoPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + promoPriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (minimumPriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
                             minimumPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + minimumPriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (maximumPriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
                             maximumPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + maximumPriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (wholesalePriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
                             wholesalePriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getBigDecimal("price"), module);
                             }
                         }
                         if (specialPromoPriceValue == null) {
                             List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
                             specialPromoPriceValue = EntityUtil.getFirst(virtualTempPrices);
                             if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
-                                if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
+                                if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getBigDecimal("price"), module);
                             }
                         }
                     }
@@ -465,21 +464,21 @@
         }
 
         //boolean validPromoPriceFound = false;
-        double promoPrice = 0;
+        BigDecimal promoPrice = BigDecimal.ZERO;
         if (promoPriceValue != null && promoPriceValue.get("price") != null) {
-            promoPrice = promoPriceValue.getDouble("price").doubleValue();
+            promoPrice = promoPriceValue.getBigDecimal("price");
             //validPromoPriceFound = true;
         }
 
         //boolean validWholesalePriceFound = false;
-        double wholesalePrice = 0;
+        BigDecimal wholesalePrice = BigDecimal.ZERO;
         if (wholesalePriceValue != null && wholesalePriceValue.get("price") != null) {
-            wholesalePrice = wholesalePriceValue.getDouble("price").doubleValue();
+            wholesalePrice = wholesalePriceValue.getBigDecimal("price");
             //validWholesalePriceFound = true;
         }
 
         boolean validPriceFound = false;
-        double defaultPrice = 0;
+        BigDecimal defaultPrice = BigDecimal.ZERO;
         List<GenericValue> orderItemPriceInfos = FastList.newInstance();
         if (defaultPriceValue != null) {
             // If a price calc formula (service) is specified, then use it to get the unit price
@@ -492,10 +491,10 @@
                 }
                 if (UtilValidate.isNotEmpty(customMethod) && UtilValidate.isNotEmpty(customMethod.getString("customMethodName"))) {
                     Map<String, Object> inMap = UtilMisc.toMap("userLogin", context.get("userLogin"), "product", product);
-                    inMap.put("initialPrice", defaultPriceValue.get("price"));
+                    inMap.put("initialPrice", defaultPriceValue.getBigDecimal("price"));
                     inMap.put("currencyUomId", currencyUomId);
-                    inMap.put("quantity", quantityDbl);
-                    inMap.put("amount", amountDbl);
+                    inMap.put("quantity", quantity);
+                    inMap.put("amount", amount);
                     if (UtilValidate.isNotEmpty(surveyResponseId)) {
                         inMap.put("surveyResponseId", surveyResponseId);
                     }
@@ -505,10 +504,10 @@
                     try {
                         Map<String, Object> outMap = dispatcher.runSync(customMethod.getString("customMethodName"), inMap);
                         if (!ServiceUtil.isError(outMap)) {
-                            Double calculatedDefaultPrice = (Double)outMap.get("price");
+                         BigDecimal calculatedDefaultPrice = (BigDecimal)outMap.get("price");
                             orderItemPriceInfos = UtilGenerics.checkList(outMap.get("orderItemPriceInfos"));
                             if (UtilValidate.isNotEmpty(calculatedDefaultPrice)) {
-                                defaultPrice = calculatedDefaultPrice.doubleValue();
+                                defaultPrice = calculatedDefaultPrice;
                                 validPriceFound = true;
                             }
                         }
@@ -518,36 +517,36 @@
                 }
             }
             if (!validPriceFound && defaultPriceValue.get("price") != null) {
-                defaultPrice = defaultPriceValue.getDouble("price").doubleValue();
+                defaultPrice = defaultPriceValue.getBigDecimal("price");
                 validPriceFound = true;
             }
         }
 
-        Double listPriceDbl = listPriceValue != null ? listPriceValue.getDouble("price") : null;
+        BigDecimal listPrice = listPriceValue != null ? listPriceValue.getBigDecimal("price") : null;
 
-        if (listPriceDbl == null) {
+        if (listPrice == null) {
             // no list price, use defaultPrice for the final price
 
             // ========= ensure calculated price is not below minSalePrice or above maxSalePrice =========
-            Double maxSellPrice = maximumPriceValue != null ? maximumPriceValue.getDouble("price") : null;
-            if (maxSellPrice != null && defaultPrice > maxSellPrice.doubleValue()) {
-                defaultPrice = maxSellPrice.doubleValue();
+         BigDecimal maxSellPrice = maximumPriceValue != null ? maximumPriceValue.getBigDecimal("price") : null;
+            if (maxSellPrice != null && defaultPrice.compareTo(maxSellPrice) > 0) {
+                defaultPrice = maxSellPrice;
             }
             // min price second to override max price, safety net
-            Double minSellPrice = minimumPriceValue != null ? minimumPriceValue.getDouble("price") : null;
-            if (minSellPrice != null && defaultPrice < minSellPrice.doubleValue()) {
-                defaultPrice = minSellPrice.doubleValue();
+            BigDecimal minSellPrice = minimumPriceValue != null ? minimumPriceValue.getBigDecimal("price") : null;
+            if (minSellPrice != null && defaultPrice.compareTo(minSellPrice) < 0) {
+                defaultPrice = minSellPrice;
                 // since we have found a minimum price that has overriden a the defaultPrice, even if no valid one was found, we will consider it as if one had been...
                 validPriceFound = true;
             }
 
-            result.put("basePrice", Double.valueOf(defaultPrice));
-            result.put("price", Double.valueOf(defaultPrice));
-            result.put("defaultPrice", Double.valueOf(defaultPrice));
-            result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getDouble("price") : null);
-            result.put("averageCost", averageCostValue != null ? averageCostValue.getDouble("price") : null);
-            result.put("promoPrice", promoPriceValue != null ? promoPriceValue.getDouble("price") : null);
-            result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getDouble("price") : null);
+            result.put("basePrice", defaultPrice);
+            result.put("price", defaultPrice);
+            result.put("defaultPrice", defaultPrice);
+            result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getBigDecimal("price") : null);
+            result.put("averageCost", averageCostValue != null ? averageCostValue.getBigDecimal("price") : null);
+            result.put("promoPrice", promoPriceValue != null ? promoPriceValue.getBigDecimal("price") : null);
+            result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getBigDecimal("price") : null);
             result.put("validPriceFound", Boolean.valueOf(validPriceFound));
             result.put("isSale", Boolean.FALSE);
             result.put("orderItemPriceInfos", orderItemPriceInfos);
@@ -575,7 +574,7 @@
                             if ("PRIP_QUANTITY".equals(productPriceCond.getString("inputParamEnumId"))) {
                                 foundQuantityInputParam = true;
                             } else {
-                                if (!checkPriceCondition(productPriceCond, productId, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, Double.valueOf(quantity), listPriceDbl.doubleValue(), currencyUomId, delegator, nowTimestamp)) {
+                                if (!checkPriceCondition(productPriceCond, productId, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, quantity, listPrice, currencyUomId, delegator, nowTimestamp)) {
                                     allExceptQuantTrue = false;
                                 }
                             }
@@ -599,7 +598,7 @@
                         ruleListToUse.add(quantityProductPriceRule);
                         ruleListToUse.addAll(nonQuantityProductPriceRules);
                     
-                        Map<String, Object> quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
+                        Map<String, Object> quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPrice, defaultPrice, promoPrice,
                             wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
                             averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
                             webSiteId, partyId, null, currencyUomId, delegator, nowTimestamp);
@@ -615,10 +614,10 @@
                     result.put("allQuantityPrices", allQuantityPrices);
 
                     // use a quantity 1 to get the main price, then fill in the quantity break prices
-                    Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
+                    Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPrice, defaultPrice, promoPrice,
                         wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
                         averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
-                        webSiteId, partyId, Double.valueOf(1.0), currencyUomId, delegator, nowTimestamp);
+                        webSiteId, partyId, BigDecimal.ONE, currencyUomId, delegator, nowTimestamp);
                     result.putAll(calcResults);
                     // The orderItemPriceInfos out parameter requires a special treatment:
                     // the list of OrderItemPriceInfos generated by the price rule is appended to
@@ -633,10 +632,10 @@
                             checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
                     if (errorResult != null) return errorResult;
                 } else {
-                    Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
+                    Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPrice, defaultPrice, promoPrice,
                         wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
                         averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
-                        webSiteId, partyId, Double.valueOf(quantity), currencyUomId, delegator, nowTimestamp);
+                        webSiteId, partyId, quantity, currencyUomId, delegator, nowTimestamp);
                     result.putAll(calcResults);
                     // The orderItemPriceInfos out parameter requires a special treatment:
                     // the list of OrderItemPriceInfos generated by the price rule is appended to
@@ -662,16 +661,16 @@
     }
     
     public static Map<String, Object> addGeneralResults(Map<String, Object> result, GenericValue competitivePriceValue, GenericValue specialPromoPriceValue, GenericValue productStore,
-        String checkIncludeVat, String currencyUomId, String productId, double quantity, String partyId, LocalDispatcher dispatcher) {
-        result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getDouble("price") : null);
-        result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getDouble("price") : null);
+        String checkIncludeVat, String currencyUomId, String productId, BigDecimal quantity, String partyId, LocalDispatcher dispatcher) {
+        result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getBigDecimal("price") : null);
+        result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getBigDecimal("price") : null);
         result.put("currencyUsed", currencyUomId);
 
         // okay, now we have the calculated price, see if we should add in tax and if so do it
         if ("Y".equals(checkIncludeVat) && productStore != null && "Y".equals(productStore.getString("showPricesWithVatTax"))) {
             Map<String, Object> calcTaxForDisplayContext = UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
-                    "productId", productId, "quantity", BigDecimal.valueOf(quantity),
-                    "basePrice", BigDecimal.valueOf(((Double) result.get("price")).doubleValue()));
+                    "productId", productId, "quantity", quantity,
+                    "basePrice", (BigDecimal) result.get("price"));
             if (UtilValidate.isNotEmpty(partyId)) {
                 calcTaxForDisplayContext.put("billToPartyId", partyId);
             }
@@ -682,25 +681,25 @@
                     return ServiceUtil.returnError("Error calculating VAT tax (with calcTaxForDisplay service)", null, null, calcTaxForDisplayResult);
                 }
                 // taxTotal, taxPercentage, priceWithTax
-                result.put("price", Double.valueOf(((BigDecimal) calcTaxForDisplayResult.get("priceWithTax")).doubleValue()));
+                result.put("price", (BigDecimal) calcTaxForDisplayResult.get("priceWithTax"));
 
                 // based on the taxPercentage calculate the other amounts, including: listPrice, defaultPrice, averageCost, promoPrice, competitivePrice
                 BigDecimal taxPercentage = (BigDecimal) calcTaxForDisplayResult.get("taxPercentage");
                 BigDecimal taxMultiplier = ONE_BASE.add(taxPercentage.divide(PERCENT_SCALE, taxCalcScale));
                 if (result.get("listPrice") != null) {
-                    result.put("listPrice", Double.valueOf( BigDecimal.valueOf(((Double) result.get("listPrice")).doubleValue()).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ).doubleValue()));
+                    result.put("listPrice", ((BigDecimal) result.get("listPrice")).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ));
                 }
                 if (result.get("defaultPrice") != null) {                    
-                    result.put("defaultPrice", Double.valueOf( BigDecimal.valueOf(((Double) result.get("defaultPrice")).doubleValue()).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ).doubleValue()));
+                    result.put("defaultPrice", ((BigDecimal) result.get("defaultPrice")).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ));
                 }
                 if (result.get("averageCost") != null) {
-                    result.put("averageCost", Double.valueOf( BigDecimal.valueOf(((Double) result.get("averageCost")).doubleValue()).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ).doubleValue()));
+                    result.put("averageCost", ((BigDecimal) result.get("averageCost")).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ));
                 }              
                 if (result.get("promoPrice") != null) {
-                    result.put("promoPrice", Double.valueOf( BigDecimal.valueOf(((Double) result.get("promoPrice")).doubleValue()).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ).doubleValue()));
+                    result.put("promoPrice", ((BigDecimal) result.get("promoPrice")).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ));
                 }
                 if (result.get("competitivePrice") != null) {
-                    result.put("competitivePrice", Double.valueOf( BigDecimal.valueOf(((Double) result.get("competitivePrice")).doubleValue()).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ).doubleValue()));
+                    result.put("competitivePrice", ((BigDecimal) result.get("competitivePrice")).multiply(taxMultiplier).setScale( taxFinalScale, taxRounding ));
                 }
             } catch (GenericServiceException e) {
                 String errMsg = "Error calculating VAT tax (with calcTaxForDisplay service): " + e.toString();
@@ -861,10 +860,10 @@
         return productPriceRules;
     }
     
-    public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, double listPrice, double defaultPrice, double promoPrice,
-        double wholesalePrice, GenericValue maximumPriceValue, GenericValue minimumPriceValue, boolean validPriceFound,
+    public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, BigDecimal listPrice, BigDecimal defaultPrice, BigDecimal promoPrice,
+        BigDecimal wholesalePrice, GenericValue maximumPriceValue, GenericValue minimumPriceValue, boolean validPriceFound,
         GenericValue averageCostValue, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId,
-        String webSiteId, String partyId, Double quantity, String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
+        String webSiteId, String partyId, BigDecimal quantity, String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
     
         Map<String, Object> calcResults = FastMap.newInstance();
 
@@ -878,11 +877,11 @@
         int totalRules = 0;
 
         // get some of the base values to calculate with
-        double averageCost = (averageCostValue != null && averageCostValue.get("price") != null) ? averageCostValue.getDouble("price").doubleValue() : listPrice;
-        double margin = listPrice - averageCost;
+        BigDecimal averageCost = (averageCostValue != null && averageCostValue.get("price") != null) ? averageCostValue.getBigDecimal("price") : listPrice;
+        BigDecimal margin = listPrice.subtract(averageCost);
 
         // calculate running sum based on listPrice and rules found
-        double price = listPrice;
+        BigDecimal price = listPrice;
         
         for (GenericValue productPriceRule: productPriceRules) {
             String productPriceRuleId = productPriceRule.getString("productPriceRuleId");
@@ -945,39 +944,39 @@
                     isSale = true;
                 }
 
-                Collection<GenericValue> productPriceActions = delegator.findByAndCache("ProductPriceAction", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
+                List<GenericValue> productPriceActions = delegator.findByAndCache("ProductPriceAction", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
                 for (GenericValue productPriceAction: productPriceActions) {
 
                     totalActions++;
 
                     // yeah, finally here, perform the action, ie, modify the price
-                    double modifyAmount = 0;
+                    BigDecimal modifyAmount = BigDecimal.ZERO;
 
                     if ("PRICE_POD".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         if (productPriceAction.get("amount") != null) {
-                            modifyAmount = defaultPrice * (productPriceAction.getDouble("amount").doubleValue() / 100.0);
+                            modifyAmount = defaultPrice.multiply(productPriceAction.getBigDecimal("amount").movePointLeft(2));
                         }
                     } else if ("PRICE_POL".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         if (productPriceAction.get("amount") != null) {
-                            modifyAmount = listPrice * (productPriceAction.getDouble("amount").doubleValue() / 100.0);
+                            modifyAmount = listPrice.multiply(productPriceAction.getBigDecimal("amount").movePointLeft(2));
                         }
                     } else if ("PRICE_POAC".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         if (productPriceAction.get("amount") != null) {
-                            modifyAmount = averageCost * (productPriceAction.getDouble("amount").doubleValue() / 100.0);
+                            modifyAmount = averageCost.multiply(productPriceAction.getBigDecimal("amount").movePointLeft(2));
                         }
                     } else if ("PRICE_POM".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         if (productPriceAction.get("amount") != null) {
-                            modifyAmount = margin * (productPriceAction.getDouble("amount").doubleValue() / 100.0);
+                            modifyAmount = margin.multiply(productPriceAction.getBigDecimal("amount").movePointLeft(2));
                         }
                     } else if ("PRICE_FOL".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         if (productPriceAction.get("amount") != null) {
-                            modifyAmount = productPriceAction.getDouble("amount").doubleValue();
+                            modifyAmount = productPriceAction.getBigDecimal("amount");
                         }
                     } else if ("PRICE_FLAT".equals(productPriceAction.getString("productPriceActionTypeId"))) {
                         // this one is a bit different, break out of the loop because we now have our final price
                         foundFlatOverride = true;
                         if (productPriceAction.get("amount") != null) {
-                            price = productPriceAction.getDouble("amount").doubleValue();
+                            price = productPriceAction.getBigDecimal("amount");
                         } else {
                             Debug.logInfo("ProductPriceAction had null amount, using default price: " + defaultPrice + " for product with id " + productId, module);
                             price = defaultPrice;
@@ -988,18 +987,18 @@
                         foundFlatOverride = true;
                         price = promoPrice;
                         if (productPriceAction.get("amount") != null) {
-                            price += productPriceAction.getDouble("amount").doubleValue();
+                            price = price.add(productPriceAction.getBigDecimal("amount"));
                         }
-                        if (price == 0.00) {
-                            if (defaultPrice != 0.00) {
+                        if (price.compareTo(BigDecimal.ZERO) == 0) {
+                            if (defaultPrice.compareTo(BigDecimal.ZERO) != 0) {
                                 Debug.logInfo("PromoPrice and ProductPriceAction had null amount, using default price: " + defaultPrice + " for product with id " + productId, module);
                                 price = defaultPrice;
-                            } else if (listPrice != 0.00) {
+                            } else if (listPrice.compareTo(BigDecimal.ZERO) != 0) {
                                 Debug.logInfo("PromoPrice and ProductPriceAction had null amount and no default price was available, using list price: " + listPrice + " for product with id " + productId, module);
                                 price = listPrice;
                             } else {
                                 Debug.logError("PromoPrice and ProductPriceAction had null amount and no default or list price was available, so price is set to zero for product with id " + productId, module);
-                                price = 0.00;
+                                price = BigDecimal.ZERO;
                             }
                             isSale = false;                // reverse isSale flag, as this sale rule was actually not applied
                         }
@@ -1008,18 +1007,18 @@
                         foundFlatOverride = true;
                         price = wholesalePrice;
                         if (productPriceAction.get("amount") != null) {
-                            price += productPriceAction.getDouble("amount").doubleValue();
+                            price = price.add(productPriceAction.getBigDecimal("amount"));
                         }
-                        if (price == 0.00) {
-                            if (defaultPrice != 0.00) {
+                        if (price.compareTo(BigDecimal.ZERO) == 0) {
+                            if (defaultPrice.compareTo(BigDecimal.ZERO) != 0) {
                                 Debug.logInfo("WholesalePrice and ProductPriceAction had null amount, using default price: " + defaultPrice + " for product with id " + productId, module);
                                 price = defaultPrice;
-                            } else if (listPrice != 0.00) {
+                            } else if (listPrice.compareTo(BigDecimal.ZERO) != 0) {
                                 Debug.logInfo("WholesalePrice and ProductPriceAction had null amount and no default price was available, using list price: " + listPrice + " for product with id " + productId, module);
                                 price = listPrice;
                             } else {
                                 Debug.logError("WholesalePrice and ProductPriceAction had null amount and no default or list price was available, so price is set to zero for product with id " + productId, module);
-                                price = 0.00;
+                                price = BigDecimal.ZERO;
                             }
                             isSale = false; // reverse isSale flag, as this sale rule was actually not applied
                         }
@@ -1037,7 +1036,7 @@
 
                     orderItemPriceInfo.set("productPriceRuleId", productPriceAction.get("productPriceRuleId"));
                     orderItemPriceInfo.set("productPriceActionSeqId", productPriceAction.get("productPriceActionSeqId"));
-                    orderItemPriceInfo.set("modifyAmount", Double.valueOf(modifyAmount));
+                    orderItemPriceInfo.set("modifyAmount", modifyAmount);
                     orderItemPriceInfo.set("rateCode", productPriceAction.get("rateCode"));
                     // make sure description is <= than 250 chars
                     String priceInfoDescriptionString = priceInfoDescription.toString();
@@ -1051,7 +1050,7 @@
                     if (foundFlatOverride) {
                         break;
                     } else {
-                        price += modifyAmount;
+                        price = price.add(modifyAmount);
                     }
                 }
             }
@@ -1081,25 +1080,25 @@
         }
 
         // ========= ensure calculated price is not below minSalePrice or above maxSalePrice =========
-        Double maxSellPrice = maximumPriceValue != null ? maximumPriceValue.getDouble("price") : null;
-        if (maxSellPrice != null && price > maxSellPrice.doubleValue()) {
-            price = maxSellPrice.doubleValue();
+        BigDecimal maxSellPrice = maximumPriceValue != null ? maximumPriceValue.getBigDecimal("price") : null;
+        if (maxSellPrice != null && price.compareTo(maxSellPrice) > 0) {
+            price = maxSellPrice;
         }
         // min price second to override max price, safety net
-        Double minSellPrice = minimumPriceValue != null ? minimumPriceValue.getDouble("price") : null;
-        if (minSellPrice != null && price < minSellPrice.doubleValue()) {
-            price = minSellPrice.doubleValue();
+        BigDecimal minSellPrice = minimumPriceValue != null ? minimumPriceValue.getBigDecimal("price") : null;
+        if (minSellPrice != null && price.compareTo(minSellPrice) < 0) {
+            price = minSellPrice;
             // since we have found a minimum price that has overriden a the defaultPrice, even if no valid one was found, we will consider it as if one had been...
             validPriceFound = true;
         }
 
         if (Debug.verboseOn()) Debug.logVerbose("Final Calculated price: " + price + ", rules: " + totalRules + ", conds: " + totalConds + ", actions: " + totalActions, module);
 
-        calcResults.put("basePrice", Double.valueOf(price));
-        calcResults.put("price", Double.valueOf(price));
-        calcResults.put("listPrice", Double.valueOf(listPrice));
-        calcResults.put("defaultPrice", Double.valueOf(defaultPrice));
-        calcResults.put("averageCost", Double.valueOf(averageCost));
+        calcResults.put("basePrice", price);
+        calcResults.put("price", price);
+        calcResults.put("listPrice", listPrice);
+        calcResults.put("defaultPrice", defaultPrice);
+        calcResults.put("averageCost", averageCost);
         calcResults.put("orderItemPriceInfos", orderItemPriceInfos);
         calcResults.put("isSale", Boolean.valueOf(isSale));
         calcResults.put("validPriceFound", Boolean.valueOf(validPriceFound));
@@ -1108,7 +1107,7 @@
     }
 
     public static boolean checkPriceCondition(GenericValue productPriceCond, String productId, String virtualProductId, String prodCatalogId,
-            String productStoreGroupId, String webSiteId, String partyId, Double quantity, double listPrice,
+            String productStoreGroupId, String webSiteId, String partyId, BigDecimal quantity, BigDecimal listPrice,
             String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
         if (Debug.verboseOn()) Debug.logVerbose("Checking price condition: " + productPriceCond, module);
         int compare = 0;
@@ -1182,7 +1181,7 @@
                 // NOTE: setting compare = 0 won't do the trick here because the condition won't always be or include and equal
                 return true;
             } else {
-                compare = quantity.compareTo(Double.valueOf(productPriceCond.getString("condValue")));
+                compare = quantity.compareTo(new BigDecimal(productPriceCond.getString("condValue")));
             }
         } else if ("PRIP_PARTY_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
             if (UtilValidate.isNotEmpty(partyId)) {
@@ -1250,9 +1249,9 @@
                 compare = 1;
             }
         } else if ("PRIP_LIST_PRICE".equals(productPriceCond.getString("inputParamEnumId"))) {
-            Double listPriceValue = Double.valueOf(listPrice);
+            BigDecimal listPriceValue = listPrice;
 
-            compare = listPriceValue.compareTo(Double.valueOf(productPriceCond.getString("condValue")));
+            compare = listPriceValue.compareTo(new BigDecimal(productPriceCond.getString("condValue")));
         } else if ("PRIP_CURRENCY_UOMID".equals(productPriceCond.getString("inputParamEnumId"))) {
             compare = currencyUomId.compareTo(productPriceCond.getString("condValue"));
         } else {
@@ -1291,13 +1290,13 @@
 
         List<GenericValue> orderItemPriceInfos = FastList.newInstance();
         boolean validPriceFound = false;
-        double price = 0.0;
+        BigDecimal price = BigDecimal.ZERO;
 
         GenericValue product = (GenericValue)context.get("product");
         String productId = product.getString("productId");
         String currencyUomId = (String)context.get("currencyUomId");
         String partyId = (String)context.get("partyId");
-        Double quantity = (Double)context.get("quantity");
+        BigDecimal quantity = (BigDecimal)context.get("quantity");
         
         // a) Get the Price from the Agreement* data model
         // TODO: Implement this
@@ -1321,20 +1320,21 @@
             if (productSuppliers != null) {
                 for (GenericValue productSupplier: productSuppliers) {
                     if (!validPriceFound) {
-                        price = ((Double)productSupplier.get("lastPrice")).doubleValue();
+                        price = ((BigDecimal)productSupplier.get("lastPrice"));
                         validPriceFound = true;
                     }
                     // add a orderItemPriceInfo element too, without orderId or orderItemId
                     StringBuilder priceInfoDescription = new StringBuilder();
                     priceInfoDescription.append("SupplierProduct ");
                     priceInfoDescription.append("[minimumOrderQuantity:");
-                    priceInfoDescription.append(productSupplier.getDouble("minimumOrderQuantity"));
-                    priceInfoDescription.append(", lastPrice: ").append(productSupplier.getDouble("lastPrice"));
+                    priceInfoDescription.append(productSupplier.getBigDecimal("minimumOrderQuantity"));
+                    priceInfoDescription.append(", lastPrice: ");
+                    priceInfoDescription.append(productSupplier.getBigDecimal("lastPrice"));
                     priceInfoDescription.append("]");
                     GenericValue orderItemPriceInfo = delegator.makeValue("OrderItemPriceInfo");
                     //orderItemPriceInfo.set("productPriceRuleId", productPriceAction.get("productPriceRuleId"));
                     //orderItemPriceInfo.set("productPriceActionSeqId", productPriceAction.get("productPriceActionSeqId"));
-                    //orderItemPriceInfo.set("modifyAmount", Double.valueOf(modifyAmount));
+                    //orderItemPriceInfo.set("modifyAmount", modifyAmount);
                     // make sure description is <= than 250 chars
                     String priceInfoDescriptionString = priceInfoDescription.toString();
                     if (priceInfoDescriptionString.length() > 250) {
@@ -1384,12 +1384,12 @@
             // use the most current price
             GenericValue thisPrice = EntityUtil.getFirst(pricesToUse);
             if (thisPrice != null) {
-                price = thisPrice.getDouble("price").doubleValue();
+                price = thisPrice.getBigDecimal("price");
                 validPriceFound = true;
             }
         }
 
-        result.put("price", Double.valueOf(price));
+        result.put("price", price);
         result.put("validPriceFound", Boolean.valueOf(validPriceFound));
         result.put("orderItemPriceInfos", orderItemPriceInfos);
         return result;

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java Mon Jan  5 23:13:36 2009
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.product.product;
 
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.Iterator;
 import java.util.List;
@@ -36,6 +37,7 @@
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilParse;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
@@ -301,7 +303,7 @@
         String quantityStr = request.getParameter("QUANTITY");
         String sequenceNumStr = request.getParameter("SEQUENCE_NUM");
         Timestamp thruDate = null;
-        Double quantity = null;
+        BigDecimal quantity = null;
         Long sequenceNum = null;
 
         if (UtilValidate.isNotEmpty(thruDateStr)) {
@@ -313,8 +315,8 @@
         }
         if (UtilValidate.isNotEmpty(quantityStr)) {
             try {
-                quantity = Double.valueOf(quantityStr);
-            } catch (Exception e) {
+                quantity = new BigDecimal(quantityStr);
+            } catch (NumberFormatException e) {
                 errMsgList.add(UtilProperties.getMessage(resource,"productevents.quantity_not_formatted_correctly", UtilHttp.getLocale(request)));
             }
         }
@@ -431,10 +433,10 @@
                     product.set("lastModifiedDate", nowTimestamp);
                     product.setString("lastModifiedByUserLogin", userLogin.getString("userLoginId"));
                     try {
-                        product.set("productHeight", parseDoubleForEntity(request.getParameter("productHeight")));
-                        product.set("productWidth", parseDoubleForEntity(request.getParameter("productWidth")));
-                        product.set("productDepth", parseDoubleForEntity(request.getParameter("productDepth")));
-                        product.set("weight", parseDoubleForEntity(request.getParameter("weight")));
+                        product.set("productHeight", UtilParse.parseBigDecimalForEntity(request.getParameter("productHeight")));
+                        product.set("productWidth", UtilParse.parseBigDecimalForEntity(request.getParameter("productWidth")));
+                        product.set("productDepth", UtilParse.parseBigDecimalForEntity(request.getParameter("productDepth")));
+                        product.set("weight", UtilParse.parseBigDecimalForEntity(request.getParameter("weight")));
     
                         // default unit settings for shipping parameters
                         product.set("heightUomId", "LEN_in");
@@ -442,10 +444,10 @@
                         product.set("depthUomId", "LEN_in");
                         product.set("weightUomId", "WT_oz");
     
-                        Double floz = parseDoubleForEntity(request.getParameter("~floz"));
-                        Double ml = parseDoubleForEntity(request.getParameter("~ml"));
-                        Double ntwt = parseDoubleForEntity(request.getParameter("~ntwt"));
-                        Double grams = parseDoubleForEntity(request.getParameter("~grams"));
+                        BigDecimal floz = UtilParse.parseBigDecimalForEntity(request.getParameter("~floz"));
+                        BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml"));
+                        BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt"));
+                        BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams"));
     
                         List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
                         setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
@@ -468,20 +470,20 @@
                     do {
                         GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
                         try {
-                            product.set("productHeight", parseDoubleForEntity(request.getParameter("productHeight" + attribIdx)));
-                            product.set("productWidth", parseDoubleForEntity(request.getParameter("productWidth" + attribIdx)));
-                            product.set("productDepth", parseDoubleForEntity(request.getParameter("productDepth" + attribIdx)));
-                            product.set("weight", parseDoubleForEntity(request.getParameter("weight" + attribIdx)));
-                            Double floz = parseDoubleForEntity(request.getParameter("~floz" + attribIdx));
-                            Double ml = parseDoubleForEntity(request.getParameter("~ml" + attribIdx));
-                            Double ntwt = parseDoubleForEntity(request.getParameter("~ntwt" + attribIdx));
-                            Double grams = parseDoubleForEntity(request.getParameter("~grams" + attribIdx));
+                            product.set("productHeight", UtilParse.parseBigDecimalForEntity(request.getParameter("productHeight" + attribIdx)));
+                            product.set("productWidth", UtilParse.parseBigDecimalForEntity(request.getParameter("productWidth" + attribIdx)));
+                            product.set("productDepth", UtilParse.parseBigDecimalForEntity(request.getParameter("productDepth" + attribIdx)));
+                            product.set("weight", UtilParse.parseBigDecimalForEntity(request.getParameter("weight" + attribIdx)));
+                            BigDecimal floz = UtilParse.parseBigDecimalForEntity(request.getParameter("~floz" + attribIdx));
+                            BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml" + attribIdx));
+                            BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt" + attribIdx));
+                            BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams" + attribIdx));
     
-                                List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
-                                setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
-                                setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
-                                setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_g", "AMOUNT", grams);
-                                setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_oz", "AMOUNT", ntwt);
+                            List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
+                            setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
+                            setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
+                            setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_g", "AMOUNT", grams);
+                            setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_oz", "AMOUNT", ntwt);
                             product.store();
                         } catch (NumberFormatException nfe) {
                             String errMsg = "Shipping Dimensions and Weights must be numbers.";
@@ -525,7 +527,7 @@
      * @throws GenericEntityException
      */
     private static void setOrCreateProdFeature(GenericDelegator delegator, String productId, List<GenericValue> currentProductFeatureAndAppls,
-                                          String uomId, String productFeatureTypeId, Double numberSpecified) throws GenericEntityException {
+                                          String uomId, String productFeatureTypeId, BigDecimal numberSpecified) throws GenericEntityException {
         
         GenericValue productFeatureType = delegator.findByPrimaryKey("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId));
         GenericValue uom = delegator.findByPrimaryKey("Uom", UtilMisc.toMap("uomId", uomId));
@@ -538,7 +540,7 @@
         // go through each; need to remove? do it now
         boolean foundOneEqual = false;
         for (GenericValue typeUomProductFeatureAndAppl: typeUomProductFeatureAndApplList) {
-            if ((numberSpecified != null) && (numberSpecified.equals(typeUomProductFeatureAndAppl.getDouble("numberSpecified")))) {
+            if ((numberSpecified != null) && (numberSpecified.equals(typeUomProductFeatureAndAppl.getBigDecimal("numberSpecified")))) {
                 foundOneEqual = true;
             } else {
                 // remove the PFA...

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Mon Jan  5 23:13:36 2009
@@ -18,6 +18,7 @@
  */
 package org.ofbiz.product.product;
 
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -1527,11 +1528,11 @@
 
     public static class ListPriceRangeConstraint extends ProductSearchConstraint {
         public static final String constraintName = "ListPriceRange";
-        protected Double lowPrice;
-        protected Double highPrice;
+        protected BigDecimal lowPrice;
+        protected BigDecimal highPrice;
         protected String currencyUomId;
 
-        public ListPriceRangeConstraint(Double lowPrice, Double highPrice, String currencyUomId) {
+        public ListPriceRangeConstraint(BigDecimal lowPrice, BigDecimal highPrice, String currencyUomId) {
             this.lowPrice = lowPrice;
             this.highPrice = highPrice;
             this.currencyUomId = UtilValidate.isNotEmpty(currencyUomId) ? currencyUomId : "USD";

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Mon Jan  5 23:13:36 2009
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.ofbiz.product.product;
 
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.Locale;
@@ -265,7 +266,7 @@
 
         Timestamp thruDate = null;
         Timestamp fromDate = null;
-        Double amount = null;
+        BigDecimal amount = null;
         Long sequenceNum = null;
 
         try {
@@ -276,7 +277,7 @@
                 thruDate = Timestamp.valueOf(thruDateStr);
             }
             if (UtilValidate.isNotEmpty(amountStr)) {
-                amount = Double.valueOf(amountStr);
+                amount = new BigDecimal(amountStr);
             }
             if (UtilValidate.isNotEmpty(sequenceNumStr)) {
                 sequenceNum= Long.valueOf(sequenceNumStr);

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Mon Jan  5 23:13:36 2009
@@ -19,6 +19,7 @@
 package org.ofbiz.product.product;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -692,19 +693,19 @@
         
         // add a list price range to the search
         if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW")) || UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
-            Double listPriceLow = null;
-            Double listPriceHigh = null;
+            BigDecimal listPriceLow = null;
+            BigDecimal listPriceHigh = null;
             String listPriceCurrency = UtilHttp.getCurrencyUom(request);
             if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW"))) {
                 try {
-                    listPriceLow = Double.valueOf((String) parameters.get("LIST_PRICE_LOW"));
+                    listPriceLow = new BigDecimal((String) parameters.get("LIST_PRICE_LOW"));
                 } catch (NumberFormatException e) {
                     Debug.logError("Error parsing LIST_PRICE_LOW parameter [" + (String) parameters.get("LIST_PRICE_LOW") + "]: " + e.toString(), module);
                 }
             }
             if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
                 try {
-                    listPriceHigh = Double.valueOf((String) parameters.get("LIST_PRICE_HIGH"));
+                    listPriceHigh = new BigDecimal((String) parameters.get("LIST_PRICE_HIGH"));
                 } catch (NumberFormatException e) {
                     Debug.logError("Error parsing LIST_PRICE_HIGH parameter [" + (String) parameters.get("LIST_PRICE_HIGH") + "]: " + e.toString(), module);
                 }
@@ -727,19 +728,19 @@
                 listPriceHighStr = null;
             }
 
-            Double listPriceLow = null;
-            Double listPriceHigh = null;
+            BigDecimal listPriceLow = null;
+            BigDecimal listPriceHigh = null;
             String listPriceCurrency = UtilHttp.getCurrencyUom(request);
             if (UtilValidate.isNotEmpty(listPriceLowStr)) {
                 try {
-                    listPriceLow = Double.valueOf(listPriceLowStr);
+                    listPriceLow = new BigDecimal(listPriceLowStr);
                 } catch (NumberFormatException e) {
                     Debug.logError("Error parsing low part of LIST_PRICE_RANGE parameter [" + listPriceLowStr + "]: " + e.toString(), module);
                 }
             }
             if (UtilValidate.isNotEmpty(listPriceHighStr)) {
                 try {
-                    listPriceHigh = Double.valueOf(listPriceHighStr);
+                    listPriceHigh = new BigDecimal(listPriceHighStr);
                 } catch (NumberFormatException e) {
                     Debug.logError("Error parsing high part of LIST_PRICE_RANGE parameter [" + listPriceHighStr + "]: " + e.toString(), module);
                 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=731851&r1=731850&r2=731851&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Mon Jan  5 23:13:36 2009
@@ -22,6 +22,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.sql.Timestamp;
 import java.util.*;
@@ -243,7 +244,7 @@
 
             // next check inventory for each item: if inventory is not required or is available
             try {
-                Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productIdTo, "quantity", Double.valueOf(1.0)));
+                Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.<String, Object>toMap("productStoreId", productStoreId, "productId", productIdTo, "quantity", BigDecimal.ONE));
                 if (ServiceUtil.isError(invReqResult)) {
                     return ServiceUtil.returnError("Error calling the isStoreInventoryRequired when building the variant product tree.", null, null, invReqResult);
                 } else if ("Y".equals((String) invReqResult.get("availableOrNotRequired"))) {
@@ -875,8 +876,8 @@
                             return ServiceUtil.returnError(e.getMessage());
                         }
 
-                        Double availableToPromiseTotal = (Double) invRes.get("availableToPromiseTotal");
-                        if (availableToPromiseTotal != null && availableToPromiseTotal.doubleValue() > 0) {
+                        BigDecimal availableToPromiseTotal = (BigDecimal) invRes.get("availableToPromiseTotal");
+                        if (availableToPromiseTotal != null && availableToPromiseTotal.compareTo(BigDecimal.ZERO) > 0) {
                             // refresh the product so we can update it
                             GenericValue productToUpdate = null;
                             try {