investira.sdk 2.2.14 → 2.3.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/CHANGELOG.md +9 -0
- package/lib/hofs/tasks.js +0 -3
- package/lib/tests/test_dates.js +3 -3
- package/lib/tests/test_formats.js +6 -8
- package/lib/tests/test_numbers.js +2 -2
- package/lib/utils/dates.js +3 -1
- package/lib/utils/formats.js +2 -2
- package/lib/utils/numbers.js +3 -10
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -445,3 +445,12 @@ O contrutor para a criação das mensagem foi alterado.
|
|
|
445
445
|
# 2.2.14
|
|
446
446
|
|
|
447
447
|
- [investira.data] Controle de vigência do feriado
|
|
448
|
+
|
|
449
|
+
# 2.2.15
|
|
450
|
+
|
|
451
|
+
- [numbers] Aumento da precisão do trunc e do round
|
|
452
|
+
- [formats] Substituicão do trimRight por trimEnd no friendlyNumber
|
|
453
|
+
|
|
454
|
+
# 2.3.0
|
|
455
|
+
|
|
456
|
+
- [nodejs] 18.12
|
package/lib/hofs/tasks.js
CHANGED
package/lib/tests/test_dates.js
CHANGED
|
@@ -134,13 +134,13 @@ test('\ndates workingDaysBetween', t => {
|
|
|
134
134
|
t.equal(dates.workingDaysBetween(xData1, xData2), 1);
|
|
135
135
|
xData1 = dates.toDate('1995-12-31');
|
|
136
136
|
xData2 = dates.toDate('2018-12-31');
|
|
137
|
-
t.equal(dates.workingDaysBetween(xData1, xData2),
|
|
137
|
+
t.equal(dates.workingDaysBetween(xData1, xData2), 5774);
|
|
138
138
|
xData1 = dates.toDate('1995-01-01');
|
|
139
139
|
xData2 = dates.toDate('2018-12-31');
|
|
140
|
-
t.equal(dates.workingDaysBetween(xData1, xData2),
|
|
140
|
+
t.equal(dates.workingDaysBetween(xData1, xData2), 6022);
|
|
141
141
|
xData1 = dates.toDate('1995-01-03');
|
|
142
142
|
xData2 = dates.toDate('2070-01-03');
|
|
143
|
-
t.equal(dates.workingDaysBetween(xData1, xData2),
|
|
143
|
+
t.equal(dates.workingDaysBetween(xData1, xData2), 18835);
|
|
144
144
|
xData1 = dates.toDate('2019-08-05');
|
|
145
145
|
xData2 = dates.toDate('2019-08-04');
|
|
146
146
|
t.equal(dates.workingDaysBetween(xData1, xData2), 0);
|
|
@@ -14,9 +14,7 @@ test('\nformats.formatPhone', t => {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
test('\nformats.friendlyNumber', t => {
|
|
17
|
-
t.equal(formats.friendlyNumber(123, 0, true),
|
|
18
|
-
t.equal(formats.friendlyNumber(123, 0, false), '123');
|
|
19
|
-
t.equal(formats.friendlyNumber(123, 0, true), 'R$ 123');
|
|
17
|
+
t.equal(formats.friendlyNumber(123, 0, true), `R$${String.fromCharCode(160)}123`);
|
|
20
18
|
t.equal(formats.friendlyNumber(123, 0, false), '123');
|
|
21
19
|
t.equal(formats.friendlyNumber(1234567, 0, false), '1 mi');
|
|
22
20
|
t.equal(formats.friendlyNumber(1234567, 1, false), '1,2 mi');
|
|
@@ -26,14 +24,14 @@ test('\nformats.friendlyNumber', t => {
|
|
|
26
24
|
t.equal(formats.friendlyNumber(1234000, 1, false), '1,2 mi');
|
|
27
25
|
t.equal(formats.friendlyNumber(1234000, 2, false), '1,23 mi');
|
|
28
26
|
t.equal(formats.friendlyNumber(1234000, 3, false), '1,234 mi');
|
|
29
|
-
t.equal(formats.friendlyNumber(1234000, 0, true),
|
|
30
|
-
t.equal(formats.friendlyNumber(1234000, 1, true),
|
|
31
|
-
t.equal(formats.friendlyNumber(1234000, 2, true),
|
|
32
|
-
t.equal(formats.friendlyNumber(1234000, 3, true),
|
|
27
|
+
t.equal(formats.friendlyNumber(1234000, 0, true), `R$${String.fromCharCode(160)}1 mi`);
|
|
28
|
+
t.equal(formats.friendlyNumber(1234000, 1, true), `R$${String.fromCharCode(160)}1,2 mi`);
|
|
29
|
+
t.equal(formats.friendlyNumber(1234000, 2, true), `R$${String.fromCharCode(160)}1,23 mi`);
|
|
30
|
+
t.equal(formats.friendlyNumber(1234000, 3, true), `R$${String.fromCharCode(160)}1,234 mi`);
|
|
33
31
|
t.equal(formats.friendlyNumber(-1234000, 3, false), '-1,234 mi');
|
|
34
32
|
t.equal(formats.friendlyNumber(0, 3, false), '0');
|
|
35
33
|
t.equal(formats.friendlyNumber(0.9123123424, 2, false), '0,91');
|
|
36
|
-
t.equal(formats.friendlyNumber(0.9123123424, 2, true),
|
|
34
|
+
t.equal(formats.friendlyNumber(0.9123123424, 2, true), `R$${String.fromCharCode(160)}0,91`);
|
|
37
35
|
t.end();
|
|
38
36
|
});
|
|
39
37
|
|
|
@@ -69,8 +69,8 @@ test('\nnumbers mul', t => {
|
|
|
69
69
|
t.equal(numbers.mul(4.300000000000001, 5), 21.500000000000004);
|
|
70
70
|
t.equal(numbers.mul(4.0001, 5.0002), 20.00130002);
|
|
71
71
|
t.equal(numbers.mul(4.0001, 5.0002), 20.00130002);
|
|
72
|
-
t.equal(numbers.mul(2357.12345679, 1234567), 2910026834.6788597);
|
|
73
|
-
t.equal(numbers.mul(-0.123456789012345678901, -1230.123456789012345678901), 151.
|
|
72
|
+
t.equal(numbers.mul(2357.12345679, 1234567), 2910026834.6788597);
|
|
73
|
+
t.equal(numbers.mul(-0.123456789012345678901, -1230.123456789012345678901), 151.86709206393846); //151.86709206393883 = Se fosse bigDecimal
|
|
74
74
|
t.end();
|
|
75
75
|
});
|
|
76
76
|
|
package/lib/utils/dates.js
CHANGED
package/lib/utils/formats.js
CHANGED
|
@@ -293,7 +293,7 @@ module.exports = formats;
|
|
|
293
293
|
* @param {*} pValue Valor a ser simplificado
|
|
294
294
|
* @param {number} [pDecimals=2] Quantidade máxima de casas decimais
|
|
295
295
|
* @param {boolean} [pShowCurrency=false] Se exibe o símbolo da moeda do país definido em formats.CURRENCY.
|
|
296
|
-
* @returns Valor formatado de forma simplificada
|
|
296
|
+
* @returns {String} Valor formatado de forma simplificada
|
|
297
297
|
*/
|
|
298
298
|
const pvSimplify = (pDIM, pValue, pDecimals = 2, pShowCurrency = false) => {
|
|
299
299
|
const xOptions = {
|
|
@@ -330,5 +330,5 @@ const pvSimplify = (pDIM, pValue, pDecimals = 2, pShowCurrency = false) => {
|
|
|
330
330
|
xValueInt *= xSign;
|
|
331
331
|
//Configura formatação
|
|
332
332
|
|
|
333
|
-
return xValueInt.toLocaleString(formats.LOCALE, xOptions) + xSuf.
|
|
333
|
+
return xValueInt.toLocaleString(formats.LOCALE, xOptions) + xSuf.trimEnd();
|
|
334
334
|
};
|
package/lib/utils/numbers.js
CHANGED
|
@@ -17,7 +17,7 @@ const numbers = {
|
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
const xP = Math.pow(10, pDecimals);
|
|
20
|
-
let xValue = Number(Math.round(pValue
|
|
20
|
+
let xValue = Number(Math.round(numbers.mul(pValue, xP)));
|
|
21
21
|
xValue = Math[xValue < 0 ? 'ceil' : 'floor'](xValue);
|
|
22
22
|
return xValue / xP;
|
|
23
23
|
},
|
|
@@ -34,7 +34,7 @@ const numbers = {
|
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
const xP = Math.pow(10, pDecimals);
|
|
37
|
-
let xValue =
|
|
37
|
+
let xValue = numbers.mul(pValue, xP);
|
|
38
38
|
xValue = Math[xValue < 0 ? 'ceil' : 'floor'](xValue);
|
|
39
39
|
return xValue / xP;
|
|
40
40
|
},
|
|
@@ -313,14 +313,7 @@ const pvCalc = (pValue1, pValue2, pOperation) => {
|
|
|
313
313
|
}
|
|
314
314
|
const xValue1Str = numbers.apart(pValue1);
|
|
315
315
|
const xValue2Str = numbers.apart(pValue2);
|
|
316
|
-
const
|
|
317
|
-
let xMaxDec = Math.max(xValue1Str.dec.length, xValue2Str.dec.length);
|
|
318
|
-
const xOver = xMaxInt + xMaxDec - PRECISION;
|
|
319
|
-
if (xOver > 0 && xMaxDec > xOver) {
|
|
320
|
-
xMaxDec -= xOver;
|
|
321
|
-
xValue1Str.dec = xValue1Str.dec.substring(0, xMaxDec);
|
|
322
|
-
xValue2Str.dec = xValue2Str.dec.substring(0, xMaxDec);
|
|
323
|
-
}
|
|
316
|
+
const xMaxDec = Math.max(xValue1Str.dec.length, xValue2Str.dec.length);
|
|
324
317
|
|
|
325
318
|
//Como se estivesse multiplicando os valores por 10^xMaxDec,
|
|
326
319
|
//mas concatena os zeros para evitar um possível residuo no cálculo
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "investira.sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"author": "Investira",
|
|
5
5
|
"description": "Investira SDK",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"registry": true,
|
|
9
|
-
"raw": "investira.sdk@2.
|
|
9
|
+
"raw": "investira.sdk@2.3.0",
|
|
10
10
|
"escapedName": "investira.sdk",
|
|
11
|
-
"rawSpec": "2.
|
|
11
|
+
"rawSpec": "2.3.0",
|
|
12
12
|
"saveSpec": null,
|
|
13
|
-
"fetchSpec": "2.
|
|
13
|
+
"fetchSpec": "2.3.0",
|
|
14
14
|
"homepage": "https://investira.com.br/",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=11.11.0 <=
|
|
16
|
+
"node": ">=11.11.0 <=18.12",
|
|
17
17
|
"npm": ">=6.0.0"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"start": "node ./lib/tests",
|
|
34
|
+
"debug": "nodemon ./lib/tests",
|
|
34
35
|
"_test": "nodemon ./_tests/test"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"moment": "^2.29.4"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"tape": "^4.
|
|
45
|
+
"tape": "^4.16.1"
|
|
45
46
|
},
|
|
46
47
|
"jshintConfig": {
|
|
47
48
|
"curly": true,
|