@ubnt/store.core 9.15.0-alpha.3 → 9.15.0-prealpha.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 +1 -138
- package/lib/_virtual/_virtual_multi-entry.js +12 -27
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +10 -14
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/assets/close.svg +1 -3
- package/lib/assets/close2.svg +2 -3
- package/lib/assets/close3.svg +4 -1
- 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/plus5.svg +9 -9
- package/lib/assets/plus6.svg +9 -9
- package/lib/assets/ucgMax.jpg +0 -0
- package/lib/assets/ucgMax2.jpg +0 -0
- package/lib/assets/ucgUltra.jpg +0 -0
- package/lib/assets/ucgUltra2.jpg +0 -0
- 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/CustomImage/CustomImage.js +1 -1
- package/lib/components/CustomImage/CustomImage.mjs +1 -1
- 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/GridGallery/GridModal/GridModal.js +1 -1
- package/lib/components/GridGallery/GridModal/GridModal.mjs +1 -1
- package/lib/components/Header/CartModalV2/CartModal.js +1 -1
- package/lib/components/Header/CartModalV2/CartModal.mjs +1 -1
- package/lib/components/Header/Header.js +1 -1
- package/lib/components/Header/Header.mjs +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/LandingPageSidebar/LandingPageSidebar.js +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs +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/ucgMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.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/ucgMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.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 +15 -15
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +10 -10
- package/lib/components/ModelCompareV3/data/products/ucgMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +1 -1
- 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 +17 -313
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +17 -311
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +2 -3
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js +34 -120
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs +34 -120
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.d.ts +2 -16
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js +12 -54
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs +11 -50
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowLeftPrimary.svg.js +5 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowRightPrimary.svg.js +5 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
- 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 +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.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/InputCard/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +4 -4
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +4 -4
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs.map +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/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.js +2 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs +2 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs.map +1 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.d.ts +1 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.js +1 -3
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.mjs +1 -3
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.d.ts +0 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.js +7 -10
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.mjs +7 -10
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.types.d.ts +0 -1
- package/lib/components/ResourceCalculatorV1/components/index.d.ts +1 -0
- package/lib/components/ResourceCalculatorV1/components/index.js +5 -0
- package/lib/{utils/money/allocators → components/ResourceCalculatorV1/components}/index.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/components/index.mjs +3 -0
- package/lib/{utils/money/allocators → components/ResourceCalculatorV1/components}/index.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.js +4 -6
- package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +4 -6
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
- package/lib/components/Search/Input/Input.js +1 -1
- package/lib/components/Search/Input/Input.mjs +1 -1
- 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/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -2
- package/lib/components/index.js.map +1 -1
- package/lib/components/index.mjs +0 -2
- package/lib/components/index.mjs.map +1 -1
- package/lib/constants/icons/generic/close.svg.js +1 -1
- package/lib/constants/icons/generic/close.svg.mjs +2 -2
- package/lib/constants/icons/generic/index.js +1 -1
- package/lib/constants/icons/generic/index.mjs +1 -1
- package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -1
- package/lib/constants/proStoreCategories/mapping/index.js +11 -16
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +11 -16
- 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/helpers/index.d.ts +0 -1
- package/lib/helpers/index.js +0 -11
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/index.mjs +0 -1
- package/lib/helpers/index.mjs.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +0 -1
- package/lib/types/index.mjs.map +1 -1
- package/lib/utils/array.d.ts +0 -4
- package/lib/utils/array.js +0 -10
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/array.mjs +1 -10
- package/lib/utils/array.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 +1 -1
- package/lib/assets/efg.png +0 -0
- package/lib/assets/ucg-max.png +0 -0
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs.map +0 -1
- package/lib/helpers/product.d.ts +0 -87
- package/lib/helpers/product.js +0 -346
- package/lib/helpers/product.js.map +0 -1
- package/lib/helpers/product.mjs +0 -335
- package/lib/helpers/product.mjs.map +0 -1
- package/lib/types/product.d.ts +0 -87
- package/lib/types/product.js +0 -14
- package/lib/types/product.js.map +0 -1
- package/lib/types/product.mjs +0 -13
- package/lib/types/product.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.mjs +0 -4
- 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
- package/lib/utils/productSort.d.ts +0 -41
- package/lib/utils/productSort.js +0 -66
- package/lib/utils/productSort.js.map +0 -1
- package/lib/utils/productSort.mjs +0 -59
- package/lib/utils/productSort.mjs.map +0 -1
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.d.ts +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js.map +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"format.js","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { dinero, toFormat } from \"dinero.js\";\nimport type { Dinero } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { currencyObjLookup } from \"./constants\";\nimport type { Money } from \"./misc\";\nimport type { CurrencyObj } from \"./types\";\n\nexport const getCurrencyObj = (\n currencyCode: Nullish<Currency>,\n): CurrencyObj | undefined => {\n return currencyCode ? currencyObjLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behaviour - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dineroObject: Dinero<number>,\n locale: string,\n options?: FormatPriceOptions,\n) {\n return toFormat(dineroObject, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const currencyObj = getCurrencyObj(money.currency);\n\n if (!currencyObj) {\n throw new Error(`Currency ${money.currency} not supported`);\n }\n\n const d = dinero({\n amount: money.amount,\n currency: currencyObj.currency,\n });\n return formatPriceRaw(d, currencyObj.locale, options);\n};\n"],"names":["getCurrencyObj","currencyCode","currencyObjLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dineroObject","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","currencyObj","Error","d","dinero"],"mappings":";;;;;AAQa,MAAAA,cAAA,GACXC,YAC4B,IAAA;EAC5B,OAAOA,YAAe,GAAAC,SAAAA,CAAAA,iBAAA,CAAkBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AAC9D,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EACtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;AAAA;AAAA;AAAA;AAAA;IAMVa,YAAc,EAAA,UAAA;IACdC,eAAiB,EAAA;EAAA,CAClB,CAAA;EACsBX,sBAAA,CAAAY,GAAA,CAAIR,UAAUC,SAAS,CAAA;EAEvC,OAAAA,SAAA;AACT,CAAA;AAkCgB,SAAAQ,cAAAA,CACdC,YACA,EAAAX,MAAA,EACAY,OACA,EAAA;EACA,OAAOC,mBAASF,YAAc,EAAA,CAAC;IAAEG,MAAA;IAAQR;GAAe,KAAA;IACtD,MAAMJ,SAAY,GAAAH,oBAAA,CAAqBC,MAAQ,EAAAM,QAAA,CAASS,IAAI,CAAA;IACtD,MAAAC,SAAA,GAAYd,SAAU,CAAAe,MAAA,CAAOH,MAAM,CAAA;IAElC,OAAAF,OAAA,EAASM,mBAAmBN,OAAS,EAAAO,mBAAA;IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;IAQxCH,SAAU,CAAAI,OAAA;IAAA;IAER,IAAIC,MAAA,CACF,UAAA;IAEET,SAASM,eAAkB,GAAA,KAAA,GAAQ,CACrC,MAAMZ,SAASgB,QAAQ,aACzB,CAAA;IAAA;IAEA,IACF,CAAA,IACAN,SAAA;EAAA,CACL,CAAA;AACH;AAOa,MAAAO,WAAA,GAAcA,CACzBC,KAAA,EACAZ,OACW,KAAA;EACL,MAAAa,WAAA,GAAchC,cAAe,CAAA+B,KAAA,CAAMlB,QAAQ,CAAA;EAEjD,IAAI,CAACmB,WAAa,EAAA;IAChB,MAAM,IAAIC,KAAA,CAAkB,YAAAF,KAAA,CAAMlB,QAAwB,gBAAA,CAAA;EAC5D;EAEA,MAAMqB,IAAIC,SAAAA,CAAAA,MAAO,CAAA;IACfd,QAAQU,KAAM,CAAAV,MAAA;IACdR,UAAUmB,WAAY,CAAAnB;EAAA,CACvB,CAAA;EACD,OAAOI,cAAe,CAAAiB,CAAA,EAAGF,WAAY,CAAAzB,MAAA,EAAQY,OAAO,CAAA;AACtD,CAAA;;;"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { toFormat,
|
|
2
|
-
import {
|
|
3
|
-
import { localizedCurrencyLookup, prettifyPriceLookup, Round } from './constants.mjs';
|
|
4
|
-
import { getDinero, roundDinero } from './misc.mjs';
|
|
1
|
+
import { toFormat, dinero } from 'dinero.js';
|
|
2
|
+
import { currencyObjLookup } from './constants.mjs';
|
|
5
3
|
"use strict";
|
|
6
|
-
const
|
|
7
|
-
return currencyCode ?
|
|
4
|
+
const getCurrencyObj = currencyCode => {
|
|
5
|
+
return currencyCode ? currencyObjLookup.get(currencyCode) : void 0;
|
|
8
6
|
};
|
|
9
7
|
const currencyFormatterCache = /* @__PURE__ */new Map();
|
|
10
8
|
const getCurrencyFormatter = (locale, currencyCode) => {
|
|
@@ -17,7 +15,7 @@ const getCurrencyFormatter = (locale, currencyCode) => {
|
|
|
17
15
|
style: "currency",
|
|
18
16
|
currency: currencyCode,
|
|
19
17
|
/**
|
|
20
|
-
* Explicitly define default
|
|
18
|
+
* Explicitly define default behaviour - just in case some runtime overrides it
|
|
21
19
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign
|
|
22
20
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay
|
|
23
21
|
*/
|
|
@@ -27,8 +25,8 @@ const getCurrencyFormatter = (locale, currencyCode) => {
|
|
|
27
25
|
currencyFormatterCache.set(cacheKey, formatter);
|
|
28
26
|
return formatter;
|
|
29
27
|
};
|
|
30
|
-
function formatPriceRaw(
|
|
31
|
-
return toFormat(
|
|
28
|
+
function formatPriceRaw(dineroObject, locale, options) {
|
|
29
|
+
return toFormat(dineroObject, ({
|
|
32
30
|
amount,
|
|
33
31
|
currency
|
|
34
32
|
}) => {
|
|
@@ -51,20 +49,15 @@ function formatPriceRaw(dinero, locale, options) {
|
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
const formatPrice = (money, options) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
const prettifyTotal = total => {
|
|
59
|
-
if (!hasSubUnits(total)) {
|
|
60
|
-
return total;
|
|
61
|
-
}
|
|
62
|
-
const totalJson = total.toJSON();
|
|
63
|
-
const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(totalJson.currency.code);
|
|
64
|
-
if (minValueInclusiveToRoundDownFrom == null || toUnit(total) < minValueInclusiveToRoundDownFrom) {
|
|
65
|
-
return total;
|
|
52
|
+
const currencyObj = getCurrencyObj(money.currency);
|
|
53
|
+
if (!currencyObj) {
|
|
54
|
+
throw new Error(`Currency ${money.currency} not supported`);
|
|
66
55
|
}
|
|
67
|
-
|
|
56
|
+
const d = dinero({
|
|
57
|
+
amount: money.amount,
|
|
58
|
+
currency: currencyObj.currency
|
|
59
|
+
});
|
|
60
|
+
return formatPriceRaw(d, currencyObj.locale, options);
|
|
68
61
|
};
|
|
69
|
-
export { formatPrice, formatPriceRaw,
|
|
62
|
+
export { formatPrice, formatPriceRaw, getCurrencyObj };
|
|
70
63
|
//# sourceMappingURL=format.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { dinero, toFormat } from \"dinero.js\";\nimport type { Dinero } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { currencyObjLookup } from \"./constants\";\nimport type { Money } from \"./misc\";\nimport type { CurrencyObj } from \"./types\";\n\nexport const getCurrencyObj = (\n currencyCode: Nullish<Currency>,\n): CurrencyObj | undefined => {\n return currencyCode ? currencyObjLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behaviour - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dineroObject: Dinero<number>,\n locale: string,\n options?: FormatPriceOptions,\n) {\n return toFormat(dineroObject, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const currencyObj = getCurrencyObj(money.currency);\n\n if (!currencyObj) {\n throw new Error(`Currency ${money.currency} not supported`);\n }\n\n const d = dinero({\n amount: money.amount,\n currency: currencyObj.currency,\n });\n return formatPriceRaw(d, currencyObj.locale, options);\n};\n"],"names":["getCurrencyObj","currencyCode","currencyObjLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dineroObject","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","currencyObj","Error","d","dinero"],"mappings":";;;AAQa,MAAAA,cAAA,GACXC,YAC4B,IAAA;EAC5B,OAAOA,YAAe,GAAAC,iBAAA,CAAkBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AAC9D,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EACtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;AAAA;AAAA;AAAA;AAAA;IAMVa,YAAc,EAAA,UAAA;IACdC,eAAiB,EAAA;EAAA,CAClB,CAAA;EACsBX,sBAAA,CAAAY,GAAA,CAAIR,UAAUC,SAAS,CAAA;EAEvC,OAAAA,SAAA;AACT,CAAA;AAkCgB,SAAAQ,cAAAA,CACdC,YACA,EAAAX,MAAA,EACAY,OACA,EAAA;EACA,OAAOC,SAASF,YAAc,EAAA,CAAC;IAAEG,MAAA;IAAQR;GAAe,KAAA;IACtD,MAAMJ,SAAY,GAAAH,oBAAA,CAAqBC,MAAQ,EAAAM,QAAA,CAASS,IAAI,CAAA;IACtD,MAAAC,SAAA,GAAYd,SAAU,CAAAe,MAAA,CAAOH,MAAM,CAAA;IAElC,OAAAF,OAAA,EAASM,mBAAmBN,OAAS,EAAAO,mBAAA;IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;IAQxCH,SAAU,CAAAI,OAAA;IAAA;IAER,IAAIC,MAAA,CACF,UAAA;IAEET,SAASM,eAAkB,GAAA,KAAA,GAAQ,CACrC,MAAMZ,SAASgB,QAAQ,aACzB,CAAA;IAAA;IAEA,IACF,CAAA,IACAN,SAAA;EAAA,CACL,CAAA;AACH;AAOa,MAAAO,WAAA,GAAcA,CACzBC,KAAA,EACAZ,OACW,KAAA;EACL,MAAAa,WAAA,GAAchC,cAAe,CAAA+B,KAAA,CAAMlB,QAAQ,CAAA;EAEjD,IAAI,CAACmB,WAAa,EAAA;IAChB,MAAM,IAAIC,KAAA,CAAkB,YAAAF,KAAA,CAAMlB,QAAwB,gBAAA,CAAA;EAC5D;EAEA,MAAMqB,IAAIC,MAAO,CAAA;IACfd,QAAQU,KAAM,CAAAV,MAAA;IACdR,UAAUmB,WAAY,CAAAnB;EAAA,CACvB,CAAA;EACD,OAAOI,cAAe,CAAAiB,CAAA,EAAGF,WAAY,CAAAzB,MAAA,EAAQY,OAAO,CAAA;AACtD,CAAA;"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export * as Allocators from "./allocators";
|
|
2
1
|
export * from "./constants";
|
|
3
|
-
export * from "./exchangeRate";
|
|
4
2
|
export * from "./format";
|
|
5
3
|
export * from "./misc";
|
|
6
|
-
export * from "./shipping";
|
|
7
|
-
export * from "./tax";
|
|
8
4
|
export * from "./types";
|
|
5
|
+
export * from "./tax";
|
package/lib/utils/money/index.js
CHANGED
|
@@ -1,51 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./allocators/index.js');
|
|
4
3
|
var constants = require('./constants.js');
|
|
5
|
-
var exchangeRate = require('./exchangeRate.js');
|
|
6
4
|
var format = require('./format.js');
|
|
7
5
|
var misc = require('./misc.js');
|
|
8
|
-
var shipping = require('./shipping.js');
|
|
9
|
-
var tax = require('./tax.js');
|
|
10
6
|
require('./types.js');
|
|
7
|
+
var tax = require('./tax.js');
|
|
11
8
|
"use strict";
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.TAX_RATE_DINERO_CURRENCY = constants.TAX_RATE_DINERO_CURRENCY;
|
|
16
|
-
exports.localizedCurrencyLookup = constants.localizedCurrencyLookup;
|
|
9
|
+
exports.currencyObjLookup = constants.currencyObjLookup;
|
|
10
|
+
exports.financialRound = constants.financialRound;
|
|
11
|
+
exports.maximumPriceFilterLookup = constants.maximumPriceFilterLookup;
|
|
17
12
|
exports.prettifyPriceLookup = constants.prettifyPriceLookup;
|
|
18
13
|
exports.smallestSubunitLookup = constants.smallestSubunitLookup;
|
|
19
|
-
exports.storesWithPerItemTaxRate = constants.storesWithPerItemTaxRate;
|
|
20
|
-
exports.invertExchangeRate = exchangeRate.invertExchangeRate;
|
|
21
|
-
exports.toFixedExchangeRate = exchangeRate.toFixedExchangeRate;
|
|
22
|
-
exports.toSnapshotExchangeRate = exchangeRate.toSnapshotExchangeRate;
|
|
23
14
|
exports.formatPrice = format.formatPrice;
|
|
24
15
|
exports.formatPriceRaw = format.formatPriceRaw;
|
|
25
|
-
exports.
|
|
26
|
-
exports.prettifyTotal = format.prettifyTotal;
|
|
16
|
+
exports.getCurrencyObj = format.getCurrencyObj;
|
|
27
17
|
exports.addMany = misc.addMany;
|
|
28
18
|
exports.amount = misc.amount;
|
|
29
|
-
exports.
|
|
19
|
+
exports.centsToMajorUnits = misc.centsToMajorUnits;
|
|
30
20
|
exports.currency = misc.currency;
|
|
31
|
-
exports.dineroToCurrencyUnit = misc.dineroToCurrencyUnit;
|
|
32
21
|
exports.getDinero = misc.getDinero;
|
|
33
22
|
exports.getDineroCurrency = misc.getDineroCurrency;
|
|
34
23
|
exports.money = misc.money;
|
|
35
24
|
exports.multiplyByFullPercent = misc.multiplyByFullPercent;
|
|
36
25
|
exports.parseCurrencyCode = misc.parseCurrencyCode;
|
|
37
26
|
exports.parseFloatToDinero = misc.parseFloatToDinero;
|
|
38
|
-
exports.
|
|
39
|
-
exports.roundDinero = misc.roundDinero;
|
|
27
|
+
exports.prettifyTotal = misc.prettifyTotal;
|
|
40
28
|
exports.stringAmountToDinero = misc.stringAmountToDinero;
|
|
41
29
|
exports.subtractMany = misc.subtractMany;
|
|
42
30
|
exports.toSmallestSubunit = misc.toSmallestSubunit;
|
|
43
|
-
exports.
|
|
44
|
-
exports.calculateLineItemTax = tax.calculateLineItemTax;
|
|
45
|
-
exports.calculateTotalTaxRate = tax.calculateTotalTaxRate;
|
|
46
|
-
exports.convertDecimalTaxRateToPercentage = tax.convertDecimalTaxRateToPercentage;
|
|
47
|
-
exports.decimalTaxRateToDinero = tax.decimalTaxRateToDinero;
|
|
48
|
-
exports.formatDecimalTaxRate = tax.formatDecimalTaxRate;
|
|
31
|
+
exports.allocateTaxAmount = tax.allocateTaxAmount;
|
|
49
32
|
exports.removeTaxAmount = tax.removeTaxAmount;
|
|
50
|
-
exports.stringTaxRateToFloat = tax.stringTaxRateToFloat;
|
|
51
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate } from './exchangeRate.mjs';
|
|
5
|
-
export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal } from './format.mjs';
|
|
6
|
-
export { addMany, amount, centsToCurrencyUnit, currency, dineroToCurrencyUnit, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, parseFloatToDineroRaw, roundDinero, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
|
|
7
|
-
export { roundShippingPrice } from './shipping.mjs';
|
|
8
|
-
export { calculateLineItemTax, calculateTotalTaxRate, convertDecimalTaxRateToPercentage, decimalTaxRateToDinero, formatDecimalTaxRate, removeTaxAmount, stringTaxRateToFloat } from './tax.mjs';
|
|
1
|
+
export { currencyObjLookup, financialRound, maximumPriceFilterLookup, prettifyPriceLookup, smallestSubunitLookup } from './constants.mjs';
|
|
2
|
+
export { formatPrice, formatPriceRaw, getCurrencyObj } from './format.mjs';
|
|
3
|
+
export { addMany, amount, centsToMajorUnits, currency, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, prettifyTotal, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
|
|
9
4
|
import './types.mjs';
|
|
5
|
+
export { allocateTaxAmount, removeTaxAmount } from './tax.mjs';
|
|
10
6
|
"use strict";
|
|
11
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,72 +1,53 @@
|
|
|
1
|
+
import type { Dinero, Currency as DineroCurrency } from "dinero.js";
|
|
1
2
|
import { Currency } from "../../types";
|
|
2
|
-
|
|
3
|
+
export interface Money {
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: Currency;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Prettify numbers depending on the currency using rounding down.
|
|
9
|
+
* ! Should only be used to prettify storefront product prices after currency conversion but nothing else !
|
|
10
|
+
*/
|
|
11
|
+
export declare const prettifyTotal: (total: Dinero<number>) => Dinero<number>;
|
|
3
12
|
/**
|
|
4
13
|
* Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.
|
|
5
14
|
* This util rounds down any unused subunits to closest subunit resolution.
|
|
6
15
|
*
|
|
7
16
|
* ! Not to be confused with prettifyTotal
|
|
8
17
|
*/
|
|
9
|
-
export declare const toSmallestSubunit: (total:
|
|
18
|
+
export declare const toSmallestSubunit: (total: Dinero<number>) => Dinero<number>;
|
|
10
19
|
/**
|
|
11
20
|
* Find Dinero.js currency instance from our Currency enum.
|
|
12
21
|
* @throws Throws an error if currency is not found!
|
|
13
|
-
*
|
|
14
22
|
* @example
|
|
15
23
|
* getDineroCurrency(Currency.Usd); // => Dinero.js currency instance
|
|
16
24
|
* getDineroCurrency("invalid"); // => throws AssertionError
|
|
17
25
|
*/
|
|
18
|
-
export declare const getDineroCurrency: (currency: Currency) =>
|
|
26
|
+
export declare const getDineroCurrency: (currency: Currency) => DineroCurrency<number>;
|
|
19
27
|
/**
|
|
20
|
-
* Convert Dinero currency
|
|
21
|
-
* @throws Throws an error if currency is not found!
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* parseCurrencyCode('usd') // Currency.Usd
|
|
25
|
-
* parseCurrencyCode('JPY') // Currency.Jpy
|
|
26
|
-
* parseCurrencyCode('invalid') // throws AssertionError
|
|
28
|
+
* Convert Dinero currency to local currency type
|
|
27
29
|
*/
|
|
28
30
|
export declare const parseCurrencyCode: (code: string) => Currency;
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* centsToCurrencyUnit(100, "USD") // 1
|
|
34
|
-
* centsToCurrencyUnit(1, "USD") // 0.01
|
|
35
|
-
* centsToCurrencyUnit(420, "USD") // 4.2
|
|
36
|
-
* centsToCurrencyUnit(420, "JPY") // 420
|
|
37
|
-
* FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input
|
|
38
|
-
*/
|
|
39
|
-
export declare const centsToCurrencyUnit: (centsAmount: Cents, currency: Currency) => number;
|
|
40
|
-
/**
|
|
41
|
-
* Utility to quickly convert dinero instance to a to currency amount number
|
|
32
|
+
* Get major units amount for cents amount and currency
|
|
42
33
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2
|
|
34
|
+
* Can look into the approach of dinero core toUnits if we need a more robust approach
|
|
35
|
+
* https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/api/toUnits.ts
|
|
36
|
+
* Though, based on experimentation, it's a basic division in the end regardless
|
|
47
37
|
*/
|
|
48
|
-
export declare const
|
|
38
|
+
export declare const centsToMajorUnits: (amount: number, currency: Currency) => number;
|
|
49
39
|
/**
|
|
50
|
-
* Parse arbitrary float amount in a given currency to a dinero object
|
|
51
|
-
* Wrapper around `parseFloatToDineroRaw` for easier usage.
|
|
40
|
+
* Parse arbitrary float amount in a given currency to a dinero object
|
|
52
41
|
*
|
|
53
42
|
* Doesn't work on string float amounts!
|
|
54
43
|
* @example
|
|
55
44
|
* parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance
|
|
56
45
|
*/
|
|
57
|
-
export declare const parseFloatToDinero: (floatAmount: number, currency: Currency) =>
|
|
58
|
-
/**
|
|
59
|
-
* Parse arbitrary float amount in a given dinero like currency object to a dinero object.
|
|
60
|
-
* ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)
|
|
61
|
-
*/
|
|
62
|
-
export declare const parseFloatToDineroRaw: (floatAmount: number, dineroCurrency: DinoCurrency) => import("dinero.js").Dinero<number>;
|
|
46
|
+
export declare const parseFloatToDinero: (floatAmount: number, currency: Currency) => Dinero<number>;
|
|
63
47
|
/**
|
|
64
48
|
* Shorthand for dinero constructor
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)
|
|
68
49
|
*/
|
|
69
|
-
export declare const getDinero: (amount:
|
|
50
|
+
export declare const getDinero: (amount: number, currency: Currency) => Dinero<number>;
|
|
70
51
|
/**
|
|
71
52
|
* Shorthand to get amount from dinero instance
|
|
72
53
|
*
|
|
@@ -77,11 +58,8 @@ export declare const getDinero: (amount: Cents, currency: Currency) => Dino;
|
|
|
77
58
|
*
|
|
78
59
|
* We should call something like: transformScale(d, currency.exponent)
|
|
79
60
|
* @see https://v2.dinerojs.com/docs/api/conversions/transform-scale
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* amount(getDinero(100, Currency.Usd)); // 100
|
|
83
61
|
*/
|
|
84
|
-
export declare const amount: (dinero:
|
|
62
|
+
export declare const amount: (dinero: Dinero<number>) => number;
|
|
85
63
|
/**
|
|
86
64
|
* Method to multiply dinero amount by full percent.
|
|
87
65
|
* It also transforms scale back to currency exponent.
|
|
@@ -90,42 +68,24 @@ export declare const amount: (dinero: Dino) => Cents;
|
|
|
90
68
|
* Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because
|
|
91
69
|
* of dinero version we do not control rounding
|
|
92
70
|
*/
|
|
93
|
-
export declare const multiplyByFullPercent: (dinero:
|
|
71
|
+
export declare const multiplyByFullPercent: (dinero: Dinero<number>, percentIncrease: number) => Dinero<number>;
|
|
94
72
|
/**
|
|
95
73
|
* Shorthand to get currency from dinero instance
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* currency(getDinero(100, Currency.Usd)); // Currency.Usd
|
|
99
74
|
*/
|
|
100
|
-
export declare const currency: (dinero:
|
|
75
|
+
export declare const currency: (dinero: Dinero<number>) => Currency;
|
|
101
76
|
/**
|
|
102
77
|
* Shorthand to get our GraphQL Money type from dinero instance
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }
|
|
106
78
|
*/
|
|
107
|
-
export declare const money: (dinero:
|
|
79
|
+
export declare const money: (dinero: Dinero<number>) => Money;
|
|
108
80
|
/**
|
|
109
81
|
* Helper to quickly add multiple dinero instances with same currency
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)
|
|
113
82
|
*/
|
|
114
|
-
export declare const addMany: (addends: Array<
|
|
83
|
+
export declare const addMany: (addends: Array<Dinero<number>>, defaultCurrency: Currency) => Dinero<number>;
|
|
115
84
|
/**
|
|
116
85
|
* Helper to quickly subtract multiple dinero instances with same currency
|
|
117
86
|
*/
|
|
118
|
-
export declare const subtractMany: (subtractions: Array<
|
|
87
|
+
export declare const subtractMany: (subtractions: Array<Dinero<number>>, defaultCurrency: Currency) => Dinero<number>;
|
|
119
88
|
/**
|
|
120
89
|
* Helper to quickly get dinero object from string
|
|
121
90
|
*/
|
|
122
|
-
export declare const stringAmountToDinero: (price: string, currency: Currency) =>
|
|
123
|
-
/**
|
|
124
|
-
* Helper to quickly round dinero object to closest integer by a given rounding function
|
|
125
|
-
* FIXME: add tests
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)
|
|
129
|
-
* roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)
|
|
130
|
-
*/
|
|
131
|
-
export declare const roundDinero: (dinero: Dino, roundingFn: RoundingFn) => Dino;
|
|
91
|
+
export declare const stringAmountToDinero: (price: string, currency: Currency) => Dinero<number>;
|
package/lib/utils/money/misc.js
CHANGED
|
@@ -1,14 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var currencies = require('@dinero.js/currencies');
|
|
3
4
|
var dinero_js = require('dinero.js');
|
|
4
5
|
require('../../types/index.js');
|
|
5
6
|
var errors = require('../errors.js');
|
|
6
7
|
var number = require('../number.js');
|
|
7
8
|
var string = require('../string.js');
|
|
9
|
+
var validations = require('../validations.js');
|
|
8
10
|
var constants = require('./constants.js');
|
|
9
|
-
var misc_private = require('./misc.private.js');
|
|
10
11
|
var generated = require('../../types/generated.js');
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return e[k];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n["default"] = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
var currencies__namespace = /*#__PURE__*/_interopNamespace(currencies);
|
|
11
32
|
"use strict";
|
|
33
|
+
const currencyLookup = new Set(Object.keys(generated.Currency).map(el => el.toString()));
|
|
34
|
+
const currenciesMap = new Map(Object.values(currencies__namespace).map(currency2 => [currency2.code, currency2]));
|
|
35
|
+
const floatToInt = (floatAmount, base, exponent) => constants.financialRound(floatAmount * Math.pow(base, exponent));
|
|
36
|
+
const prettifyTotal = total => {
|
|
37
|
+
if (!dinero_js.hasSubUnits(total)) {
|
|
38
|
+
return total;
|
|
39
|
+
}
|
|
40
|
+
const totalJson = total.toJSON();
|
|
41
|
+
const minValueInclusiveToRoundDownFrom = constants.prettifyPriceLookup.get(totalJson.currency.code);
|
|
42
|
+
if (minValueInclusiveToRoundDownFrom == null || dinero_js.toUnit(total) < minValueInclusiveToRoundDownFrom) {
|
|
43
|
+
return total;
|
|
44
|
+
}
|
|
45
|
+
const roundedUnitPrice = dinero_js.toUnit(total, {
|
|
46
|
+
digits: 0,
|
|
47
|
+
round: dinero_js.down
|
|
48
|
+
});
|
|
49
|
+
return dinero_js.dinero({
|
|
50
|
+
amount: roundedUnitPrice * Math.pow(totalJson.currency.base, totalJson.currency.exponent),
|
|
51
|
+
currency: totalJson.currency
|
|
52
|
+
});
|
|
53
|
+
};
|
|
12
54
|
const toSmallestSubunit = total => {
|
|
13
55
|
if (!dinero_js.hasSubUnits(total)) {
|
|
14
56
|
return total;
|
|
@@ -18,47 +60,49 @@ const toSmallestSubunit = total => {
|
|
|
18
60
|
if (roundToDigits == null || roundingMode == null) {
|
|
19
61
|
return total;
|
|
20
62
|
}
|
|
21
|
-
|
|
63
|
+
const roundedUnitPrice = dinero_js.toUnit(total, {
|
|
64
|
+
digits: roundToDigits,
|
|
65
|
+
round: roundingMode
|
|
66
|
+
});
|
|
67
|
+
return dinero_js.dinero({
|
|
68
|
+
amount: roundedUnitPrice * Math.pow(totalJson.currency.base, totalJson.currency.exponent),
|
|
69
|
+
currency: totalJson.currency
|
|
70
|
+
});
|
|
22
71
|
};
|
|
23
72
|
const getDineroCurrency = currency2 => {
|
|
24
|
-
const dineroCurrency =
|
|
73
|
+
const dineroCurrency = currenciesMap.get(currency2);
|
|
25
74
|
errors.assert(!!dineroCurrency, `Unsupported currency: "${currency2}"`);
|
|
26
75
|
return dineroCurrency;
|
|
27
76
|
};
|
|
28
77
|
const parseCurrencyCode = code => {
|
|
29
78
|
const normalizedCode = string.capitalize(code.toLowerCase());
|
|
30
|
-
errors.assert(
|
|
79
|
+
errors.assert(currencyLookup.has(normalizedCode), `Invalid currency code: ${normalizedCode}`);
|
|
31
80
|
return generated.Currency[normalizedCode];
|
|
32
81
|
};
|
|
33
|
-
const
|
|
82
|
+
const centsToMajorUnits = (amount2, currency2) => {
|
|
34
83
|
const dineroCurrency = getDineroCurrency(currency2);
|
|
35
|
-
const
|
|
36
|
-
amount:
|
|
84
|
+
const price = dinero_js.dinero({
|
|
85
|
+
amount: amount2,
|
|
37
86
|
currency: dineroCurrency
|
|
38
87
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const dineroToCurrencyUnit = dineroObj => {
|
|
42
|
-
return dinero_js.toUnit(dineroObj);
|
|
88
|
+
const divider = Math.pow(10, dineroCurrency.exponent);
|
|
89
|
+
return dinero_js.toSnapshot(price).amount / divider;
|
|
43
90
|
};
|
|
44
91
|
const parseFloatToDinero = (floatAmount, currency2) => {
|
|
45
|
-
const dineroCurrency = getDineroCurrency(currency2);
|
|
46
|
-
return parseFloatToDineroRaw(floatAmount, dineroCurrency);
|
|
47
|
-
};
|
|
48
|
-
const parseFloatToDineroRaw = (floatAmount, dineroCurrency) => {
|
|
49
92
|
number.isFloat(floatAmount, "Amount");
|
|
93
|
+
const dineroCurrency = getDineroCurrency(currency2);
|
|
50
94
|
const scaleOfGivenAmount = String(floatAmount).split(".")[1]?.length ?? dineroCurrency.exponent;
|
|
51
95
|
if (scaleOfGivenAmount == null || scaleOfGivenAmount > dineroCurrency.exponent) {
|
|
52
96
|
throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);
|
|
53
97
|
}
|
|
54
|
-
const rateInt =
|
|
98
|
+
const rateInt = floatToInt(floatAmount, dineroCurrency.base, dineroCurrency.exponent);
|
|
55
99
|
return dinero_js.dinero({
|
|
56
100
|
amount: rateInt,
|
|
57
101
|
currency: dineroCurrency
|
|
58
102
|
});
|
|
59
103
|
};
|
|
60
104
|
const getDinero = (amount2, currency2) => {
|
|
61
|
-
|
|
105
|
+
validations.isInt(amount2, "Amount");
|
|
62
106
|
return dinero_js.dinero({
|
|
63
107
|
amount: amount2,
|
|
64
108
|
currency: getDineroCurrency(currency2)
|
|
@@ -90,33 +134,18 @@ const money = dinero2 => {
|
|
|
90
134
|
};
|
|
91
135
|
const addMany = (addends, defaultCurrency) => [...addends, getDinero(0, defaultCurrency)].reduce(dinero_js.add);
|
|
92
136
|
const subtractMany = (subtractions, defaultCurrency) => [...subtractions, getDinero(0, defaultCurrency)].reduce(dinero_js.subtract);
|
|
93
|
-
const stringAmountToDinero = (price, currency2) =>
|
|
94
|
-
// FIXME: parseFloat seems dangerous O_O
|
|
95
|
-
parseFloatToDinero(parseFloat(price), currency2);
|
|
96
|
-
const roundDinero = (dinero2, roundingFn) => {
|
|
97
|
-
const roundedUnitPrice = dinero_js.toUnit(dinero2, {
|
|
98
|
-
digits: 0,
|
|
99
|
-
round: roundingFn
|
|
100
|
-
});
|
|
101
|
-
const snapshot = dinero_js.toSnapshot(dinero2);
|
|
102
|
-
return dinero2.create({
|
|
103
|
-
amount: roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,
|
|
104
|
-
currency: snapshot.currency
|
|
105
|
-
});
|
|
106
|
-
};
|
|
137
|
+
const stringAmountToDinero = (price, currency2) => parseFloatToDinero(parseFloat(price), currency2);
|
|
107
138
|
exports.addMany = addMany;
|
|
108
139
|
exports.amount = amount;
|
|
109
|
-
exports.
|
|
140
|
+
exports.centsToMajorUnits = centsToMajorUnits;
|
|
110
141
|
exports.currency = currency;
|
|
111
|
-
exports.dineroToCurrencyUnit = dineroToCurrencyUnit;
|
|
112
142
|
exports.getDinero = getDinero;
|
|
113
143
|
exports.getDineroCurrency = getDineroCurrency;
|
|
114
144
|
exports.money = money;
|
|
115
145
|
exports.multiplyByFullPercent = multiplyByFullPercent;
|
|
116
146
|
exports.parseCurrencyCode = parseCurrencyCode;
|
|
117
147
|
exports.parseFloatToDinero = parseFloatToDinero;
|
|
118
|
-
exports.
|
|
119
|
-
exports.roundDinero = roundDinero;
|
|
148
|
+
exports.prettifyTotal = prettifyTotal;
|
|
120
149
|
exports.stringAmountToDinero = stringAmountToDinero;
|
|
121
150
|
exports.subtractMany = subtractMany;
|
|
122
151
|
exports.toSmallestSubunit = toSmallestSubunit;
|