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 25696 9f0f61605bc5
parent 25695 1d34a4e4bb53
child 25697 b7df49952bd8
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	Fri Jan 16 12:56:53 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
@@ -456,12 +456,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;