@ubnt/store.core 9.11.0-alpha.0 → 9.11.1
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 +7 -48
- package/lib/assets/attention.svg +5 -5
- package/lib/assets/attention2.svg +5 -5
- package/lib/assets/close2.svg +2 -3
- package/lib/assets/close3.svg +3 -2
- package/lib/assets/minus4.svg +8 -8
- package/lib/assets/minus5.svg +8 -8
- package/lib/assets/pause.svg +3 -3
- package/lib/assets/pause2.svg +3 -3
- package/lib/assets/udmPro.jpg +0 -0
- package/lib/assets/udmPro2.jpg +0 -0
- package/lib/assets/udmProMax.jpg +0 -0
- package/lib/assets/udmProMax2.jpg +0 -0
- package/lib/assets/udmProSpecial.jpg +0 -0
- package/lib/assets/udmProSpecial2.jpg +0 -0
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.js +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.mjs +2 -2
- package/lib/components/Header/ProHeader/ProHeader.js +2 -19
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +2 -19
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +0 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.js +0 -6
- package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs +0 -6
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
- package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
- package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
- package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
- package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
- package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
- package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
- package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/data/CloudGateways.js +9 -9
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +6 -6
- package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +1 -6
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +1 -6
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
- package/lib/components/VideoPlayerNew/VideoPlayer.js +2 -2
- package/lib/components/VideoPlayerNew/VideoPlayer.mjs +2 -2
- package/lib/components/VideoPlayerNew/assets/close.svg.js +1 -1
- package/lib/components/VideoPlayerNew/assets/close.svg.mjs +2 -2
- package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
- package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
- package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -1
- package/lib/constants/proStoreCategories/mapping/index.js +8 -13
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +8 -13
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -2
- package/lib/constants/proStoreCategories/mapping/unifi.js +0 -1
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +0 -3
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -3
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +1 -1
- package/lib/contexts/MenuContext/mapping.js +7 -1
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +7 -1
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/utils/money/constants.d.ts +25 -56
- package/lib/utils/money/constants.js +7 -72
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +7 -70
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/format.d.ts +5 -10
- package/lib/utils/money/format.js +14 -22
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +16 -23
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/index.d.ts +1 -4
- package/lib/utils/money/index.js +8 -26
- package/lib/utils/money/index.js.map +1 -1
- package/lib/utils/money/index.mjs +4 -8
- package/lib/utils/money/index.mjs.map +1 -1
- package/lib/utils/money/misc.d.ts +28 -68
- package/lib/utils/money/misc.js +64 -35
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs +43 -32
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/money/tax.d.ts +2 -38
- package/lib/utils/money/tax.js +10 -46
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +11 -42
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/types.d.ts +3 -78
- package/lib/utils/number.d.ts +1 -1
- package/lib/utils/number.js +1 -1
- package/lib/utils/number.js.map +1 -1
- package/lib/utils/number.mjs +1 -1
- package/lib/utils/number.mjs.map +1 -1
- package/lib/utils/validations.d.ts +15 -0
- package/lib/utils/validations.js +23 -0
- package/lib/utils/validations.js.map +1 -0
- package/lib/utils/validations.mjs +21 -0
- package/lib/utils/validations.mjs.map +1 -0
- package/package.json +2 -2
- package/lib/components/Tooltip/Tooltip.d.ts +0 -2
- package/lib/components/Tooltip/Tooltip.js +0 -45
- package/lib/components/Tooltip/Tooltip.js.map +0 -1
- package/lib/components/Tooltip/Tooltip.mjs +0 -43
- package/lib/components/Tooltip/Tooltip.mjs.map +0 -1
- package/lib/components/Tooltip/Tooltip.styles.d.ts +0 -32
- package/lib/components/Tooltip/Tooltip.styles.js +0 -44
- package/lib/components/Tooltip/Tooltip.styles.js.map +0 -1
- package/lib/components/Tooltip/Tooltip.styles.mjs +0 -34
- package/lib/components/Tooltip/Tooltip.styles.mjs.map +0 -1
- package/lib/components/Tooltip/index.d.ts +0 -1
- package/lib/components/Tooltip/index.js +0 -6
- package/lib/components/Tooltip/index.js.map +0 -1
- package/lib/components/Tooltip/index.mjs +0 -3
- package/lib/components/Tooltip/index.mjs.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
- package/lib/utils/money/allocators/fixedAmount.js +0 -55
- package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.mjs +0 -53
- package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
- package/lib/utils/money/allocators/index.d.ts +0 -2
- package/lib/utils/money/allocators/index.js +0 -8
- package/lib/utils/money/allocators/index.js.map +0 -1
- package/lib/utils/money/allocators/index.mjs +0 -4
- package/lib/utils/money/allocators/index.mjs.map +0 -1
- package/lib/utils/money/allocators/productAmount.d.ts +0 -13
- package/lib/utils/money/allocators/productAmount.js +0 -110
- package/lib/utils/money/allocators/productAmount.js.map +0 -1
- package/lib/utils/money/allocators/productAmount.mjs +0 -108
- package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
- package/lib/utils/money/exchangeRate.d.ts +0 -31
- package/lib/utils/money/exchangeRate.js +0 -27
- package/lib/utils/money/exchangeRate.js.map +0 -1
- package/lib/utils/money/exchangeRate.mjs +0 -23
- package/lib/utils/money/exchangeRate.mjs.map +0 -1
- package/lib/utils/money/misc.private.d.ts +0 -23
- package/lib/utils/money/misc.private.js +0 -46
- package/lib/utils/money/misc.private.js.map +0 -1
- package/lib/utils/money/misc.private.mjs +0 -21
- package/lib/utils/money/misc.private.mjs.map +0 -1
- package/lib/utils/money/shipping.d.ts +0 -5
- package/lib/utils/money/shipping.js +0 -8
- package/lib/utils/money/shipping.js.map +0 -1
- package/lib/utils/money/shipping.mjs +0 -6
- package/lib/utils/money/shipping.mjs.map +0 -1
- package/lib/utils/money/tax.private.d.ts +0 -17
- package/lib/utils/money/tax.private.js +0 -65
- package/lib/utils/money/tax.private.js.map +0 -1
- package/lib/utils/money/tax.private.mjs +0 -60
- package/lib/utils/money/tax.private.mjs.map +0 -1
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var misc = require('../misc.js');
|
|
4
|
-
var fixedAmount = require('./fixedAmount.js');
|
|
5
|
-
"use strict";
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value
|
|
12
|
-
}) : obj[key] = value;
|
|
13
|
-
var __publicField = (obj, key, value) => {
|
|
14
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
-
return value;
|
|
16
|
-
};
|
|
17
|
-
var __accessCheck = (obj, member, msg) => {
|
|
18
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
19
|
-
};
|
|
20
|
-
var __privateGet = (obj, member, getter) => {
|
|
21
|
-
__accessCheck(obj, member, "read from private field");
|
|
22
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
23
|
-
};
|
|
24
|
-
var __privateAdd = (obj, member, value) => {
|
|
25
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
26
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
27
|
-
};
|
|
28
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
29
|
-
__accessCheck(obj, member, "write to private field");
|
|
30
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
var _itemPrice, _currency, _subtotal, _discountAmount, _taxableAmount, _tax, _total;
|
|
34
|
-
class ProductAmountAllocator {
|
|
35
|
-
constructor(productSummary) {
|
|
36
|
-
// #############################################################################
|
|
37
|
-
// Fixed values
|
|
38
|
-
// #############################################################################
|
|
39
|
-
__privateAdd(this, _itemPrice, void 0);
|
|
40
|
-
__privateAdd(this, _currency, void 0);
|
|
41
|
-
// #############################################################################
|
|
42
|
-
/**
|
|
43
|
-
* Remaining quantity to allocate
|
|
44
|
-
*/
|
|
45
|
-
__publicField(this, "quantity");
|
|
46
|
-
// #############################################################################
|
|
47
|
-
// Specific amount allocators
|
|
48
|
-
// #############################################################################
|
|
49
|
-
__privateAdd(this, _subtotal, void 0);
|
|
50
|
-
__privateAdd(this, _discountAmount, void 0);
|
|
51
|
-
__privateAdd(this, _taxableAmount, void 0);
|
|
52
|
-
__privateAdd(this, _tax, void 0);
|
|
53
|
-
__privateAdd(this, _total, void 0);
|
|
54
|
-
const currency = productSummary.currency;
|
|
55
|
-
const priceForAllocation = productSummary.itemPrice * productSummary.quantity;
|
|
56
|
-
__privateSet(this, _itemPrice, productSummary.itemPrice);
|
|
57
|
-
__privateSet(this, _currency, currency);
|
|
58
|
-
this.quantity = productSummary.quantity;
|
|
59
|
-
__privateSet(this, _subtotal, new fixedAmount.FixedAmountAllocator({
|
|
60
|
-
initialAllocateAmount: productSummary.subtotal,
|
|
61
|
-
initialTotalAmount: priceForAllocation,
|
|
62
|
-
currency
|
|
63
|
-
}));
|
|
64
|
-
__privateSet(this, _discountAmount, new fixedAmount.FixedAmountAllocator({
|
|
65
|
-
initialAllocateAmount: productSummary.discountAmount,
|
|
66
|
-
initialTotalAmount: priceForAllocation,
|
|
67
|
-
currency
|
|
68
|
-
}));
|
|
69
|
-
__privateSet(this, _taxableAmount, new fixedAmount.FixedAmountAllocator({
|
|
70
|
-
initialAllocateAmount: productSummary.taxableAmount,
|
|
71
|
-
initialTotalAmount: priceForAllocation,
|
|
72
|
-
currency
|
|
73
|
-
}));
|
|
74
|
-
__privateSet(this, _tax, new fixedAmount.FixedAmountAllocator({
|
|
75
|
-
initialAllocateAmount: productSummary.tax,
|
|
76
|
-
initialTotalAmount: priceForAllocation,
|
|
77
|
-
currency
|
|
78
|
-
}));
|
|
79
|
-
__privateSet(this, _total, new fixedAmount.FixedAmountAllocator({
|
|
80
|
-
initialAllocateAmount: productSummary.total,
|
|
81
|
-
initialTotalAmount: priceForAllocation,
|
|
82
|
-
currency
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
allocateQty(quantity) {
|
|
86
|
-
let quantityNormalized = Math.max(quantity, 0);
|
|
87
|
-
quantityNormalized = this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;
|
|
88
|
-
this.quantity = Math.max(this.quantity - quantityNormalized, 0);
|
|
89
|
-
const itemQuantityPrice = __privateGet(this, _itemPrice) * quantityNormalized;
|
|
90
|
-
return {
|
|
91
|
-
itemPrice: __privateGet(this, _itemPrice),
|
|
92
|
-
currency: __privateGet(this, _currency),
|
|
93
|
-
quantity: quantityNormalized,
|
|
94
|
-
subtotal: misc.amount(__privateGet(this, _subtotal).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
95
|
-
discountAmount: misc.amount(__privateGet(this, _discountAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
96
|
-
taxableAmount: misc.amount(__privateGet(this, _taxableAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
97
|
-
tax: misc.amount(__privateGet(this, _tax).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
98
|
-
total: misc.amount(__privateGet(this, _total).allocate(itemQuantityPrice, __privateGet(this, _currency)))
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
_itemPrice = new WeakMap();
|
|
103
|
-
_currency = new WeakMap();
|
|
104
|
-
_subtotal = new WeakMap();
|
|
105
|
-
_discountAmount = new WeakMap();
|
|
106
|
-
_taxableAmount = new WeakMap();
|
|
107
|
-
_tax = new WeakMap();
|
|
108
|
-
_total = new WeakMap();
|
|
109
|
-
exports.ProductAmountAllocator = ProductAmountAllocator;
|
|
110
|
-
//# sourceMappingURL=productAmount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"productAmount.js","sources":["../../../../src/utils/money/allocators/productAmount.ts"],"sourcesContent":["import type { Currency } from \"../../../types\";\nimport { amount } from \"../misc\";\nimport type { Cents, FullLineItemSummary } from \"../types\";\nimport { FixedAmountAllocator } from \"./fixedAmount\";\n\n/**\n * Helper class to distribute a total amount for a product\n */\nexport class ProductAmountAllocator {\n // #############################################################################\n // Fixed values\n // #############################################################################\n readonly #itemPrice: Cents;\n readonly #currency: Currency;\n // #############################################################################\n /**\n * Remaining quantity to allocate\n */\n quantity: number;\n // #############################################################################\n // Specific amount allocators\n // #############################################################################\n #subtotal: FixedAmountAllocator;\n #discountAmount: FixedAmountAllocator;\n #taxableAmount: FixedAmountAllocator;\n #tax: FixedAmountAllocator;\n #total: FixedAmountAllocator;\n\n constructor(productSummary: FullLineItemSummary) {\n const currency = productSummary.currency;\n\n /**\n * Somewhat hackish, just need a stable price that can easily divide later by quantity\n */\n const priceForAllocation =\n productSummary.itemPrice * productSummary.quantity;\n\n this.#itemPrice = productSummary.itemPrice;\n this.#currency = currency;\n this.quantity = productSummary.quantity;\n this.#subtotal = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.subtotal,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#discountAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.discountAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#taxableAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.taxableAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#tax = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.tax,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#total = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.total,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n }\n\n allocateQty(quantity: number): FullLineItemSummary {\n // Calculate remaining allocatable quantity\n let quantityNormalized = Math.max(quantity, 0);\n quantityNormalized =\n this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;\n\n // Adjust remaining qty\n this.quantity = Math.max(this.quantity - quantityNormalized, 0);\n\n // How big of a slice of the total price we need to allocate\n const itemQuantityPrice = this.#itemPrice * quantityNormalized;\n\n return {\n itemPrice: this.#itemPrice,\n currency: this.#currency,\n quantity: quantityNormalized,\n subtotal: amount(\n this.#subtotal.allocate(itemQuantityPrice, this.#currency),\n ),\n discountAmount: amount(\n this.#discountAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n taxableAmount: amount(\n this.#taxableAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n tax: amount(this.#tax.allocate(itemQuantityPrice, this.#currency)),\n total: amount(this.#total.allocate(itemQuantityPrice, this.#currency)),\n } satisfies FullLineItemSummary;\n }\n}\n"],"names":["_itemPrice","_currency","_subtotal","_discountAmount","_taxableAmount","_tax","_total","ProductAmountAllocator","constructor","productSummary","__privateAdd","__publicField","currency","priceForAllocation","itemPrice","quantity","__privateSet","FixedAmountAllocator","initialAllocateAmount","subtotal","initialTotalAmount","discountAmount","taxableAmount","tax","total","allocateQty","quantityNormalized","Math","max","itemQuantityPrice","__privateGet","amount","allocate","WeakMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,eAAA,EAAAC,cAAA,EAAAC,IAAA,EAAAC,MAAA;AAQO,MAAMC,sBAAuB,CAAA;EAoBlCC,YAAYC,cAAqC,EAAA;IAhBjD;IAAA;IAAA;IAAAC,YAAA,CAAA,IAAA,EAASV,UAAT,EAAA,KAAA,CAAA,CAAA;IACAU,YAAA,CAAA,IAAA,EAAST,SAAT,EAAA,KAAA,CAAA,CAAA;IAKA;IAAA;AAAA;AAAA;IAAAU,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAIA;IAAA;IAAA;IAAAD,YAAA,CAAA,IAAA,EAAAR,SAAA,EAAA,KAAA,CAAA,CAAA;IACAQ,YAAA,CAAA,IAAA,EAAAP,eAAA,EAAA,KAAA,CAAA,CAAA;IACAO,YAAA,CAAA,IAAA,EAAAN,cAAA,EAAA,KAAA,CAAA,CAAA;IACAM,YAAA,CAAA,IAAA,EAAAL,IAAA,EAAA,KAAA,CAAA,CAAA;IACAK,YAAA,CAAA,IAAA,EAAAJ,MAAA,EAAA,KAAA,CAAA,CAAA;IAGE,MAAMM,WAAWH,cAAe,CAAAG,QAAA;IAK1B,MAAAC,kBAAA,GACJJ,cAAe,CAAAK,SAAA,GAAYL,cAAe,CAAAM,QAAA;IAE5CC,YAAA,CAAA,IAAA,EAAKhB,YAAaS,cAAe,CAAAK,SAAA,CAAA;IACjCE,YAAA,CAAA,IAAA,EAAKf,SAAY,EAAAW,QAAA,CAAA;IACjB,IAAA,CAAKG,WAAWN,cAAe,CAAAM,QAAA;IAC1BC,YAAA,CAAA,IAAA,EAAAd,SAAA,EAAY,IAAIe,gCAAqB,CAAA;MACxCC,uBAAuBT,cAAe,CAAAU,QAAA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object.defineProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value
|
|
10
|
-
}) : obj[key] = value;
|
|
11
|
-
var __publicField = (obj, key, value) => {
|
|
12
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
|
-
return value;
|
|
14
|
-
};
|
|
15
|
-
var __accessCheck = (obj, member, msg) => {
|
|
16
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
17
|
-
};
|
|
18
|
-
var __privateGet = (obj, member, getter) => {
|
|
19
|
-
__accessCheck(obj, member, "read from private field");
|
|
20
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
21
|
-
};
|
|
22
|
-
var __privateAdd = (obj, member, value) => {
|
|
23
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
24
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
25
|
-
};
|
|
26
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
27
|
-
__accessCheck(obj, member, "write to private field");
|
|
28
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
|
-
var _itemPrice, _currency, _subtotal, _discountAmount, _taxableAmount, _tax, _total;
|
|
32
|
-
class ProductAmountAllocator {
|
|
33
|
-
constructor(productSummary) {
|
|
34
|
-
// #############################################################################
|
|
35
|
-
// Fixed values
|
|
36
|
-
// #############################################################################
|
|
37
|
-
__privateAdd(this, _itemPrice, void 0);
|
|
38
|
-
__privateAdd(this, _currency, void 0);
|
|
39
|
-
// #############################################################################
|
|
40
|
-
/**
|
|
41
|
-
* Remaining quantity to allocate
|
|
42
|
-
*/
|
|
43
|
-
__publicField(this, "quantity");
|
|
44
|
-
// #############################################################################
|
|
45
|
-
// Specific amount allocators
|
|
46
|
-
// #############################################################################
|
|
47
|
-
__privateAdd(this, _subtotal, void 0);
|
|
48
|
-
__privateAdd(this, _discountAmount, void 0);
|
|
49
|
-
__privateAdd(this, _taxableAmount, void 0);
|
|
50
|
-
__privateAdd(this, _tax, void 0);
|
|
51
|
-
__privateAdd(this, _total, void 0);
|
|
52
|
-
const currency = productSummary.currency;
|
|
53
|
-
const priceForAllocation = productSummary.itemPrice * productSummary.quantity;
|
|
54
|
-
__privateSet(this, _itemPrice, productSummary.itemPrice);
|
|
55
|
-
__privateSet(this, _currency, currency);
|
|
56
|
-
this.quantity = productSummary.quantity;
|
|
57
|
-
__privateSet(this, _subtotal, new FixedAmountAllocator({
|
|
58
|
-
initialAllocateAmount: productSummary.subtotal,
|
|
59
|
-
initialTotalAmount: priceForAllocation,
|
|
60
|
-
currency
|
|
61
|
-
}));
|
|
62
|
-
__privateSet(this, _discountAmount, new FixedAmountAllocator({
|
|
63
|
-
initialAllocateAmount: productSummary.discountAmount,
|
|
64
|
-
initialTotalAmount: priceForAllocation,
|
|
65
|
-
currency
|
|
66
|
-
}));
|
|
67
|
-
__privateSet(this, _taxableAmount, new FixedAmountAllocator({
|
|
68
|
-
initialAllocateAmount: productSummary.taxableAmount,
|
|
69
|
-
initialTotalAmount: priceForAllocation,
|
|
70
|
-
currency
|
|
71
|
-
}));
|
|
72
|
-
__privateSet(this, _tax, new FixedAmountAllocator({
|
|
73
|
-
initialAllocateAmount: productSummary.tax,
|
|
74
|
-
initialTotalAmount: priceForAllocation,
|
|
75
|
-
currency
|
|
76
|
-
}));
|
|
77
|
-
__privateSet(this, _total, new FixedAmountAllocator({
|
|
78
|
-
initialAllocateAmount: productSummary.total,
|
|
79
|
-
initialTotalAmount: priceForAllocation,
|
|
80
|
-
currency
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
allocateQty(quantity) {
|
|
84
|
-
let quantityNormalized = Math.max(quantity, 0);
|
|
85
|
-
quantityNormalized = this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;
|
|
86
|
-
this.quantity = Math.max(this.quantity - quantityNormalized, 0);
|
|
87
|
-
const itemQuantityPrice = __privateGet(this, _itemPrice) * quantityNormalized;
|
|
88
|
-
return {
|
|
89
|
-
itemPrice: __privateGet(this, _itemPrice),
|
|
90
|
-
currency: __privateGet(this, _currency),
|
|
91
|
-
quantity: quantityNormalized,
|
|
92
|
-
subtotal: amount(__privateGet(this, _subtotal).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
93
|
-
discountAmount: amount(__privateGet(this, _discountAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
94
|
-
taxableAmount: amount(__privateGet(this, _taxableAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
95
|
-
tax: amount(__privateGet(this, _tax).allocate(itemQuantityPrice, __privateGet(this, _currency))),
|
|
96
|
-
total: amount(__privateGet(this, _total).allocate(itemQuantityPrice, __privateGet(this, _currency)))
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
_itemPrice = new WeakMap();
|
|
101
|
-
_currency = new WeakMap();
|
|
102
|
-
_subtotal = new WeakMap();
|
|
103
|
-
_discountAmount = new WeakMap();
|
|
104
|
-
_taxableAmount = new WeakMap();
|
|
105
|
-
_tax = new WeakMap();
|
|
106
|
-
_total = new WeakMap();
|
|
107
|
-
export { ProductAmountAllocator };
|
|
108
|
-
//# sourceMappingURL=productAmount.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"productAmount.mjs","sources":["../../../../src/utils/money/allocators/productAmount.ts"],"sourcesContent":["import type { Currency } from \"../../../types\";\nimport { amount } from \"../misc\";\nimport type { Cents, FullLineItemSummary } from \"../types\";\nimport { FixedAmountAllocator } from \"./fixedAmount\";\n\n/**\n * Helper class to distribute a total amount for a product\n */\nexport class ProductAmountAllocator {\n // #############################################################################\n // Fixed values\n // #############################################################################\n readonly #itemPrice: Cents;\n readonly #currency: Currency;\n // #############################################################################\n /**\n * Remaining quantity to allocate\n */\n quantity: number;\n // #############################################################################\n // Specific amount allocators\n // #############################################################################\n #subtotal: FixedAmountAllocator;\n #discountAmount: FixedAmountAllocator;\n #taxableAmount: FixedAmountAllocator;\n #tax: FixedAmountAllocator;\n #total: FixedAmountAllocator;\n\n constructor(productSummary: FullLineItemSummary) {\n const currency = productSummary.currency;\n\n /**\n * Somewhat hackish, just need a stable price that can easily divide later by quantity\n */\n const priceForAllocation =\n productSummary.itemPrice * productSummary.quantity;\n\n this.#itemPrice = productSummary.itemPrice;\n this.#currency = currency;\n this.quantity = productSummary.quantity;\n this.#subtotal = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.subtotal,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#discountAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.discountAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#taxableAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.taxableAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#tax = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.tax,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#total = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.total,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n }\n\n allocateQty(quantity: number): FullLineItemSummary {\n // Calculate remaining allocatable quantity\n let quantityNormalized = Math.max(quantity, 0);\n quantityNormalized =\n this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;\n\n // Adjust remaining qty\n this.quantity = Math.max(this.quantity - quantityNormalized, 0);\n\n // How big of a slice of the total price we need to allocate\n const itemQuantityPrice = this.#itemPrice * quantityNormalized;\n\n return {\n itemPrice: this.#itemPrice,\n currency: this.#currency,\n quantity: quantityNormalized,\n subtotal: amount(\n this.#subtotal.allocate(itemQuantityPrice, this.#currency),\n ),\n discountAmount: amount(\n this.#discountAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n taxableAmount: amount(\n this.#taxableAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n tax: amount(this.#tax.allocate(itemQuantityPrice, this.#currency)),\n total: amount(this.#total.allocate(itemQuantityPrice, this.#currency)),\n } satisfies FullLineItemSummary;\n }\n}\n"],"names":["_itemPrice","_currency","_subtotal","_discountAmount","_taxableAmount","_tax","_total","ProductAmountAllocator","constructor","productSummary","__privateAdd","__publicField","currency","priceForAllocation","itemPrice","quantity","__privateSet","FixedAmountAllocator","initialAllocateAmount","subtotal","initialTotalAmount","discountAmount","taxableAmount","tax","total","allocateQty","quantityNormalized","Math","max","itemQuantityPrice","__privateGet","amount","allocate","WeakMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,eAAA,EAAAC,cAAA,EAAAC,IAAA,EAAAC,MAAA;AAQO,MAAMC,sBAAuB,CAAA;EAoBlCC,YAAYC,cAAqC,EAAA;IAhBjD;IAAA;IAAA;IAAAC,YAAA,CAAA,IAAA,EAASV,UAAT,EAAA,KAAA,CAAA,CAAA;IACAU,YAAA,CAAA,IAAA,EAAST,SAAT,EAAA,KAAA,CAAA,CAAA;IAKA;IAAA;AAAA;AAAA;IAAAU,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAIA;IAAA;IAAA;IAAAD,YAAA,CAAA,IAAA,EAAAR,SAAA,EAAA,KAAA,CAAA,CAAA;IACAQ,YAAA,CAAA,IAAA,EAAAP,eAAA,EAAA,KAAA,CAAA,CAAA;IACAO,YAAA,CAAA,IAAA,EAAAN,cAAA,EAAA,KAAA,CAAA,CAAA;IACAM,YAAA,CAAA,IAAA,EAAAL,IAAA,EAAA,KAAA,CAAA,CAAA;IACAK,YAAA,CAAA,IAAA,EAAAJ,MAAA,EAAA,KAAA,CAAA,CAAA;IAGE,MAAMM,WAAWH,cAAe,CAAAG,QAAA;IAK1B,MAAAC,kBAAA,GACJJ,cAAe,CAAAK,SAAA,GAAYL,cAAe,CAAAM,QAAA;IAE5CC,YA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AAA,IAAA4B,OAAA,CAAA,CAAA;AACA3B,MAAA,GAAA,IAAA2B,OAAA,CAAA,CAAA;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Cents, TaxRate } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Parse exchange rate to dinero friendly amount and scale.
|
|
4
|
-
*
|
|
5
|
-
* Used to prepare exchange rate for sending over API.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}
|
|
9
|
-
*/
|
|
10
|
-
export declare const toSnapshotExchangeRate: (exchangeRate: TaxRate) => {
|
|
11
|
-
amount: Cents;
|
|
12
|
-
scale: number;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Converts an arbitrary exchange rate to a fixed decimal place number.
|
|
16
|
-
*
|
|
17
|
-
* Used to take in an input and convert it for storage in the database.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* toFixedExchangeRate("0.123456789") // "0.123457"
|
|
21
|
-
* toFixedExchangeRate("0.123456789", true) // 0.123457
|
|
22
|
-
*/
|
|
23
|
-
export declare function toFixedExchangeRate(rate: string | number, asNumber?: boolean): string;
|
|
24
|
-
export declare function toFixedExchangeRate(rate: string | number, asNumber: true): number;
|
|
25
|
-
/**
|
|
26
|
-
* Invert an exchange rate by doing 1 / rate
|
|
27
|
-
* Used to fake a reverse exchange rate in case we don't have it
|
|
28
|
-
* @example
|
|
29
|
-
* invertExchangeRate("0.22") // "4.545455"
|
|
30
|
-
*/
|
|
31
|
-
export declare function invertExchangeRate(rate: string | number): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var errors = require('../errors.js');
|
|
4
|
-
var number = require('../number.js');
|
|
5
|
-
var constants = require('./constants.js');
|
|
6
|
-
var misc_private = require('./misc.private.js');
|
|
7
|
-
"use strict";
|
|
8
|
-
const toSnapshotExchangeRate = exchangeRate => {
|
|
9
|
-
number.isFloat(exchangeRate, "Exchange rate");
|
|
10
|
-
errors.assert(exchangeRate > 0, "Exchange rate must be greater than 0");
|
|
11
|
-
const rateInt = misc_private.floatToInt(exchangeRate, constants.EXCHANGE_RATE_DINERO_CURRENCY.base, constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent);
|
|
12
|
-
return {
|
|
13
|
-
amount: rateInt,
|
|
14
|
-
scale: constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
function toFixedExchangeRate(rate, asNumber) {
|
|
18
|
-
return number.toFixedRate(typeof rate === "string" ? +rate : rate, constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent, asNumber);
|
|
19
|
-
}
|
|
20
|
-
function invertExchangeRate(rate) {
|
|
21
|
-
const exchangeRate = toFixedExchangeRate(rate, true);
|
|
22
|
-
return toFixedExchangeRate(1 / exchangeRate, false);
|
|
23
|
-
}
|
|
24
|
-
exports.invertExchangeRate = invertExchangeRate;
|
|
25
|
-
exports.toFixedExchangeRate = toFixedExchangeRate;
|
|
26
|
-
exports.toSnapshotExchangeRate = toSnapshotExchangeRate;
|
|
27
|
-
//# sourceMappingURL=exchangeRate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exchangeRate.js","sources":["../../../src/utils/money/exchangeRate.ts"],"sourcesContent":["import { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport { EXCHANGE_RATE_DINERO_CURRENCY } from \"./constants\";\nimport { floatToInt } from \"./misc.private\";\nimport type { Cents, TaxRate } from \"./types\";\n\n// FIXME: reconsider if needed her as only used in BE for exchange rate Graph other places in code use Float|number\n/**\n * Parse exchange rate to dinero friendly amount and scale.\n *\n * Used to prepare exchange rate for sending over API.\n *\n * @example\n * toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}\n */\nexport const toSnapshotExchangeRate = (\n exchangeRate: TaxRate,\n): {\n amount: Cents;\n scale: number;\n} => {\n // Validate input\n isFloat(exchangeRate, \"Exchange rate\");\n assert(exchangeRate > 0, \"Exchange rate must be greater than 0\");\n\n // Get scale of exchange rate\n const rateInt = floatToInt(\n exchangeRate,\n EXCHANGE_RATE_DINERO_CURRENCY.base,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n );\n\n // Return dinero friendly amount and scale\n return {\n amount: rateInt,\n scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n };\n};\n\n/**\n * Converts an arbitrary exchange rate to a fixed decimal place number.\n *\n * Used to take in an input and convert it for storage in the database.\n *\n * @example\n * toFixedExchangeRate(\"0.123456789\") // \"0.123457\"\n * toFixedExchangeRate(\"0.123456789\", true) // 0.123457\n */\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber: true,\n): number;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string | number {\n // FIXME: Remove + but instead add proper parsing of the string --> number\n // https://stackoverflow.com/a/12862627/1378261\n return toFixedRate(\n typeof rate === \"string\" ? +rate : rate,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n asNumber,\n );\n}\n\n/**\n * Invert an exchange rate by doing 1 / rate\n * Used to fake a reverse exchange rate in case we don't have it\n * @example\n * invertExchangeRate(\"0.22\") // \"4.545455\"\n */\nexport function invertExchangeRate(rate: string | number) {\n const exchangeRate = toFixedExchangeRate(rate, true);\n return toFixedExchangeRate(1 / exchangeRate, false);\n}\n"],"names":["toSnapshotExchangeRate","exchangeRate","isFloat","assert","rateInt","floatToInt","EXCHANGE_RATE_DINERO_CURRENCY","base","exponent","amount","scale","toFixedExchangeRate","rate","asNumber","toFixedRate","invertExchangeRate"],"mappings":";;;;;;;AAea,MAAAA,sBAAA,GACXC,YAIG,IAAA;EAEHC,cAAA,CAAQD,cAAc,eAAe,CAAA;EAC9BE,MAAAA,CAAAA,MAAA,CAAAF,YAAA,GAAe,GAAG,sCAAsC,CAAA;EAG/D,MAAMG,OAAU,GAAAC,YAAA,CAAAA,UAAA,CACdJ,YAAA,EACAK,SAAAA,CAAAA,6BAA8B,CAAAC,IAAA,EAC9BD,SAAAA,CAAAA,6BAA8B,CAAAE,QAAA,CAChC;EAGO,OAAA;IACLC,MAAQ,EAAAL,OAAA;IACRM,OAAOJ,SAA8B,CAAAA,6BAAA,CAAAE;EAAA,CACvC;AACF,CAAA;AAmBgB,SAAAG,mBAAAA,CACdC,MACAC,QACiB,EAAA;EAGV,OAAAC,MAAA,CAAAA,WAAA,CACL,OAAOF,IAAA,KAAS,QAAW,GAAA,CAACA,IAAO,GAAAA,IAAA,EACnCN,SAAAA,CAAAA,6BAA8B,CAAAE,QAAA,EAC9BK,QAAA,CACF;AACF;AAQO,SAASE,mBAAmBH,IAAuB,EAAA;EAClD,MAAAX,YAAA,GAAeU,mBAAoB,CAAAC,IAAA,EAAM,IAAI,CAAA;EAC5C,OAAAD,mBAAA,CAAoB,CAAI,GAAAV,YAAA,EAAc,KAAK,CAAA;AACpD;;;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { assert } from '../errors.mjs';
|
|
2
|
-
import { isFloat, toFixedRate } from '../number.mjs';
|
|
3
|
-
import { EXCHANGE_RATE_DINERO_CURRENCY } from './constants.mjs';
|
|
4
|
-
import { floatToInt } from './misc.private.mjs';
|
|
5
|
-
"use strict";
|
|
6
|
-
const toSnapshotExchangeRate = exchangeRate => {
|
|
7
|
-
isFloat(exchangeRate, "Exchange rate");
|
|
8
|
-
assert(exchangeRate > 0, "Exchange rate must be greater than 0");
|
|
9
|
-
const rateInt = floatToInt(exchangeRate, EXCHANGE_RATE_DINERO_CURRENCY.base, EXCHANGE_RATE_DINERO_CURRENCY.exponent);
|
|
10
|
-
return {
|
|
11
|
-
amount: rateInt,
|
|
12
|
-
scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
function toFixedExchangeRate(rate, asNumber) {
|
|
16
|
-
return toFixedRate(typeof rate === "string" ? +rate : rate, EXCHANGE_RATE_DINERO_CURRENCY.exponent, asNumber);
|
|
17
|
-
}
|
|
18
|
-
function invertExchangeRate(rate) {
|
|
19
|
-
const exchangeRate = toFixedExchangeRate(rate, true);
|
|
20
|
-
return toFixedExchangeRate(1 / exchangeRate, false);
|
|
21
|
-
}
|
|
22
|
-
export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate };
|
|
23
|
-
//# sourceMappingURL=exchangeRate.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exchangeRate.mjs","sources":["../../../src/utils/money/exchangeRate.ts"],"sourcesContent":["import { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport { EXCHANGE_RATE_DINERO_CURRENCY } from \"./constants\";\nimport { floatToInt } from \"./misc.private\";\nimport type { Cents, TaxRate } from \"./types\";\n\n// FIXME: reconsider if needed her as only used in BE for exchange rate Graph other places in code use Float|number\n/**\n * Parse exchange rate to dinero friendly amount and scale.\n *\n * Used to prepare exchange rate for sending over API.\n *\n * @example\n * toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}\n */\nexport const toSnapshotExchangeRate = (\n exchangeRate: TaxRate,\n): {\n amount: Cents;\n scale: number;\n} => {\n // Validate input\n isFloat(exchangeRate, \"Exchange rate\");\n assert(exchangeRate > 0, \"Exchange rate must be greater than 0\");\n\n // Get scale of exchange rate\n const rateInt = floatToInt(\n exchangeRate,\n EXCHANGE_RATE_DINERO_CURRENCY.base,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n );\n\n // Return dinero friendly amount and scale\n return {\n amount: rateInt,\n scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n };\n};\n\n/**\n * Converts an arbitrary exchange rate to a fixed decimal place number.\n *\n * Used to take in an input and convert it for storage in the database.\n *\n * @example\n * toFixedExchangeRate(\"0.123456789\") // \"0.123457\"\n * toFixedExchangeRate(\"0.123456789\", true) // 0.123457\n */\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber: true,\n): number;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string | number {\n // FIXME: Remove + but instead add proper parsing of the string --> number\n // https://stackoverflow.com/a/12862627/1378261\n return toFixedRate(\n typeof rate === \"string\" ? +rate : rate,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n asNumber,\n );\n}\n\n/**\n * Invert an exchange rate by doing 1 / rate\n * Used to fake a reverse exchange rate in case we don't have it\n * @example\n * invertExchangeRate(\"0.22\") // \"4.545455\"\n */\nexport function invertExchangeRate(rate: string | number) {\n const exchangeRate = toFixedExchangeRate(rate, true);\n return toFixedExchangeRate(1 / exchangeRate, false);\n}\n"],"names":["toSnapshotExchangeRate","exchangeRate","isFloat","assert","rateInt","floatToInt","EXCHANGE_RATE_DINERO_CURRENCY","base","exponent","amount","scale","toFixedExchangeRate","rate","asNumber","toFixedRate","invertExchangeRate"],"mappings":";;;;;AAea,MAAAA,sBAAA,GACXC,YAIG,IAAA;EAEHC,OAAA,CAAQD,cAAc,eAAe,CAAA;EAC9BE,MAAA,CAAAF,YAAA,GAAe,GAAG,sCAAsC,CAAA;EAG/D,MAAMG,OAAU,GAAAC,UAAA,CACdJ,YAAA,EACAK,6BAA8B,CAAAC,IAAA,EAC9BD,6BAA8B,CAAAE,QAAA,CAChC;EAGO,OAAA;IACLC,MAAQ,EAAAL,OAAA;IACRM,OAAOJ,6BAA8B,CAAAE;EAAA,CACvC;AACF,CAAA;AAmBgB,SAAAG,mBAAAA,CACdC,MACAC,QACiB,EAAA;EAGV,OAAAC,WAAA,CACL,OAAOF,IAAA,KAAS,QAAW,GAAA,CAACA,IAAO,GAAAA,IAAA,EACnCN,6BAA8B,CAAAE,QAAA,EAC9BK,QAAA,CACF;AACF;AAQO,SAASE,mBAAmBH,IAAuB,EAAA;EAClD,MAAAX,YAAA,GAAeU,mBAAoB,CAAAC,IAAA,EAAM,IAAI,CAAA;EAC5C,OAAAD,mBAAA,CAAoB,CAAI,GAAAV,YAAA,EAAc,KAAK,CAAA;AACpD;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as currencies from "@dinero.js/currencies";
|
|
2
|
-
import type { DinoCurrency } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Fast lookup for our custom currency enum to check that given currency is valid
|
|
5
|
-
*/
|
|
6
|
-
export declare const currencyLookup: Set<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Dinero currency lookup to check that given currency is valid
|
|
9
|
-
*/
|
|
10
|
-
export declare const dineroCurrenciesLookup: Map<string, currencies.Currency<number>>;
|
|
11
|
-
/**
|
|
12
|
-
* Private util to convert a float value into a int. Also applies financial rounding to the value if needed.
|
|
13
|
-
* Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats
|
|
14
|
-
* @example
|
|
15
|
-
* floatToInt(69.10, 10, 2); // 6910
|
|
16
|
-
* floatToInt(42, 10, 2); // 4200
|
|
17
|
-
* floatToInt(0.22, 10, 6); // 220000
|
|
18
|
-
*/
|
|
19
|
-
export declare const floatToInt: (floatAmount: number, base: number, exponent: number) => number;
|
|
20
|
-
/**
|
|
21
|
-
* FIXME: is it private tho?!
|
|
22
|
-
*/
|
|
23
|
-
export declare const decimalToDinero: (decimalAmount: string | number, currency: DinoCurrency) => import("dinero.js").Dinero<number>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var currencies = require('@dinero.js/currencies');
|
|
4
|
-
var dinero_js = require('dinero.js');
|
|
5
|
-
require('../../types/index.js');
|
|
6
|
-
var number = require('../number.js');
|
|
7
|
-
var constants = require('./constants.js');
|
|
8
|
-
var generated = require('../../types/generated.js');
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return e[k];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
n["default"] = e;
|
|
26
|
-
return Object.freeze(n);
|
|
27
|
-
}
|
|
28
|
-
var currencies__namespace = /*#__PURE__*/_interopNamespace(currencies);
|
|
29
|
-
"use strict";
|
|
30
|
-
const currencyLookup = new Set(Object.keys(generated.Currency).map(el => el.toString()));
|
|
31
|
-
const dineroCurrenciesLookup = new Map(Object.values(currencies__namespace).map(currency => [currency.code, currency]));
|
|
32
|
-
const floatToInt = (floatAmount, base, exponent) => constants.Round.Financial(floatAmount * Math.pow(base, exponent));
|
|
33
|
-
const decimalToDinero = (decimalAmount, currency) => {
|
|
34
|
-
const parsedNumber = typeof decimalAmount === "number" ? decimalAmount : Number.parseFloat(decimalAmount);
|
|
35
|
-
number.isFloat(parsedNumber);
|
|
36
|
-
const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(10, currency.exponent)).toFixed(0));
|
|
37
|
-
return dinero_js.dinero({
|
|
38
|
-
amount: parsedNumberInt,
|
|
39
|
-
currency
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
exports.currencyLookup = currencyLookup;
|
|
43
|
-
exports.decimalToDinero = decimalToDinero;
|
|
44
|
-
exports.dineroCurrenciesLookup = dineroCurrenciesLookup;
|
|
45
|
-
exports.floatToInt = floatToInt;
|
|
46
|
-
//# sourceMappingURL=misc.private.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"misc.private.js","sources":["../../../src/utils/money/misc.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport * as currencies from \"@dinero.js/currencies\";\nimport { dinero } from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { isFloat } from \"../number\";\nimport { Round } from \"./constants\";\nimport type { DinoCurrency } from \"./types\";\n\n/**\n * Fast lookup for our custom currency enum to check that given currency is valid\n */\nexport const currencyLookup = new Set(\n Object.keys(Currency).map((el) => el.toString()),\n);\n\n/**\n * Dinero currency lookup to check that given currency is valid\n */\nexport const dineroCurrenciesLookup = new Map(\n Object.values(currencies).map((currency) => [currency.code, currency]),\n);\n\n/**\n * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.\n * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats\n * @example\n * floatToInt(69.10, 10, 2); // 6910\n * floatToInt(42, 10, 2); // 4200\n * floatToInt(0.22, 10, 6); // 220000\n */\nexport const floatToInt = (\n floatAmount: number,\n base: number,\n exponent: number,\n // FIXME: pass in the rounding method and or use roundDinero\n): number => Round.Financial(floatAmount * Math.pow(base, exponent));\n\n/**\n * FIXME: is it private tho?!\n */\nexport const decimalToDinero = (\n decimalAmount: string | number,\n currency: DinoCurrency,\n // FIXME: rounding method?!\n) => {\n const parsedNumber =\n typeof decimalAmount === \"number\"\n ? decimalAmount\n : Number.parseFloat(decimalAmount);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (parsedNumber * Math.pow(10, currency.exponent)).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency,\n });\n};\n"],"names":["currencyLookup","Set","Object","keys","Currency","map","el","toString","dineroCurrenciesLookup","Map","values","currencies","currency","code","floatToInt","floatAmount","base","exponent","Round","Financial","Math","pow","decimalToDinero","decimalAmount","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","toFixed","dinero","amount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAMA,iBAAiB,IAAIC,GAAA,CAChCC,MAAA,CAAOC,KAAKC,SAAAA,CAAAA,QAAQ,CAAA,CAAEC,IAAKC,EAAA,IAAOA,EAAG,CAAAC,QAAA,EAAU,CACjD,CAAA;AAKO,MAAMC,yBAAyB,IAAIC,GAAA,CACxCP,MAAA,CAAOQ,MAAO,CAAAC,qBAAU,CAAE,CAAAN,GAAA,CAAKO,QAAA,IAAa,CAACA,QAAA,CAASC,IAAM,EAAAD,QAAQ,CAAC,CACvE,CAAA;AAUO,MAAME,UAAa,GAAAA,CACxBC,WACA,EAAAC,IAAA,EACAC,QAEW,KAAAC,SAAA,CAAAA,KAAA,CAAMC,SAAU,CAAAJ,WAAA,GAAcK,IAAK,CAAAC,GAAA,CAAIL,IAAM,EAAAC,QAAQ,CAAC,CAAA;AAKtD,MAAAK,eAAA,GAAkBA,CAC7BC,aAAA,EACAX,QAEG,KAAA;EACH,MAAMY,eACJ,OAAOD,aAAA,KAAkB,WACrBA,aACA,GAAAE,MAAA,CAAOC,WAAWH,aAAa,CAAA;EACrCI,MAAA,CAAAA,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAC5B,CAAAL,YAAA,GAAeJ,KAAKC,GAAI,CAAA,EAAA,EAAIT,SAASK,QAAQ,CAAA,EAAGa,QAAQ,CAAC,CAAA,CAC5D;EACA,OAAOC,gBAAO,CAAA;IACZC,MAAQ,EAAAJ,eAAA;IACRhB;EAAA,CACD,CAAA;AACH,CAAA;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as currencies from '@dinero.js/currencies';
|
|
2
|
-
import { dinero } from 'dinero.js';
|
|
3
|
-
import '../../types/index.mjs';
|
|
4
|
-
import { isFloat } from '../number.mjs';
|
|
5
|
-
import { Round } from './constants.mjs';
|
|
6
|
-
import { Currency } from '../../types/generated.mjs';
|
|
7
|
-
"use strict";
|
|
8
|
-
const currencyLookup = new Set(Object.keys(Currency).map(el => el.toString()));
|
|
9
|
-
const dineroCurrenciesLookup = new Map(Object.values(currencies).map(currency => [currency.code, currency]));
|
|
10
|
-
const floatToInt = (floatAmount, base, exponent) => Round.Financial(floatAmount * Math.pow(base, exponent));
|
|
11
|
-
const decimalToDinero = (decimalAmount, currency) => {
|
|
12
|
-
const parsedNumber = typeof decimalAmount === "number" ? decimalAmount : Number.parseFloat(decimalAmount);
|
|
13
|
-
isFloat(parsedNumber);
|
|
14
|
-
const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(10, currency.exponent)).toFixed(0));
|
|
15
|
-
return dinero({
|
|
16
|
-
amount: parsedNumberInt,
|
|
17
|
-
currency
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
export { currencyLookup, decimalToDinero, dineroCurrenciesLookup, floatToInt };
|
|
21
|
-
//# sourceMappingURL=misc.private.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"misc.private.mjs","sources":["../../../src/utils/money/misc.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport * as currencies from \"@dinero.js/currencies\";\nimport { dinero } from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { isFloat } from \"../number\";\nimport { Round } from \"./constants\";\nimport type { DinoCurrency } from \"./types\";\n\n/**\n * Fast lookup for our custom currency enum to check that given currency is valid\n */\nexport const currencyLookup = new Set(\n Object.keys(Currency).map((el) => el.toString()),\n);\n\n/**\n * Dinero currency lookup to check that given currency is valid\n */\nexport const dineroCurrenciesLookup = new Map(\n Object.values(currencies).map((currency) => [currency.code, currency]),\n);\n\n/**\n * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.\n * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats\n * @example\n * floatToInt(69.10, 10, 2); // 6910\n * floatToInt(42, 10, 2); // 4200\n * floatToInt(0.22, 10, 6); // 220000\n */\nexport const floatToInt = (\n floatAmount: number,\n base: number,\n exponent: number,\n // FIXME: pass in the rounding method and or use roundDinero\n): number => Round.Financial(floatAmount * Math.pow(base, exponent));\n\n/**\n * FIXME: is it private tho?!\n */\nexport const decimalToDinero = (\n decimalAmount: string | number,\n currency: DinoCurrency,\n // FIXME: rounding method?!\n) => {\n const parsedNumber =\n typeof decimalAmount === \"number\"\n ? decimalAmount\n : Number.parseFloat(decimalAmount);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (parsedNumber * Math.pow(10, currency.exponent)).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency,\n });\n};\n"],"names":["currencyLookup","Set","Object","keys","Currency","map","el","toString","dineroCurrenciesLookup","Map","values","currencies","currency","code","floatToInt","floatAmount","base","exponent","Round","Financial","Math","pow","decimalToDinero","decimalAmount","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","toFixed","dinero","amount"],"mappings":";;;;;;;AAeO,MAAMA,iBAAiB,IAAIC,GAAA,CAChCC,MAAA,CAAOC,KAAKC,QAAQ,CAAA,CAAEC,IAAKC,EAAA,IAAOA,EAAG,CAAAC,QAAA,EAAU,CACjD,CAAA;AAKO,MAAMC,yBAAyB,IAAIC,GAAA,CACxCP,MAAA,CAAOQ,MAAO,CAAAC,UAAU,CAAE,CAAAN,GAAA,CAAKO,QAAA,IAAa,CAACA,QAAA,CAASC,IAAM,EAAAD,QAAQ,CAAC,CACvE,CAAA;AAUO,MAAME,UAAa,GAAAA,CACxBC,WACA,EAAAC,IAAA,EACAC,QAEW,KAAAC,KAAA,CAAMC,SAAU,CAAAJ,WAAA,GAAcK,IAAK,CAAAC,GAAA,CAAIL,IAAM,EAAAC,QAAQ,CAAC,CAAA;AAKtD,MAAAK,eAAA,GAAkBA,CAC7BC,aAAA,EACAX,QAEG,KAAA;EACH,MAAMY,eACJ,OAAOD,aAAA,KAAkB,WACrBA,aACA,GAAAE,MAAA,CAAOC,WAAWH,aAAa,CAAA;EACrCI,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAC5B,CAAAL,YAAA,GAAeJ,KAAKC,GAAI,CAAA,EAAA,EAAIT,SAASK,QAAQ,CAAA,EAAGa,QAAQ,CAAC,CAAA,CAC5D;EACA,OAAOC,MAAO,CAAA;IACZC,MAAQ,EAAAJ,eAAA;IACRhB;EAAA,CACD,CAAA;AACH,CAAA;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var constants = require('./constants.js');
|
|
4
|
-
var misc = require('./misc.js');
|
|
5
|
-
"use strict";
|
|
6
|
-
const roundShippingPrice = price => misc.roundDinero(price, constants.Round.Shipping);
|
|
7
|
-
exports.roundShippingPrice = roundShippingPrice;
|
|
8
|
-
//# sourceMappingURL=shipping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shipping.js","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,IAAY,CAAAA,WAAA,CAAAD,KAAA,EAAOE,gBAAMC,QAAQ,CAAA;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shipping.mjs","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,WAAY,CAAAD,KAAA,EAAOE,MAAMC,QAAQ,CAAA;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Dinero } from "dinero.js";
|
|
2
|
-
import type { Cents, LineItemSummary, SingleLineItemSummary, TaxRate } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Private helper to convert a floating number to a dinero friendly allocation integer pair
|
|
5
|
-
* @see https://v2.dinerojs.com/docs/api/mutations/allocate
|
|
6
|
-
* @example
|
|
7
|
-
* taxRateToDineroAllocation(0.1) // [1, 9]
|
|
8
|
-
* taxRateToDineroAllocation(0.5) // [5, 5]
|
|
9
|
-
*/
|
|
10
|
-
export declare const taxRateToDineroAllocation: (taxRate: TaxRate) => [number, number];
|
|
11
|
-
/**
|
|
12
|
-
* Reverse engineer the taxable amount from "whole item" taxable amount into "per item" taxable amount for custom tax
|
|
13
|
-
* rate calculations
|
|
14
|
-
*/
|
|
15
|
-
export declare const allocatePerItemTaxableAmount: (itemSummary: LineItemSummary) => SingleLineItemSummary[];
|
|
16
|
-
export declare const calculateWholeQtyLineItemTax: (itemSummary: LineItemSummary, taxRate: TaxRate) => Dinero<Cents>;
|
|
17
|
-
export declare const calculatePerQtyLineItemTax: (itemSummary: LineItemSummary, taxRate: TaxRate) => Dinero<Cents>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dinero_js = require('dinero.js');
|
|
4
|
-
var errors = require('../errors.js');
|
|
5
|
-
var fixedAmount = require('./allocators/fixedAmount.js');
|
|
6
|
-
var misc = require('./misc.js');
|
|
7
|
-
"use strict";
|
|
8
|
-
const taxRateToDineroAllocation = taxRate => {
|
|
9
|
-
if (taxRate <= 0 || taxRate >= 1) {
|
|
10
|
-
throw new RangeError("Unsupported rate, expected in range of 0>rate<1");
|
|
11
|
-
}
|
|
12
|
-
const rateScale = String(taxRate).split(".")[1]?.length;
|
|
13
|
-
errors.assert(rateScale !== void 0, "rateScale is undefined");
|
|
14
|
-
const rateInt = Math.round(taxRate * Math.pow(10, rateScale));
|
|
15
|
-
return [rateInt, Math.pow(10, rateScale) - rateInt];
|
|
16
|
-
};
|
|
17
|
-
const allocatePerItemTaxableAmount = itemSummary => {
|
|
18
|
-
if (itemSummary.quantity === 1) {
|
|
19
|
-
return [itemSummary];
|
|
20
|
-
}
|
|
21
|
-
const preDiscountAmount = dinero_js.add(misc.getDinero(itemSummary.taxableAmount, itemSummary.currency), misc.getDinero(itemSummary.discountAmount, itemSummary.currency));
|
|
22
|
-
const allocator = new fixedAmount.FixedAmountAllocator({
|
|
23
|
-
initialAllocateAmount: itemSummary.discountAmount,
|
|
24
|
-
initialTotalAmount: misc.amount(preDiscountAmount),
|
|
25
|
-
currency: itemSummary.currency
|
|
26
|
-
});
|
|
27
|
-
return Array.from({
|
|
28
|
-
length: itemSummary.quantity
|
|
29
|
-
}, () => {
|
|
30
|
-
const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
|
|
31
|
-
const taxableAmount = dinero_js.subtract(misc.getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
|
|
32
|
-
return {
|
|
33
|
-
itemPrice: itemSummary.itemPrice,
|
|
34
|
-
taxableAmount: misc.amount(taxableAmount),
|
|
35
|
-
discountAmount: misc.amount(discountAllocatedAmount),
|
|
36
|
-
currency: itemSummary.currency,
|
|
37
|
-
quantity: 1
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
|
|
42
|
-
if (taxRate === 0) {
|
|
43
|
-
return misc.getDinero(0, itemSummary.currency);
|
|
44
|
-
}
|
|
45
|
-
const [taxAmount] = dinero_js.allocate(misc.getDinero(itemSummary.taxableAmount, itemSummary.currency), taxRateToDineroAllocation(taxRate));
|
|
46
|
-
errors.assert(taxAmount !== void 0, "taxAmount is undefined");
|
|
47
|
-
return taxAmount;
|
|
48
|
-
};
|
|
49
|
-
const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
|
|
50
|
-
if (taxRate === 0) {
|
|
51
|
-
return misc.getDinero(0, itemSummary.currency);
|
|
52
|
-
}
|
|
53
|
-
const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
|
|
54
|
-
let totalTaxAmount = misc.getDinero(0, itemSummary.currency);
|
|
55
|
-
singleItemSummaries.forEach(itemSummary2 => {
|
|
56
|
-
const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
|
|
57
|
-
totalTaxAmount = dinero_js.add(totalTaxAmount, taxAmount);
|
|
58
|
-
});
|
|
59
|
-
return totalTaxAmount;
|
|
60
|
-
};
|
|
61
|
-
exports.allocatePerItemTaxableAmount = allocatePerItemTaxableAmount;
|
|
62
|
-
exports.calculatePerQtyLineItemTax = calculatePerQtyLineItemTax;
|
|
63
|
-
exports.calculateWholeQtyLineItemTax = calculateWholeQtyLineItemTax;
|
|
64
|
-
exports.taxRateToDineroAllocation = taxRateToDineroAllocation;
|
|
65
|
-
//# sourceMappingURL=tax.private.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tax.private.js","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport type { Dinero } from \"dinero.js\";\nimport { add, allocate, subtract } from \"dinero.js\";\n\nimport { assert } from \"../errors\";\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { amount, getDinero } from \"./misc\";\nimport type {\n Cents,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\n\n/**\n * Private helper to convert a floating number to a dinero friendly allocation integer pair\n * @see https://v2.dinerojs.com/docs/api/mutations/allocate\n * @example\n * taxRateToDineroAllocation(0.1) // [1, 9]\n * taxRateToDineroAllocation(0.5) // [5, 5]\n */\nexport const taxRateToDineroAllocation = (\n taxRate: TaxRate,\n): [number, number] => {\n if (taxRate <= 0 || taxRate >= 1) {\n throw new RangeError(\"Unsupported rate, expected in range of 0>rate<1\");\n }\n\n // Get the scale of the rate\n const rateScale = String(taxRate).split(\".\")[1]?.length;\n assert(rateScale !== undefined, \"rateScale is undefined\");\n\n // Convert to integers\n const rateInt = Math.round(taxRate * Math.pow(10, rateScale));\n return [rateInt, Math.pow(10, rateScale) - rateInt];\n};\n\n/**\n * Reverse engineer the taxable amount from \"whole item\" taxable amount into \"per item\" taxable amount for custom tax\n * rate calculations\n */\nexport const allocatePerItemTaxableAmount = (\n itemSummary: LineItemSummary,\n): SingleLineItemSummary[] => {\n /**\n * If the item quantity is 1, we can just return the item summary as is\n */\n if (itemSummary.quantity === 1) {\n return [itemSummary as SingleLineItemSummary];\n }\n\n // Reverse engineer price before discount\n const preDiscountAmount = add(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n getDinero(itemSummary.discountAmount, itemSummary.currency),\n );\n\n const allocator = new FixedAmountAllocator({\n initialAllocateAmount: itemSummary.discountAmount,\n initialTotalAmount: amount(preDiscountAmount),\n currency: itemSummary.currency,\n });\n\n // Iterate over the amount of qty to reverse engineer the discount price\n return Array.from({ length: itemSummary.quantity }, () => {\n const discountAllocatedAmount = allocator.allocate(\n itemSummary.itemPrice,\n itemSummary.currency,\n );\n\n const taxableAmount = subtract(\n getDinero(itemSummary.itemPrice, itemSummary.currency),\n discountAllocatedAmount,\n );\n\n return {\n itemPrice: itemSummary.itemPrice,\n taxableAmount: amount(taxableAmount),\n discountAmount: amount(discountAllocatedAmount),\n currency: itemSummary.currency,\n quantity: 1,\n } as SingleLineItemSummary;\n });\n};\n\nexport const calculateWholeQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * FIXME: look into approach with multiply and different scale for control over rounding, currently we just inherit\n * what dinero gives us which cause unexpected rounding issue\n */\n const [taxAmount] = allocate(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n taxRateToDineroAllocation(taxRate),\n );\n\n assert(taxAmount !== undefined, \"taxAmount is undefined\");\n return taxAmount;\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n // Split the item summary into per individual item qty summaries\n const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);\n\n // Calculate individual item qty tax and sum them up\n let totalTaxAmount = getDinero(0, itemSummary.currency);\n\n singleItemSummaries.forEach((itemSummary) => {\n // Probably a bit confusing at first, but calling the whole qty tax calculation function here as we can safely use\n // it as item summary is always a single item summary here\n const taxAmount = calculateWholeQtyLineItemTax(itemSummary, taxRate);\n totalTaxAmount = add(totalTaxAmount, taxAmount);\n });\n\n return totalTaxAmount;\n};\n"],"names":["taxRateToDineroAllocation","taxRate","RangeError","rateScale","String","split","length","assert","rateInt","Math","round","pow","allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxAmount","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach"],"mappings":";;;;;;;AAwBa,MAAAA,yBAAA,GACXC,OACqB,IAAA;EACjB,IAAAA,OAAA,IAAW,CAAK,IAAAA,OAAA,IAAW,CAAG,EAAA;IAC1B,MAAA,IAAIC,WAAW,iDAAiD,CAAA;EACxE;EAGM,MAAAC,SAAA,GAAYC,OAAOH,OAAO,CAAA,CAAEI,MAAM,GAAG,CAAA,CAAE,CAAC,CAAG,EAAAC,MAAA;EAC1CC,MAAAA,CAAAA,MAAA,CAAAJ,SAAA,KAAc,QAAW,w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