fixed bug 28720: callouts incorrectly set big non integer numbers
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 22 Jan 2015 11:14:24 +0100
changeset 24121 3a018e1f7069
parent 24120 a598b05243fc
child 24122 e18688c19880
fixed bug 28720: callouts incorrectly set big non integer numbers

When a big non integer number was set by a callout, decimal separator was removed
resulting in a different number, ie. 10200500.45 resulted in 1020050045.00.

The problem was in the OB.Utilities.Number.ScientificToDecimal JavaScript function
which wrongly assumed scientific exponent always added zeroes to coefficient, which
is not true in this case where exponent determines where the decimal separator is
inserted in the coefficient.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js	Mon Jan 19 12:35:25 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js	Thu Jan 22 11:14:24 2015 +0100
@@ -453,12 +453,17 @@
       numberOfZeros = numberOfZeros - split[1].length;
     }
 
-    //Create the string of zeros
-    for (i = 0; i < numberOfZeros; i++) {
-      zeros = zeros + '0';
+    if (numberOfZeros >= 0) {
+      //Need to concatenate zeros to the coefficient
+      for (i = 0; i < numberOfZeros; i++) {
+        zeros = zeros + '0';
+      }
+      //Create the final number
+      number = coeficient + zeros;
+    } else {
+      // final decimal number is not integer: add dot decimal separator in the correct position
+      number = coeficient.substr(0, coeficient.length + numberOfZeros) + '.' + coeficient.substr(coeficient.length + numberOfZeros);
     }
-    //Create the final number
-    number = coeficient + zeros;
   }
 
   return number;