Fixed issue 29709: Physical inventory cannot be created.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Mon, 25 May 2015 16:18:51 +0200
changeset 26764 fdb573cffe5f
parent 26763 ac68a43ce656
child 26766 9c435312991b
Fixed issue 29709: Physical inventory cannot be created.

The problem was that if it was a very small negative Book Quantity number, it was not
possible to create a Physical Inventory line.

It was because the "ScientificToDecimal" function was not working properly with negative
numbers. The '-' sign was taken as a number instead of as a sign, that was the reason of
obtaining a value like 0.000-3655 when -0.0003655 was expected.

To fix this, a condition has been added which takes into account the fact of having
the '-' sign and to deal with the sign as a sign and not as a number.
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 May 25 12:31:46 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js	Mon May 25 16:18:51 2015 +0200
@@ -424,7 +424,7 @@
 
   number = number.toString();
   var coeficient, exponent, numberOfZeros, zeros = '',
-      i, split, index;
+      i, split, index, sign;
 
   // Look for 'e' or 'E' 
   if (number.indexOf('e') !== -1) {
@@ -453,7 +453,13 @@
       zeros = zeros + '0';
     }
     //Create the final number
-    number = '0.' + zeros + coeficient;
+    if (coeficient.substring(0, 1) === '-') {
+      sign = '-';
+      coeficient = coeficient.substring(1, coeficient.length);
+      number = sign + '0.' + zeros + coeficient;
+    } else {
+      number = '0.' + zeros + coeficient;
+    }
   } else { // Case the number is bigger than 1
     numberOfZeros = exponent.indexOf('+') !== -1 ? exponent.substring(1, exponent.length) : exponent;
     if (split) {