Fixes issue 23975: Number handling works using ',' as decimal separator
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 04 Jun 2013 10:20:19 +0200
changeset 20508 52742b2346be
parent 20507 31f9b82dde77
child 20509 51f380c29321
Fixes issue 23975: Number handling works using ',' as decimal separator

In the fix of the issue 23758 [1] it was wrongly assumed that the function getValue() of a OBNumberItem was going to return a javascript number. When the an existing record has just been opened getValue() will return a number, but when the user edits it, it will return the string representation of the number using the format specified by the user.

Now this has been taken into account, so the value is treated differently if getValue returns a string or a javascript number.

[1] https://code.openbravo.com/erp/devel/pi/rev/2e4eccaa3cc8fc8ac434cb0d386166558d1ee686
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Sat Jun 01 01:56:07 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Tue Jun 04 10:20:19 2013 +0200
@@ -432,8 +432,13 @@
     var value, roundedValue, textRoundedValue;
 
     // Make sure the number is rounded using the number of decimal digits specified in the number typeInstance
-    value = OB.Utilities.Number.OBPlainToOBMasked(this.getValue(), this.typeInstance.maskNumeric, this.typeInstance.decSeparator, this.typeInstance.groupSeparator);
-    this.setValue(OB.Utilities.Number.OBMaskedToJS(value));
+    if (isc.isA.String(this.getValue())) {
+        value = OB.Utilities.Number.OBPlainToOBMasked(this.getValue(), this.typeInstance.maskNumeric, this.typeInstance.decSeparator, this.typeInstance.groupSeparator);
+        this.setValue(OB.Utilities.Number.OBMaskedToJS(value, this.typeInstance.decSeparator, this.typeInstance.groupSeparator));
+    } else {
+        value = OB.Utilities.Number.OBPlainToOBMasked(this.getValue(), this.typeInstance.maskNumeric);
+        this.setValue(OB.Utilities.Number.OBMaskedToJS(value));
+    }
 
     if (this.grid && this.grid.isEditing && this.grid.isEditing()) {
       this.grid.setEditValue(this.grid.getEditRow(), this.name, this.getValue(), true, true);