@tagplus/components 4.5.0 → 4.7.0

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.5.0",
11
+ "version": "4.7.0",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -48,7 +48,7 @@ function formatMoney (input, toString = false, locale = defaults, customPrecisio
48
48
  const negative = inputString.indexOf('-') >= 0 ? -1 : 1
49
49
 
50
50
  if (toString) {
51
- input = completeZeros(inputString, locale)
51
+ input = completeZeros(customPrecision, inputString, locale)
52
52
  }
53
53
 
54
54
  const precision = customPrecision || locale.number.precision
@@ -71,8 +71,8 @@ function formatMoney (input, toString = false, locale = defaults, customPrecisio
71
71
  return currency * negative
72
72
  }
73
73
 
74
- function completeZeros (input, locale) {
75
- const precision = locale?.number?.precision || defaults.precision
74
+ function completeZeros (customPrecision, input, locale) {
75
+ const precision = customPrecision || locale?.number?.precision || defaults.precision
76
76
  const decimal = locale?.number?.decimal || defaults.decimal
77
77
  let i = input.lastIndexOf('.')
78
78
  const j = input.lastIndexOf(',')
@@ -90,12 +90,7 @@ function completeZeros (input, locale) {
90
90
  return input
91
91
  }
92
92
 
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
- }
93
+ function onlyNumbers (input) {
99
94
  return toStr(input).replace(/\D+/g, '') || '0'
100
95
  }
101
96
 
@@ -111,7 +106,6 @@ function between (min, n, max) {
111
106
  function numbersToCurrency (numbers, precision) {
112
107
  const exp = Math.pow(10, precision)
113
108
  const float = parseFloat(numbers) / exp
114
- console.log('numbersToCurrency -> ', float.toFixed(fixed(precision)))
115
109
  return float.toFixed(fixed(precision))
116
110
  }
117
111