diff --git a/Utilities.js b/Utilities.js index 65fc7ae64..4c16cb55e 100644 --- a/Utilities.js +++ b/Utilities.js @@ -5,7 +5,7 @@ function getNodeDefinition(node) { } else { console.log('[Error] Could not get APP Scchema for project ' + node.project) } - + } function dynamicDecimals(value, minDecimals) { @@ -14,13 +14,18 @@ function dynamicDecimals(value, minDecimals) { } let decimals = 0 if (value < 1) { decimals = 2 } - if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 4 } - if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 6 } - if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 8 } - if (Math.abs(Math.trunc(value * 100000000)) < 1) { decimals = 10 } - if (Math.abs(Math.trunc(value * 10000000000)) < 1) { value = 0; decimals = 0 } - if (decimals < minDecimals) {decimals = minDecimals} + + if (Math.abs(Math.trunc(value * 10)) < 1) { decimals = 4 } + if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 5 } + if (Math.abs(Math.trunc(value * 1000)) < 1) { decimals = 6 } + if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 7 } + if (Math.abs(Math.trunc(value * 100000)) < 1) { decimals = 8 } + if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 9 } + if (Math.abs(Math.trunc(value * 10000000)) < 1) { decimals = 10 } + if (Math.abs(Math.trunc(value * 100000000000)) < 1) { value = 0; decimals = 0 } + if (decimals < minDecimals) {decimals = minDecimals} + let returnValue = Number(value).toFixed(decimals) return returnValue }