@tagplus/components 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "4.4.0",
11
+ "version": "4.4.1",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -90,7 +90,12 @@ function completeZeros (input, locale) {
90
90
  return input
91
91
  }
92
92
 
93
- function onlyNumbers (input) {
93
+ function onlyNumbers (input, precision = defaults.precision) {
94
+ const numbersAfterComma = input.split(',')[1]?.length || 0
95
+ // if the numbers after the comma are less than the precision, add zeros
96
+ if (numbersAfterComma < precision) {
97
+ input += '0'.repeat(precision - numbersAfterComma)
98
+ }
94
99
  return toStr(input).replace(/\D+/g, '') || '0'
95
100
  }
96
101
 
@@ -106,7 +111,7 @@ function between (min, n, max) {
106
111
  function numbersToCurrency (numbers, precision) {
107
112
  const exp = Math.pow(10, precision)
108
113
  const float = parseFloat(numbers) / exp
109
-
114
+ console.log('numbersToCurrency -> ', float.toFixed(fixed(precision)))
110
115
  return float.toFixed(fixed(precision))
111
116
  }
112
117