|
Author: ashish
Date: Sat Sep 15 05:25:28 2012 New Revision: 1385014 URL: http://svn.apache.org/viewvc?rev=1385014&view=rev 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/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1385014&r1=1385013&r2=1385014&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sat Sep 15 05:25:28 2012 @@ -42,6 +42,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; @@ -3639,8 +3640,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()); } @@ -3683,8 +3684,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); @@ -3748,8 +3755,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()); } |
| Free forum by Nabble | Edit this page |
