Author: ashish
Date: Sat Sep 15 05:29:43 2012
New Revision: 1385016

URL: http://svn.apache.org/viewvc?rev=1385016&view=rev
Log:
Applied bug fix from trunk revision: 1385014
Log:
Applied bug fix from jira issue - OFBIZ-4972 - NumberFormateException while 
update order items.
If order item price or quantity is greater then 999 then update order items 
service throw NumberFormateException.
Steps to regenerate:
Create an order(SO/PO).
Edit order items, set order price 1000 and update order items.
Again edit order items and try to update price from (1,000 to 1,002).
System will throw NPE and if same will perform for quantity then it will throw 
NumberFormatException on console.
Thanks Deepak for the contribution.

Modified:
    
ofbiz/branches/release11.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: 
ofbiz/branches/release11.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release11.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1385016&r1=1385015&r2=1385016&view=diff
==============================================================================
--- 
ofbiz/branches/release11.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
 (original)
+++ 
ofbiz/branches/release11.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
 Sat Sep 15 05:29:43 2012
@@ -41,6 +41,7 @@ import javolution.util.FastSet;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.GeneralRuntimeException;
+import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilGenerics;
@@ -3567,8 +3568,8 @@ public class OrderServices {
             String quantityStr = itemQtyMap.get(key);
             BigDecimal groupQty = BigDecimal.ZERO;
             try {
-                groupQty = new BigDecimal(quantityStr);
-            } catch (NumberFormatException e) {
+                groupQty = (BigDecimal) 
ObjectType.simpleTypeConvert(quantityStr, "BigDecimal", null, locale);
+            } catch (GeneralException e) {
                 Debug.logError(e, module);
                 return ServiceUtil.returnError(e.getMessage());
             }
@@ -3613,8 +3614,14 @@ public class OrderServices {
                 if (overridePriceMap.containsKey(itemSeqId)) {
                     String priceStr = itemPriceMap.get(itemSeqId);
                     if (UtilValidate.isNotEmpty(priceStr)) {
-                        BigDecimal price = new BigDecimal("-1");
-                        price = new 
BigDecimal(priceStr).setScale(orderDecimals, orderRounding);
+                        BigDecimal price = null;
+                        try {
+                            price = (BigDecimal) 
ObjectType.simpleTypeConvert(priceStr, "BigDecimal", null, locale);
+                        } catch (GeneralException e) {
+                            Debug.logError(e, module);
+                            return ServiceUtil.returnError(e.getMessage());
+                        }
+                        price = price.setScale(orderDecimals, orderRounding);
                         cartItem.setBasePrice(price);
                         cartItem.setIsModifiedPrice(true);
                         Debug.logInfo("Set item price: [" + itemSeqId + "] " + 
price, module);
@@ -3680,8 +3687,8 @@ public class OrderServices {
             String quantityStr = itemQtyMap.get(key);
             BigDecimal groupQty = BigDecimal.ZERO;
             try {
-                groupQty = new BigDecimal(quantityStr);
-            } catch (NumberFormatException e) {
+                groupQty = (BigDecimal) 
ObjectType.simpleTypeConvert(quantityStr, "BigDecimal", null, locale);
+            } catch (GeneralException e) {
                 Debug.logError(e, module);
                 return ServiceUtil.returnError(e.getMessage());
             }


Reply via email to