@lyxa.ai/core 1.4.110 → 1.4.111
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/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const getExchangeRate: () => Promise<number>;
|
|
2
2
|
export declare const convertToBase: (amount: number) => Promise<number>;
|
|
3
3
|
export declare const convertToSecondary: (amount: number) => Promise<number>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const convertToSecondaryWithExchangeRate: (amount: number, exchangeRate: number) => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.convertToSecondaryWithExchangeRate = exports.convertToSecondary = exports.convertToBase = exports.getExchangeRate = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const shared_1 = require("./shared");
|
|
6
6
|
const DEFAULT_EXCHANGE_RATE = 0;
|
|
@@ -26,11 +26,11 @@ const convertToSecondary = async (amount) => {
|
|
|
26
26
|
return (0, shared_1.roundSecondaryCurrency)(amount * exchangeRate);
|
|
27
27
|
};
|
|
28
28
|
exports.convertToSecondary = convertToSecondary;
|
|
29
|
-
const
|
|
29
|
+
const convertToSecondaryWithExchangeRate = (amount, exchangeRate) => {
|
|
30
30
|
if (typeof amount !== 'number' || isNaN(amount)) {
|
|
31
31
|
return 0;
|
|
32
32
|
}
|
|
33
33
|
return (0, shared_1.roundSecondaryCurrency)(amount * exchangeRate);
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
35
|
+
exports.convertToSecondaryWithExchangeRate = convertToSecondaryWithExchangeRate;
|
|
36
36
|
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAAA,0BAAkC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{ Setting } from '../libraries/mongo/models';\nimport { roundBaseCurrency, roundSecondaryCurrency } from './shared';\n\nconst DEFAULT_EXCHANGE_RATE = 0;\n\nexport const getExchangeRate = async (): Promise<number> => {\n\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = settings.currencySetting;\n\treturn currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;\n};\n\nexport const convertToBase = async (amount: number): Promise<number> => {\n\tif (typeof amount !== 'number' || isNaN(amount)) {\n\t\treturn 0;\n\t}\n\n\tconst exchangeRate = await getExchangeRate();\n\treturn roundBaseCurrency(amount / exchangeRate);\n};\n\nexport const convertToSecondary = async (amount: number): Promise<number> => {\n\tif (typeof amount !== 'number' || isNaN(amount)) {\n\t\treturn 0;\n\t}\n\n\tconst exchangeRate = await getExchangeRate();\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n\nexport const convertToSecondaryWithExchangeRate = (amount: number, exchangeRate: number): number => {\n\tif (typeof amount !== 'number' || isNaN(amount)) {\n\t\treturn 0;\n\t}\n\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};"]}
|