Update Utilities.js
This commit is contained in:
1 parent
7a9c4b818c
commit
3152f26760
1 file changed
+12
-7
+12
-7
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user