could help me with the following situation:
I have a Numeric field (21,2) and need to format it for a specific layout, as below.
Input's example:
VALUE1: 3500.31 - > After Formatting: +00000000000003500.31
VALUE2: -3000 - > After Formatting: -00000000000003000.00
VALUE3: 2000.00 - > After Formatting: +00000000000002000.00
I am using the function below to fill the 0 left and validation of the signal, however I have a problem, for cases where the input is an integer, this way the field is in the format # .00:
Output: +00000000000000003000
Function:
function leadingZero(value, totalWidth, paddingChar) {
var length = totalWidth - value.toString().length + 1;
return Array(length).join(paddingChar || '0') + value;
};
if (total_amount >=0){
var total_amount = '+' + leadingZero(total_amount,20);
} else {
var total_amount = '-' + leadingZero(replace(total_amount,'-',''),20);
}
Thank you!