diff --git a/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml
index 89accd6338..109f703fb7 100644
--- a/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml
+++ b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml
@@ -48,7 +48,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
-
+
diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java
index 3690fe3b98..8d45ef799a 100644
--- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java
+++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java
@@ -137,6 +137,8 @@ public class NumberBox extends Div
@Override
public void onEvent(Event event) throws Exception {
if (btn.getPopup() != null) {
+ // Fill the calculator with the actual value of the field
+ // TODO: this could be made a user preference
String curValue = "";
if (decimalBox.getValue() != null) {
curValue = decimalBox.getValue().toString();
@@ -146,6 +148,9 @@ public class NumberBox extends Div
String separator = Character.toString(separatorChar);
curValue = curValue.replace(".", separator);
}
+ if ("0".equals(curValue)) {
+ curValue = "";
+ }
}
String txtCalcId = txtCalc.getId();
Clients.evalJavaScript("calc.append('" + txtCalcId + "', '" + curValue + "')");
diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/calc.js b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/calc.js
index 072b66942a..d9f48ce218 100644
--- a/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/calc.js
+++ b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/calc.js
@@ -73,10 +73,14 @@ function Calc()
var re = new RegExp("[" + separator + "]", "g");
value = value.replace(re,'.');
}
- var reclean = new RegExp("[^1234567890+-/*%() ]", "g"); // sanitize
- value = value.replace(reclean,'');
- var reperc = new RegExp("[%]", "g"); // percentage
- value = value.replace(reperc,'/100 ');
+ value = value
+ .replace(/[^1234567890+-/*%() ]/g, '') // sanitize
+ .replace(/[%]/g, '/100 ') // percentage
+ // now replace leading zeroes
+ .replace(/\b0+\b/g, 'z') // replace bare zeros with sentinel
+ .replace(/[1-9\.]0+/g, m => m.replace(/0/g, 'z')) // save these too
+ .replace(/0/g, '') // throw away the rest of the zeros
+ .replace(/z/g, '0'); // turn sentinels back to zeros
newValue = value;
var result = "" + eval(value);
if (separator != '.')