From 3152f26760422477c9a8a11b7fa58ad99b4bb25b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 4 Nov 2020 18:05:47 +0100 Subject: [PATCH] Update Utilities.js --- Utilities.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 }