You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2012/09/15 07:31:07 UTC

svn commit: r1385017 - /ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

Author: ashish
Date: Sat Sep 15 05:31:06 2012
New Revision: 1385017

URL: http://svn.apache.org/viewvc?rev=1385017&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/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1385017&r1=1385016&r2=1385017&view=diff
==============================================================================
--- ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/order/OrderServices.java Sat Sep 15 05:31:06 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.UtilMisc;
@@ -3441,8 +3442,8 @@ public class OrderServices {
             String quantityStr = (String) 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());
             }
@@ -3486,8 +3487,14 @@ public class OrderServices {
                 if (overridePriceMap.containsKey(itemSeqId)) {
                     String priceStr = (String) 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);
@@ -3552,8 +3559,8 @@ public class OrderServices {
             String quantityStr = (String) 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());
             }