Fixed issue 35349:Callout problem when working with comma as decimal separator
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Mon, 27 Feb 2017 10:46:35 +0100
changeset 31445 d2f5d812ddda
parent 31444 d074c8f621ff
child 31446 793c3a7ef62d
Fixed issue 35349:Callout problem when working with comma as decimal separator

The problem was raised when a default format were switched, it means, when
decimal and group separator were switched. In this situation, when
SimpleCalloutInformationProvider class was used to obtain the current element
value and this current element was a BigDecimal, the format was not managed
properly. This occurred because getCurrentElementValue method always retrieved
a String element instead of Object element, in tyhis case BigDecimal.

In this situation, managesUpdatedValuesForCallout method of FIC class compare
if element is a String or not. If a BigDecimal is retrieved as String element,
in this part of the code the format is not managed properly when decimal separator
is comma. The code manage the comma separator as group separator and removed it.

When the decimal separator is dot (.) the format is managed as expected although
this method retrieves a String object (e.g. "1.23"). When decimal separator is
comma (,) this BigDecimal (e.g. 1,24) is retrieved by getCurrentElementValue method
as String value and the format is missed.

This problem has been fixed by take into account type of current element inside
getCurrentElementValue method. Now this method retrieves an object value. In this
case, a BigDecimal is retrieved. Now the format is managed properly.
src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java	Tue Feb 21 14:16:33 2017 +0100
+++ b/src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java	Mon Feb 27 10:46:35 2017 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2016 Openbravo SLU 
+ * All portions are Copyright (C) 2016-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -62,10 +62,10 @@
   @Override
   public Object getCurrentElementValue(Object element) {
     JSONObject json = (JSONObject) element;
-    String value = null;
+    Object value = null;
     try {
       if (json.has(CalloutConstants.CLASSIC_VALUE)) {
-        value = json.getString(CalloutConstants.CLASSIC_VALUE);
+        value = json.get(CalloutConstants.CLASSIC_VALUE);
       }
     } catch (JSONException e) {
       log.error("Error retrieving value from json {}", json);