@royalinvest/dto 0.69.18 → 0.69.20
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/dist/property.d.ts +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +9 -0
- package/package.json +1 -1
package/dist/property.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function fromMinorUnits(amountMinor: string, currency: CurrencyEn
|
|
|
4
4
|
export declare function fromMinorUnitsExact(amountMinor: string, currency: CurrencyEnum): string;
|
|
5
5
|
export declare function parseMajorToMinor(value: string, currency: CurrencyEnum): string;
|
|
6
6
|
export declare function resolveLocale(uiLanguage: LocaleType, country?: CountryEnum | null): string;
|
|
7
|
+
export declare function formatMoney(amountMinor: string, currency: CurrencyEnum, locale: string): string;
|
package/dist/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.fromMinorUnits = fromMinorUnits;
|
|
|
4
4
|
exports.fromMinorUnitsExact = fromMinorUnitsExact;
|
|
5
5
|
exports.parseMajorToMinor = parseMajorToMinor;
|
|
6
6
|
exports.resolveLocale = resolveLocale;
|
|
7
|
+
exports.formatMoney = formatMoney;
|
|
7
8
|
const config_1 = require("./config");
|
|
8
9
|
// This is going to be used for web app to show amount in minor taking into account units configured for the currency
|
|
9
10
|
function fromMinorUnits(amountMinor, currency) {
|
|
@@ -51,3 +52,11 @@ function resolveLocale(uiLanguage, country) {
|
|
|
51
52
|
// Fallback: language-only default
|
|
52
53
|
return config_1.DEFAULT_LOCALE_BY_LANGUAGE[uiLanguage] ?? "en-US";
|
|
53
54
|
}
|
|
55
|
+
function formatMoney(amountMinor, currency, locale) {
|
|
56
|
+
const amountMajor = fromMinorUnits(amountMinor, currency);
|
|
57
|
+
return new Intl.NumberFormat(locale, {
|
|
58
|
+
style: "currency",
|
|
59
|
+
currency,
|
|
60
|
+
currencyDisplay: "symbol",
|
|
61
|
+
}).format(amountMajor);
|
|
62
|
+
}
|
package/package.json
CHANGED