@wrcb/cb-common 1.0.549 → 1.0.552
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CurrencyService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const country_1 = require("../types/country");
|
|
5
5
|
class CurrencyService {
|
|
6
6
|
static getCurrencyFromCountry(country) {
|
|
7
7
|
var _a;
|
|
8
8
|
if (!country)
|
|
9
|
-
return
|
|
10
|
-
return ((_a =
|
|
9
|
+
return country_1.Currency.BRL;
|
|
10
|
+
return ((_a = country_1.countryInfoMap[country]) === null || _a === void 0 ? void 0 : _a.currency) || country_1.Currency.BRL;
|
|
11
11
|
}
|
|
12
12
|
static getCurrencyConfig(country) {
|
|
13
13
|
const currency = this.getCurrencyFromCountry(country);
|
|
@@ -18,7 +18,7 @@ class CurrencyService {
|
|
|
18
18
|
const valueInUnits = valueInCents / 100;
|
|
19
19
|
return valueInUnits.toLocaleString(config.locale, {
|
|
20
20
|
style: 'currency',
|
|
21
|
-
currency: config.currency
|
|
21
|
+
currency: config.currency
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
static parseFromCurrency(formattedValue, country) {
|
|
@@ -31,7 +31,7 @@ class CurrencyService {
|
|
|
31
31
|
static formatToInput(valueInCents, country) {
|
|
32
32
|
const config = this.getCurrencyConfig(country);
|
|
33
33
|
const valueInUnits = valueInCents / 100;
|
|
34
|
-
if (config.currency ===
|
|
34
|
+
if (config.currency === country_1.Currency.BRL) {
|
|
35
35
|
return valueInUnits.toFixed(2).replace('.', ',');
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -56,14 +56,14 @@ class CurrencyService {
|
|
|
56
56
|
}
|
|
57
57
|
exports.CurrencyService = CurrencyService;
|
|
58
58
|
CurrencyService.CURRENCY_CONFIG = {
|
|
59
|
-
[
|
|
59
|
+
[country_1.Currency.BRL]: {
|
|
60
60
|
locale: 'pt-BR',
|
|
61
61
|
currency: 'BRL',
|
|
62
|
-
symbol: 'R$'
|
|
62
|
+
symbol: 'R$'
|
|
63
63
|
},
|
|
64
|
-
[
|
|
64
|
+
[country_1.Currency.ARS]: {
|
|
65
65
|
locale: 'es-AR',
|
|
66
66
|
currency: 'ARS',
|
|
67
|
-
symbol: '$'
|
|
68
|
-
}
|
|
67
|
+
symbol: '$'
|
|
68
|
+
}
|
|
69
69
|
};
|