@ubnt/store.core 9.4.0-prealpha.2 → 9.5.0-money.4
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 +16 -0
- package/lib/_virtual/_virtual_multi-entry.js +40 -46
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +40 -46
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/assets/digital-signage-mode.svg +7 -0
- package/lib/assets/gps.svg +10 -0
- package/lib/assets/hdmi2.svg +10 -0
- package/lib/assets/industrial.jpg +0 -0
- package/lib/assets/mobileRouting.svg +3 -0
- package/lib/assets/mounting2.svg +13 -0
- package/lib/assets/ucCast.jpg +0 -0
- package/lib/assets/ucCastPro.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/assets/umr-industrial.jpg +0 -0
- package/lib/assets/umr.jpg +0 -0
- package/lib/assets/usb-c.svg +10 -0
- package/lib/assets/video2.svg +3 -0
- package/lib/assets/youtube2.svg +3 -0
- package/lib/components/Header/AccountMenu/AccountMenu.js +3 -3
- package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.mjs +2 -2
- package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
- package/lib/components/Header/Header.js +9 -9
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/Header.mjs +6 -6
- package/lib/components/Header/Header.mjs.map +1 -1
- package/lib/components/Header/IsolatedHeader.js +3 -3
- package/lib/components/Header/IsolatedHeader.js.map +1 -1
- package/lib/components/Header/IsolatedHeader.mjs +2 -2
- package/lib/components/Header/IsolatedHeader.mjs.map +1 -1
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js +5 -7
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js.map +1 -1
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs +5 -7
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.js +6 -6
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +4 -4
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.js +4 -4
- package/lib/components/LandingPage/Cards/Cards.js.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.mjs +3 -3
- package/lib/components/LandingPage/Cards/Cards.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.d.ts +3 -0
- 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/MicrositeMediaGrid/MicrositeMediaGrid.js +1 -0
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.js.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.mjs +1 -0
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.mjs.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.d.ts +1 -0
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.js +13 -5
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.js.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.mjs +13 -5
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.mjs.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.types.d.ts +1 -0
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.types.js.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.types.mjs.map +1 -1
- package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.types.d.ts +1 -1
- package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.types.d.ts +1 -1
- package/lib/components/MobileModal/MobileModal.js +1 -1
- package/lib/components/MobileModal/MobileModal.js.map +1 -1
- package/lib/components/MobileModal/MobileModal.mjs +1 -1
- package/lib/components/MobileModal/MobileModal.mjs.map +1 -1
- package/lib/{assets/icons → components/MobileModal/assets}/arrowDown.svg.js +1 -1
- package/lib/components/MobileModal/assets/arrowDown.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/ModelCompareV3.js +11 -4
- package/lib/components/ModelCompareV3/ModelCompareV3.js.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.mjs +11 -4
- package/lib/components/ModelCompareV3/ModelCompareV3.mjs.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +23 -12
- 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/assets/{WiFi/flagship.jpg.js → DisplayCast/ucCast.jpg.js} +2 -2
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCast.jpg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCast.jpg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCast.jpg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/{WiFi/mega-capacity.jpg.js → DisplayCast/ucCastPro.jpg.js} +2 -2
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCastPro.jpg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCastPro.jpg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/DisplayCast/ucCastPro.jpg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/{WiFi/flexible-outdoor.jpg.js → MobileRouters/umr-industrial.jpg.js} +2 -2
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr-industrial.jpg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr-industrial.jpg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr-industrial.jpg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/{WiFi/wall.jpg.js → MobileRouters/umr.jpg.js} +2 -2
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/digital-signage-mode.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/digital-signage-mode.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/digital-signage-mode.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/digital-signage-mode.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/gps.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/gps.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/gps.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/gps.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/hdmi.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/hdmi.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/hdmi.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/hdmi.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/mounting.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/mounting.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/mounting.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/mounting.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/usb-c.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/usb-c.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/usb-c.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/usb-c.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/video.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/video.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/video.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/video.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/assets/youtube.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/youtube.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/youtube.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/youtube.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/CloudGateways.js +9 -9
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +6 -6
- package/lib/components/ModelCompareV3/data/{WiFi.d.ts → DisplayCast.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/DisplayCast.js +23 -0
- package/lib/components/ModelCompareV3/data/DisplayCast.js.map +1 -0
- package/lib/components/ModelCompareV3/data/DisplayCast.mjs +21 -0
- package/lib/components/ModelCompareV3/data/DisplayCast.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/MobileRouters.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/MobileRouters.js +35 -0
- package/lib/components/ModelCompareV3/data/MobileRouters.js.map +1 -0
- package/lib/components/ModelCompareV3/data/MobileRouters.mjs +27 -0
- package/lib/components/ModelCompareV3/data/MobileRouters.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/index.d.ts +24 -23
- package/lib/components/ModelCompareV3/data/index.js +50 -47
- package/lib/components/ModelCompareV3/data/index.js.map +1 -1
- package/lib/components/ModelCompareV3/data/index.mjs +50 -47
- package/lib/components/ModelCompareV3/data/index.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/industrial.js +1 -1
- package/lib/components/ModelCompareV3/data/products/industrial.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/{wifiWall.d.ts → ucCast.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCast.js +89 -0
- package/lib/components/ModelCompareV3/data/products/ucCast.js.map +1 -0
- package/lib/components/ModelCompareV3/data/products/ucCast.mjs +81 -0
- package/lib/components/ModelCompareV3/data/products/ucCast.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/products/{wifiFlagship.d.ts → ucCastPro.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCastPro.js +90 -0
- package/lib/components/ModelCompareV3/data/products/ucCastPro.js.map +1 -0
- package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs +82 -0
- package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs.map +1 -0
- 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/ModelCompareV3/data/products/udw.js +0 -1
- package/lib/components/ModelCompareV3/data/products/udw.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udw.mjs +0 -1
- package/lib/components/ModelCompareV3/data/products/udw.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/{wifiMegaCapacity.d.ts → umr.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/products/umr.js +112 -0
- package/lib/components/ModelCompareV3/data/products/umr.js.map +1 -0
- package/lib/components/ModelCompareV3/data/products/umr.mjs +104 -0
- package/lib/components/ModelCompareV3/data/products/umr.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/products/{wifiFlexibleOutdoor.d.ts → umrIndustrial.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/products/umrIndustrial.js +109 -0
- package/lib/components/ModelCompareV3/data/products/umrIndustrial.js.map +1 -0
- package/lib/components/ModelCompareV3/data/products/umrIndustrial.mjs +101 -0
- package/lib/components/ModelCompareV3/data/products/umrIndustrial.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/carrierSupport.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/carrierSupport.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/carrierSupport.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/carrierSupport.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/carrierSupport.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/cellular.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/cellular.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/cellular.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/cellular.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/cellular.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/digitalSignageMode.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/digitalSignageMode.js +20 -0
- package/lib/components/ModelCompareV3/data/properties/digitalSignageMode.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/digitalSignageMode.mjs +12 -0
- package/lib/components/ModelCompareV3/data/properties/digitalSignageMode.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/gpsLocationTracking.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/gpsLocationTracking.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/gpsLocationTracking.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/gpsLocationTracking.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/gpsLocationTracking.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/hdmiCec.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/hdmiCec.js +20 -0
- package/lib/components/ModelCompareV3/data/properties/hdmiCec.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/hdmiCec.mjs +12 -0
- package/lib/components/ModelCompareV3/data/properties/hdmiCec.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/index.d.ts +9 -0
- package/lib/components/ModelCompareV3/data/properties/index.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.mjs +9 -0
- package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/usbCPeripheralSupport.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/usbCPeripheralSupport.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/usbCPeripheralSupport.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/usbCPeripheralSupport.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/usbCPeripheralSupport.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/videoContentSupport.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/videoContentSupport.js +19 -0
- package/lib/components/ModelCompareV3/data/properties/videoContentSupport.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/videoContentSupport.mjs +11 -0
- package/lib/components/ModelCompareV3/data/properties/videoContentSupport.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/webMode.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/webMode.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/webMode.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/webMode.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/webMode.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/wifi.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/wifi.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/wifi.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/wifi.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/wifi.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/youtubeMode.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/youtubeMode.js +20 -0
- package/lib/components/ModelCompareV3/data/properties/youtubeMode.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/youtubeMode.mjs +12 -0
- package/lib/components/ModelCompareV3/data/properties/youtubeMode.mjs.map +1 -0
- package/lib/components/ModelCompareV3/translations/ar.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/ar.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ar.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/ar.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/de.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/de.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/el.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/el.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.js +50 -63
- package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.mjs +50 -63
- package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/es.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/es.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/fr.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/fr.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/it.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/it.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/ja.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/ja.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +62 -6
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +62 -6
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/index.d.ts +0 -2
- package/lib/components/index.js +30 -34
- package/lib/components/index.js.map +1 -1
- package/lib/components/index.mjs +30 -34
- package/lib/components/index.mjs.map +1 -1
- package/lib/constants/icons/generic/carouselArrowRight.svg.js +5 -5
- package/lib/constants/icons/generic/index.js +3 -3
- package/lib/constants/icons/header/account.svg.js +5 -5
- package/lib/constants/icons/header/globe.svg.js +5 -5
- package/lib/constants/icons/header/index.js +9 -9
- package/lib/constants/icons/header/logoUnifi.svg.js +5 -5
- package/lib/constants/icons/menu/index.d.ts +1 -1
- package/lib/constants/icons/menu/index.js +9 -9
- package/lib/constants/icons/menu/index.mjs +2 -2
- package/lib/{components/BannerEasySteps/assets/play-outline.svg.js → constants/icons/menu/mobileRouting.svg.js} +6 -6
- package/lib/constants/icons/menu/mobileRouting.svg.js.map +1 -0
- package/lib/constants/icons/menu/mobileRouting.svg.mjs +3 -0
- package/lib/constants/icons/menu/mobileRouting.svg.mjs.map +1 -0
- package/lib/constants/icons/options/colors/black.svg.js +5 -5
- package/lib/constants/icons/options/colors/index.js +3 -3
- package/lib/constants/icons/options/styles/black.svg.js +5 -5
- package/lib/constants/icons/options/styles/index.js +3 -3
- package/lib/constants/optionIcons.js +6 -6
- package/lib/constants/optionIcons.mjs +4 -4
- package/lib/contexts/MenuContext/mapping.js +6 -4
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +5 -3
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/types.js.map +1 -1
- package/lib/contexts/MenuContext/types.mjs.map +1 -1
- package/lib/contexts/MenuContext/utils.d.ts +1 -6
- package/lib/contexts/MenuContext/utils.js +0 -16
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs +1 -16
- package/lib/contexts/MenuContext/utils.mjs.map +1 -1
- package/lib/contexts/index.d.ts +0 -1
- package/lib/contexts/index.js +0 -2
- package/lib/contexts/index.js.map +1 -1
- package/lib/contexts/index.mjs +0 -2
- package/lib/contexts/index.mjs.map +1 -1
- package/lib/utils/money/allocators/fixedAmount.d.ts +26 -0
- package/lib/utils/money/allocators/fixedAmount.js +55 -0
- package/lib/utils/money/allocators/fixedAmount.js.map +1 -0
- package/lib/utils/money/allocators/fixedAmount.mjs +53 -0
- package/lib/utils/money/allocators/fixedAmount.mjs.map +1 -0
- package/lib/utils/money/allocators/index.d.ts +1 -0
- package/lib/utils/money/allocators/index.js +6 -0
- package/lib/utils/money/allocators/index.mjs +3 -0
- package/lib/utils/money/constants.d.ts +56 -25
- package/lib/utils/money/constants.js +72 -7
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +70 -7
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/exchangeRate.d.ts +31 -0
- package/lib/utils/money/exchangeRate.js +27 -0
- package/lib/utils/money/exchangeRate.js.map +1 -0
- package/lib/utils/money/exchangeRate.mjs +23 -0
- package/lib/utils/money/exchangeRate.mjs.map +1 -0
- package/lib/utils/money/format.d.ts +10 -5
- package/lib/utils/money/format.js +22 -14
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +23 -16
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/index.d.ts +4 -1
- package/lib/utils/money/index.js +26 -8
- package/lib/utils/money/index.js.map +1 -1
- package/lib/utils/money/index.mjs +8 -4
- package/lib/utils/money/index.mjs.map +1 -1
- package/lib/utils/money/misc.d.ts +68 -28
- package/lib/utils/money/misc.js +35 -64
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs +32 -43
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/money/misc.private.d.ts +23 -0
- package/lib/utils/money/misc.private.js +46 -0
- package/lib/utils/money/misc.private.js.map +1 -0
- package/lib/utils/money/misc.private.mjs +21 -0
- package/lib/utils/money/misc.private.mjs.map +1 -0
- package/lib/utils/money/shipping.d.ts +5 -0
- package/lib/utils/money/shipping.js +8 -0
- package/lib/utils/money/shipping.js.map +1 -0
- package/lib/utils/money/shipping.mjs +6 -0
- package/lib/utils/money/shipping.mjs.map +1 -0
- package/lib/utils/money/tax.d.ts +38 -2
- package/lib/utils/money/tax.js +46 -10
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +42 -11
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/tax.private.d.ts +17 -0
- package/lib/utils/money/tax.private.js +65 -0
- package/lib/utils/money/tax.private.js.map +1 -0
- package/lib/utils/money/tax.private.mjs +60 -0
- package/lib/utils/money/tax.private.mjs.map +1 -0
- package/lib/utils/money/types.d.ts +64 -3
- 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/tax/index.d.ts +1 -1
- package/lib/utils/tax/index.js +8 -1
- package/lib/utils/tax/index.js.map +1 -1
- package/lib/utils/tax/index.mjs +8 -1
- package/lib/utils/tax/index.mjs.map +1 -1
- package/lib/utils/tax/types.d.ts +2 -1
- package/lib/utils/tax/types.js +1 -0
- package/lib/utils/tax/types.js.map +1 -1
- package/lib/utils/tax/types.mjs +1 -0
- package/lib/utils/tax/types.mjs.map +1 -1
- package/package.json +1 -1
- package/lib/assets/education.jpg +0 -0
- package/lib/assets/enterprise.jpg +0 -0
- package/lib/assets/flagship.jpg +0 -0
- package/lib/assets/flexible-outdoor.jpg +0 -0
- package/lib/assets/hospitality.jpg +0 -0
- package/lib/assets/how-it-works.jpg +0 -0
- package/lib/assets/icons/arrowDown.svg.mjs +0 -3
- package/lib/assets/industrial2.jpg +0 -0
- package/lib/assets/mega-capacity.jpg +0 -0
- package/lib/assets/nextai-camera.jpg +0 -0
- package/lib/assets/nextai-cyber.jpg +0 -0
- package/lib/assets/overview.svg +0 -3
- package/lib/assets/play-outline.svg +0 -3
- package/lib/assets/retail.jpg +0 -0
- package/lib/assets/sd-wan-sase.jpg +0 -0
- package/lib/assets/site-manager.jpg +0 -0
- package/lib/assets/stadium.jpg +0 -0
- package/lib/assets/tco-calculator.jpg +0 -0
- package/lib/assets/wall.jpg +0 -0
- package/lib/components/BannerEasySteps/BannerEasySteps.d.ts +0 -2
- package/lib/components/BannerEasySteps/BannerEasySteps.js +0 -74
- package/lib/components/BannerEasySteps/BannerEasySteps.js.map +0 -1
- package/lib/components/BannerEasySteps/BannerEasySteps.mjs +0 -66
- package/lib/components/BannerEasySteps/BannerEasySteps.mjs.map +0 -1
- package/lib/components/BannerEasySteps/BannerEasySteps.styles.d.ts +0 -13
- package/lib/components/BannerEasySteps/BannerEasySteps.styles.js +0 -127
- package/lib/components/BannerEasySteps/BannerEasySteps.styles.js.map +0 -1
- package/lib/components/BannerEasySteps/BannerEasySteps.styles.mjs +0 -114
- package/lib/components/BannerEasySteps/BannerEasySteps.styles.mjs.map +0 -1
- package/lib/components/BannerEasySteps/BannerEasySteps.types.d.ts +0 -15
- package/lib/components/BannerEasySteps/assets/play-outline.svg.js.map +0 -1
- package/lib/components/BannerEasySteps/assets/play-outline.svg.mjs +0 -3
- package/lib/components/BannerEasySteps/assets/play-outline.svg.mjs.map +0 -1
- package/lib/components/BannerEasySteps/index.d.ts +0 -1
- package/lib/components/BannerEasySteps/index.js +0 -6
- package/lib/components/BannerEasySteps/index.mjs +0 -3
- package/lib/components/MicrositeHeader/MicrositeHeader.d.ts +0 -2
- package/lib/components/MicrositeHeader/MicrositeHeader.js +0 -35
- package/lib/components/MicrositeHeader/MicrositeHeader.js.map +0 -1
- package/lib/components/MicrositeHeader/MicrositeHeader.mjs +0 -33
- package/lib/components/MicrositeHeader/MicrositeHeader.mjs.map +0 -1
- package/lib/components/MicrositeHeader/MicrositeHeader.styles.d.ts +0 -2
- package/lib/components/MicrositeHeader/MicrositeHeader.styles.js +0 -29
- package/lib/components/MicrositeHeader/MicrositeHeader.styles.js.map +0 -1
- package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs +0 -20
- package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs.map +0 -1
- package/lib/components/MicrositeHeader/MicrositeHeader.types.d.ts +0 -5
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.d.ts +0 -2
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js +0 -149
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js.map +0 -1
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs +0 -141
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.d.ts +0 -46
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js +0 -369
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js.map +0 -1
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs +0 -341
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.types.d.ts +0 -20
- package/lib/components/MicrositeHeader/components/DropdownMenu/index.d.ts +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.d.ts +0 -2
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js +0 -209
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js.map +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs +0 -198
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.d.ts +0 -22
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js +0 -148
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js.map +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs +0 -126
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.types.d.ts +0 -10
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.d.ts +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js +0 -6
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js.map +0 -1
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs +0 -3
- package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.d.ts +0 -2
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js +0 -71
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs +0 -69
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.d.ts +0 -13
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js +0 -104
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs +0 -89
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.types.d.ts +0 -11
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.d.ts +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js +0 -6
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js.map +0 -1
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs +0 -3
- package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs.map +0 -1
- package/lib/components/MicrositeHeader/index.d.ts +0 -1
- package/lib/components/MicrositeHeader/index.js +0 -6
- package/lib/components/MicrositeHeader/index.js.map +0 -1
- package/lib/components/MicrositeHeader/index.mjs +0 -3
- package/lib/components/MicrositeHeader/index.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/WiFi.js +0 -23
- package/lib/components/ModelCompareV3/data/WiFi.js.map +0 -1
- package/lib/components/ModelCompareV3/data/WiFi.mjs +0 -21
- package/lib/components/ModelCompareV3/data/WiFi.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiFlagship.js +0 -70
- package/lib/components/ModelCompareV3/data/products/wifiFlagship.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs +0 -62
- package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js +0 -73
- package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs +0 -65
- package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js +0 -73
- package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs +0 -65
- package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiWall.js +0 -74
- package/lib/components/ModelCompareV3/data/products/wifiWall.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/wifiWall.mjs +0 -66
- package/lib/components/ModelCompareV3/data/products/wifiWall.mjs.map +0 -1
- package/lib/constants/icons/menu/overview.svg.js +0 -27
- package/lib/constants/icons/menu/overview.svg.js.map +0 -1
- package/lib/constants/icons/menu/overview.svg.mjs +0 -3
- package/lib/constants/icons/menu/overview.svg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/index.d.ts +0 -12
- package/lib/contexts/MicrositeMenuContext/assets/index.js +0 -16
- package/lib/contexts/MicrositeMenuContext/assets/index.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/index.mjs +0 -14
- package/lib/contexts/MicrositeMenuContext/assets/index.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js +0 -27
- package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/context.d.ts +0 -37
- package/lib/contexts/MicrositeMenuContext/context.js +0 -137
- package/lib/contexts/MicrositeMenuContext/context.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/context.mjs +0 -113
- package/lib/contexts/MicrositeMenuContext/context.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/index.d.ts +0 -1
- package/lib/contexts/MicrositeMenuContext/index.js +0 -8
- package/lib/contexts/MicrositeMenuContext/index.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/index.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/index.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/mapping.d.ts +0 -4
- package/lib/contexts/MicrositeMenuContext/mapping.js +0 -547
- package/lib/contexts/MicrositeMenuContext/mapping.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/mapping.mjs +0 -499
- package/lib/contexts/MicrositeMenuContext/mapping.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/ar.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/ar.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/de.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/de.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/el.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/el.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/en.json.js +0 -81
- package/lib/contexts/MicrositeMenuContext/translations/en.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs +0 -76
- package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/es.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/es.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/fr.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/fr.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/it.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/it.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/ja.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/ja.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js +0 -8
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs +0 -3
- package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs.map +0 -1
- package/lib/contexts/MicrositeMenuContext/types.d.ts +0 -98
- package/lib/contexts/MicrositeMenuContext/types.js +0 -15
- package/lib/contexts/MicrositeMenuContext/types.js.map +0 -1
- package/lib/contexts/MicrositeMenuContext/types.mjs +0 -14
- package/lib/contexts/MicrositeMenuContext/types.mjs.map +0 -1
- package/lib/utils/validations.d.ts +0 -15
- package/lib/utils/validations.js +0 -23
- package/lib/utils/validations.js.map +0 -1
- package/lib/utils/validations.mjs +0 -21
- package/lib/utils/validations.mjs.map +0 -1
- /package/lib/{assets/icons → components/MobileModal/assets}/arrowDown.svg.js.map +0 -0
- /package/lib/{assets/icons → components/MobileModal/assets}/arrowDown.svg.mjs.map +0 -0
- /package/lib/{components/BannerEasySteps → utils/money/allocators}/index.js.map +0 -0
- /package/lib/{components/BannerEasySteps → utils/money/allocators}/index.mjs.map +0 -0
package/lib/utils/money/tax.mjs
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSnapshot, dinero, down, multiply, toUnit, halfEven } from 'dinero.js';
|
|
2
|
+
import { assert } from '../errors.mjs';
|
|
3
|
+
import { isFloat, toFixedRate } from '../number.mjs';
|
|
4
|
+
import { storesWithPerItemTaxRate, TAX_RATE_DINERO_CURRENCY } from './constants.mjs';
|
|
5
|
+
import { calculatePerQtyLineItemTax, calculateWholeQtyLineItemTax } from './tax.private.mjs';
|
|
2
6
|
"use strict";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return allocate(baseAmountObj, [rateInt, Math.pow(10, rateScale) - rateInt])[0];
|
|
7
|
+
const calculateLineItemTax = ({
|
|
8
|
+
itemSummary,
|
|
9
|
+
taxRate,
|
|
10
|
+
storeId
|
|
11
|
+
}) => {
|
|
12
|
+
return storesWithPerItemTaxRate.has(storeId) ? calculatePerQtyLineItemTax(itemSummary, taxRate) : calculateWholeQtyLineItemTax(itemSummary, taxRate);
|
|
10
13
|
};
|
|
11
|
-
const removeTaxAmount = (baseAmountWithTaxObj,
|
|
14
|
+
const removeTaxAmount = (baseAmountWithTaxObj, taxRate) => {
|
|
12
15
|
const snapshot = toSnapshot(baseAmountWithTaxObj);
|
|
13
16
|
return dinero({
|
|
14
17
|
...snapshot,
|
|
15
|
-
amount: down(snapshot.amount / (1 +
|
|
18
|
+
amount: down(snapshot.amount / (1 + taxRate))
|
|
16
19
|
});
|
|
17
20
|
};
|
|
18
|
-
|
|
21
|
+
const convertDecimalTaxRateToPercentage = taxRate => {
|
|
22
|
+
const dineroObj = decimalTaxRateToDinero(taxRate);
|
|
23
|
+
const t = multiply(dineroObj, 100);
|
|
24
|
+
return toUnit(t, {
|
|
25
|
+
digits: TAX_RATE_DINERO_CURRENCY.exponent,
|
|
26
|
+
round: halfEven
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const decimalTaxRateToDinero = taxRate => {
|
|
30
|
+
const parsedNumber = typeof taxRate === "number" ? taxRate : Number.parseFloat(taxRate);
|
|
31
|
+
isFloat(parsedNumber);
|
|
32
|
+
const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(TAX_RATE_DINERO_CURRENCY.base, TAX_RATE_DINERO_CURRENCY.exponent)).toFixed(0));
|
|
33
|
+
return dinero({
|
|
34
|
+
amount: parsedNumberInt,
|
|
35
|
+
currency: TAX_RATE_DINERO_CURRENCY
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const formatDecimalTaxRate = taxRate => {
|
|
39
|
+
return `${convertDecimalTaxRateToPercentage(taxRate)}%`;
|
|
40
|
+
};
|
|
41
|
+
const stringTaxRateToFloat = rate => toFixedRate(+rate, TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
42
|
+
const calculateTotalTaxRate = rates => {
|
|
43
|
+
const rateSum = rates.reduce((sum, rate) => sum + rate, 0);
|
|
44
|
+
const result = toFixedRate(rateSum, TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
45
|
+
assert(result >= 0, "Tax rate must be positive");
|
|
46
|
+
assert(result < 1, "Tax rate must be less than 1");
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
export { calculateLineItemTax, calculateTotalTaxRate, convertDecimalTaxRateToPercentage, decimalTaxRateToDinero, formatDecimalTaxRate, removeTaxAmount, stringTaxRateToFloat };
|
|
19
50
|
//# sourceMappingURL=tax.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tax.mjs","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"tax.mjs","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import {\n type Dinero,\n dinero,\n // FIXME: move usage to rounding\n down,\n // FIXME: move usage to rounding\n halfEven,\n multiply,\n toSnapshot,\n toUnit,\n} from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport {\n storesWithPerItemTaxRate,\n TAX_RATE_DINERO_CURRENCY,\n} from \"./constants\";\nimport {\n calculatePerQtyLineItemTax,\n calculateWholeQtyLineItemTax,\n} from \"./tax.private\";\nimport type { Cents, Dino, LineItemSummary, TaxRate } from \"./types\";\n\n/**\n * Function to calculate the tax amount for a given line item depending on the store's tax rate calculation strategy\n */\nexport const calculateLineItemTax = ({\n itemSummary,\n taxRate,\n storeId,\n}: {\n itemSummary: LineItemSummary;\n taxRate: TaxRate;\n storeId: StoreId;\n}) => {\n return storesWithPerItemTaxRate.has(storeId)\n ? calculatePerQtyLineItemTax(itemSummary, taxRate)\n : calculateWholeQtyLineItemTax(itemSummary, taxRate);\n};\n\nexport const removeTaxAmount = (\n baseAmountWithTaxObj: Dinero<Cents>,\n taxRate: TaxRate,\n) => {\n const snapshot = toSnapshot(baseAmountWithTaxObj);\n return dinero({\n ...snapshot,\n amount: down(snapshot.amount / (1 + taxRate)),\n });\n};\n\n/**\n * Will return a percentage tax rate from a decimal tax rate (usually returned by DB)\n *\n * Use for math-related calculations ONLY! Use `formatDecimalTaxRate` for display purposes e.g. invoices.\n *\n * @example convertDecimalTaxRateToPercentage(\"0.01\") // 1\n * @example convertDecimalTaxRateToPercentage(\"0.1023\") // 10.23\n * @example convertDecimalTaxRateToPercentage(\"0.12345678\") // 12.345678\n */\nexport const convertDecimalTaxRateToPercentage = (\n taxRate: string | number,\n): number => {\n const dineroObj = decimalTaxRateToDinero(taxRate);\n const t = multiply(dineroObj, 100);\n return toUnit(t, {\n digits: TAX_RATE_DINERO_CURRENCY.exponent,\n round: halfEven,\n });\n};\n\nexport const decimalTaxRateToDinero = (taxRate: string | number): Dino => {\n const parsedNumber =\n typeof taxRate === \"number\" ? taxRate : Number.parseFloat(taxRate);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (\n parsedNumber *\n Math.pow(TAX_RATE_DINERO_CURRENCY.base, TAX_RATE_DINERO_CURRENCY.exponent)\n ).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency: TAX_RATE_DINERO_CURRENCY,\n });\n};\n\n/**\n * Will return a percentage string from a decimal tax rate (usually returned by DB).\n *\n * Use for display purposes e.g. invoices.\n *\n * @example formatDecimalTaxRate(\"0.01\") // \"1%\"\n * @example formatDecimalTaxRate(\"0.1023\") // \"10.23%\"\n * @example formatDecimalTaxRate(\"0.12345678\") // \"12.345678%\"\n */\nexport const formatDecimalTaxRate = <TaxRateFloat extends string | number>(\n taxRate: TaxRateFloat,\n): `${number}%` => {\n return `${convertDecimalTaxRateToPercentage(taxRate)}%`;\n};\n\nexport const stringTaxRateToFloat = (rate: string): number =>\n toFixedRate(+rate, TAX_RATE_DINERO_CURRENCY.exponent, true);\n\n/**\n * Calculate total Tax(LV: \"PVN\") for country, which consists of multiple tax entries\n * Returning fixed to ${TAX_RATE_DINERO_CURRENCY.exponent} 4 decimal places, to for example 0.2100 represent 21.00%\n */\nexport const calculateTotalTaxRate = (rates: number[]): number => {\n const rateSum = rates.reduce((sum, rate) => sum + rate, 0);\n const result = toFixedRate(rateSum, TAX_RATE_DINERO_CURRENCY.exponent, true);\n assert(result >= 0, \"Tax rate must be positive\");\n assert(result < 1, \"Tax rate must be less than 1\");\n return result;\n};\n"],"names":["calculateLineItemTax","itemSummary","taxRate","storeId","storesWithPerItemTaxRate","has","calculatePerQtyLineItemTax","calculateWholeQtyLineItemTax","removeTaxAmount","baseAmountWithTaxObj","snapshot","toSnapshot","dinero","amount","down","convertDecimalTaxRateToPercentage","dineroObj","decimalTaxRateToDinero","t","multiply","toUnit","digits","TAX_RATE_DINERO_CURRENCY","exponent","round","halfEven","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","Math","pow","base","toFixed","currency","formatDecimalTaxRate","stringTaxRateToFloat","rate","toFixedRate","calculateTotalTaxRate","rates","rateSum","reduce","sum","result","assert"],"mappings":";;;;;;AA4BO,MAAMA,uBAAuBA,CAAC;EACnCC,WAAA;EACAC,OAAA;EACAC;AACF,CAIM,KAAA;EACG,OAAAC,wBAAA,CAAyBC,GAAI,CAAAF,OAAO,CACvC,GAAAG,0BAAA,CAA2BL,aAAaC,OAAO,CAAA,GAC/CK,4BAA6B,CAAAN,WAAA,EAAaC,OAAO,CAAA;AACvD,CAAA;AAEa,MAAAM,eAAA,GAAkBA,CAC7BC,oBAAA,EACAP,OACG,KAAA;EACG,MAAAQ,QAAA,GAAWC,WAAWF,oBAAoB,CAAA;EAChD,OAAOG,MAAO,CAAA;IACZ,GAAGF,QAAA;IACHG,MAAQ,EAAAC,IAAA,CAAKJ,QAAS,CAAAG,MAAA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,MAAA,CAAAD,MAAA,IAAU,GAAG,2BAA2B,CAAA;EACxCC,MAAA,CAAAD,MAAA,GAAS,GAAG,8BAA8B,CAAA;EAC1C,OAAAA,MAAA;AACT,CAAA;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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>;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;EA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
|
|
2
|
+
import { assert } from '../errors.mjs';
|
|
3
|
+
import { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
|
|
4
|
+
import { getDinero, amount } from './misc.mjs';
|
|
5
|
+
"use strict";
|
|
6
|
+
const taxRateToDineroAllocation = taxRate => {
|
|
7
|
+
if (taxRate <= 0 || taxRate >= 1) {
|
|
8
|
+
throw new RangeError("Unsupported rate, expected in range of 0>rate<1");
|
|
9
|
+
}
|
|
10
|
+
const rateScale = String(taxRate).split(".")[1]?.length;
|
|
11
|
+
assert(rateScale !== void 0, "rateScale is undefined");
|
|
12
|
+
const rateInt = Math.round(taxRate * Math.pow(10, rateScale));
|
|
13
|
+
return [rateInt, Math.pow(10, rateScale) - rateInt];
|
|
14
|
+
};
|
|
15
|
+
const allocatePerItemTaxableAmount = itemSummary => {
|
|
16
|
+
if (itemSummary.quantity === 1) {
|
|
17
|
+
return [itemSummary];
|
|
18
|
+
}
|
|
19
|
+
const preDiscountAmount = add(getDinero(itemSummary.taxableAmount, itemSummary.currency), getDinero(itemSummary.discountAmount, itemSummary.currency));
|
|
20
|
+
const allocator = new FixedAmountAllocator({
|
|
21
|
+
initialAllocateAmount: itemSummary.discountAmount,
|
|
22
|
+
initialTotalAmount: amount(preDiscountAmount),
|
|
23
|
+
currency: itemSummary.currency
|
|
24
|
+
});
|
|
25
|
+
return Array.from({
|
|
26
|
+
length: itemSummary.quantity
|
|
27
|
+
}, () => {
|
|
28
|
+
const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
|
|
29
|
+
const taxableAmount = subtract(getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
|
|
30
|
+
return {
|
|
31
|
+
itemPrice: itemSummary.itemPrice,
|
|
32
|
+
taxableAmount: amount(taxableAmount),
|
|
33
|
+
discountAmount: amount(discountAllocatedAmount),
|
|
34
|
+
currency: itemSummary.currency,
|
|
35
|
+
quantity: 1
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
|
|
40
|
+
if (taxRate === 0) {
|
|
41
|
+
return getDinero(0, itemSummary.currency);
|
|
42
|
+
}
|
|
43
|
+
const [taxAmount] = allocate(getDinero(itemSummary.taxableAmount, itemSummary.currency), taxRateToDineroAllocation(taxRate));
|
|
44
|
+
assert(taxAmount !== void 0, "taxAmount is undefined");
|
|
45
|
+
return taxAmount;
|
|
46
|
+
};
|
|
47
|
+
const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
|
|
48
|
+
if (taxRate === 0) {
|
|
49
|
+
return getDinero(0, itemSummary.currency);
|
|
50
|
+
}
|
|
51
|
+
const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
|
|
52
|
+
let totalTaxAmount = getDinero(0, itemSummary.currency);
|
|
53
|
+
singleItemSummaries.forEach(itemSummary2 => {
|
|
54
|
+
const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
|
|
55
|
+
totalTaxAmount = add(totalTaxAmount, taxAmount);
|
|
56
|
+
});
|
|
57
|
+
return totalTaxAmount;
|
|
58
|
+
};
|
|
59
|
+
export { allocatePerItemTaxableAmount, calculatePerQtyLineItemTax, calculateWholeQtyLineItemTax, taxRateToDineroAllocation };
|
|
60
|
+
//# sourceMappingURL=tax.private.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax.private.mjs","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,GA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a,CAAA;MACnCE,cAAA,EAAgBK,OAAOG,uBAAuB,CAAA;MAC9CT,UAAUN,WAAY,CAAAM,QAAA;MACtBL,QAAU,EAAA;IAAA,CACZ;EAAA,CACD,CAAA;AACH,CAAA;AAEa,MAAAkB,4BAAA,GAA+BA,CAC1CnB,WAAA,EACAZ,OACkB,KAAA;EAElB,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAgB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAMM,MAAA,CAACc,SAAS,CAAI,GAAAJ,QAAA,CAClBZ,SAAU,CAAAJ,WAAA,CAAYK,aAAe,EAAAL,WAAA,CAAYM,QAAQ,CAAA,EACzDnB,0BAA0BC,OAAO,CAAA,CACnC;EAEOM,MAAA,CAAA0B,SAAA,KAAc,QAAW,wBAAwB,CAAA;EACjD,OAAAA,SAAA;AACT,CAAA;AAEa,MAAAC,0BAAA,GAA6BA,CACxCrB,WAAA,EACAZ,OACkB,KAAA;EAElB,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAgB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAGM,MAAAgB,mBAAA,GAAsBvB,6BAA6BC,WAAW,CAAA;EAGpE,IAAIuB,cAAiB,GAAAnB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCgB,mBAAA,CAAAE,OAAA,CAASxB,YAAgB,IAAA;IAGrC,MAAAoB,SAAA,GAAYD,4BAA6BnB,CAAAA,YAAAA,EAAaZ,OAAO,CAAA;IAClDmC,cAAA,GAAApB,GAAA,CAAIoB,gBAAgBH,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAG,cAAA;AACT,CAAA;"}
|
|
@@ -1,10 +1,71 @@
|
|
|
1
|
-
import type { Currency as DineroCurrency } from "dinero.js";
|
|
1
|
+
import type { Dinero, Currency as DineroCurrency } from "dinero.js";
|
|
2
|
+
import type { Currency } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Floating point number of item tax rate
|
|
5
|
+
* Number in range of 0>rate<1 (non-inclusive boundaries)
|
|
6
|
+
* @example
|
|
7
|
+
* 0.09 // 9%
|
|
8
|
+
*/
|
|
9
|
+
export type TaxRate = number;
|
|
10
|
+
/**
|
|
11
|
+
* Shorthand for Dinero.js instance with number as the amount
|
|
12
|
+
*/
|
|
13
|
+
export type Dino = Dinero<number>;
|
|
14
|
+
/**
|
|
15
|
+
* Shorthand for Dinero.js currency instance representing either a currency or custom currency such as tax-rate or shipping
|
|
16
|
+
*/
|
|
17
|
+
export type DinoCurrency = DineroCurrency<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Cents representation of specific currency
|
|
20
|
+
* As a helper to easily understand the code, we use `Cents` as a type alias for `number` as historically we have had
|
|
21
|
+
* mistakes by the team where we have used as dollar instead of `Cents` and vice versa.
|
|
22
|
+
* @example
|
|
23
|
+
* 100 // in USD this is $1.00
|
|
24
|
+
* 100 // in YEN this is ¥100
|
|
25
|
+
*/
|
|
26
|
+
export type Cents = number;
|
|
27
|
+
/**
|
|
28
|
+
* Type definition for a rounding function that can be used to round fractions
|
|
29
|
+
*/
|
|
30
|
+
export type RoundingFn = (float: number) => Cents;
|
|
31
|
+
/**
|
|
32
|
+
* Convenient way to represent a money on the API level
|
|
33
|
+
* When working with dinero you typically will convert this to a Dinero instance
|
|
34
|
+
*/
|
|
35
|
+
export interface Money {
|
|
36
|
+
amount: Cents;
|
|
37
|
+
currency: Currency;
|
|
38
|
+
}
|
|
2
39
|
/**
|
|
3
40
|
* Attempt to type out some locales `language-TERRITORY` which "we" as store care about
|
|
4
41
|
* @see https://unicode-org.github.io/cldr-staging/charts/38/supplemental/territory_language_information.html
|
|
5
42
|
*/
|
|
6
43
|
export type Locale = "ar-AE" | "ar-SA" | "bg-BG" | "bn-BD" | "bn-IN" | "cs-CZ" | "da-DK" | "de-AT" | "de-CH" | "de-DE" | "el-GR" | "en-AU" | "en-BR" | "en-CA" | "en-GB" | "en-IE" | "en-IN" | "en-JP" | "en-NZ" | "en-SG" | "en-US" | "en-ZA" | "es-AR" | "es-CL" | "es-CO" | "es-ES" | "es-MX" | "es-US" | "fi-FI" | "fr-BE" | "fr-CA" | "fr-CH" | "fr-FR" | "he-IL" | "hi-IN" | "hr-HR" | "hu-HU" | "id-ID" | "it-CH" | "it-IT" | "ja-JP" | "ko-KR" | "nl-BE" | "nl-NL" | "no-NO" | "pl-PL" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "sk-SK" | "sv-SE" | "ta-IN" | "ta-LK" | "th-TH" | "tr-TR" | "zh-CN" | "zh-HK" | "zh-TW" | string;
|
|
7
|
-
export type
|
|
8
|
-
currency:
|
|
44
|
+
export type LocalizedCurrency = {
|
|
45
|
+
currency: DinoCurrency;
|
|
9
46
|
locale: Locale;
|
|
10
47
|
};
|
|
48
|
+
export interface LineItemSummary {
|
|
49
|
+
itemPrice: Cents;
|
|
50
|
+
/**
|
|
51
|
+
* (itemPrice * quantity) - discountAmount
|
|
52
|
+
*/
|
|
53
|
+
taxableAmount: Cents;
|
|
54
|
+
/**
|
|
55
|
+
* Total discount amount (only) applied for the given item quantity.
|
|
56
|
+
* No taxes are included. Calculated by `total_raw_price * <discount-allocation-percentage>`
|
|
57
|
+
*/
|
|
58
|
+
discountAmount: Cents;
|
|
59
|
+
currency: Currency;
|
|
60
|
+
/**
|
|
61
|
+
* Item quantity that is always bigger than zero!
|
|
62
|
+
*/
|
|
63
|
+
quantity: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Pretty much the same as PreTaxItemSummary but with quantity always set to 1 (for clearer type hinting and reasoning
|
|
67
|
+
* around the topic)
|
|
68
|
+
*/
|
|
69
|
+
export interface SingleLineItemSummary extends LineItemSummary {
|
|
70
|
+
quantity: 1;
|
|
71
|
+
}
|
package/lib/utils/number.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function isFloat(value: unknown, entity?: string, ErrorClass?: ne
|
|
|
31
31
|
* toFixed(1.2345, 0) // => "1"
|
|
32
32
|
* toFixed(1.23, 4) // => "1.2300"
|
|
33
33
|
*/
|
|
34
|
-
export declare function toFixedRate(rate: number, scale: number): string;
|
|
34
|
+
export declare function toFixedRate(rate: number, scale: number, asNumber?: boolean): string;
|
|
35
35
|
export declare function toFixedRate(rate: number, scale: number, asNumber: true): number;
|
|
36
36
|
/**
|
|
37
37
|
* Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of
|
package/lib/utils/number.js
CHANGED
|
@@ -21,7 +21,7 @@ function isInt(value, entity = "Value", ErrorClass = TypeError) {
|
|
|
21
21
|
function isFloat(value, entity = "Value", ErrorClass = TypeError) {
|
|
22
22
|
isFiniteNumber(value, entity, ErrorClass);
|
|
23
23
|
}
|
|
24
|
-
function toFixedRate(rate, scale
|
|
24
|
+
function toFixedRate(rate, scale, asNumber) {
|
|
25
25
|
isFloat(rate, "Rate");
|
|
26
26
|
const fixedRate = rate.toFixed(scale);
|
|
27
27
|
return asNumber ? +fixedRate : fixedRate;
|
package/lib/utils/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;AAWO,SAASU,OACdA,CAAAV,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;AAC1C;AAoBgB,SAAAS,WAAAA,CAAYC,IAAc,EAAAC,KAAA,EAAeC,QAAoB,EAAA;EAE3EJ,O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C,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;;;;;;;;;;"}
|
package/lib/utils/number.mjs
CHANGED
|
@@ -20,7 +20,7 @@ function isInt(value, entity = "Value", ErrorClass = TypeError) {
|
|
|
20
20
|
function isFloat(value, entity = "Value", ErrorClass = TypeError) {
|
|
21
21
|
isFiniteNumber(value, entity, ErrorClass);
|
|
22
22
|
}
|
|
23
|
-
function toFixedRate(rate, scale
|
|
23
|
+
function toFixedRate(rate, scale, asNumber) {
|
|
24
24
|
isFloat(rate, "Rate");
|
|
25
25
|
const fixedRate = rate.toFixed(scale);
|
|
26
26
|
return asNumber ? +fixedRate : fixedRate;
|
package/lib/utils/number.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number
|
|
1
|
+
{"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAA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T,CAAA;AAKO,MAAMM,KAAQ,GAAAA,CAACC,GAAa,EAAAC,GAAA,EAAaC,GAAgB,KAAA;EAC9D,MAAMC,OAAU,GAAAd,IAAA,CAAKY,GAAI,CAAAA,GAAA,EAAKC,GAAG,CAAA;EACjC,MAAME,OAAU,GAAAf,IAAA,CAAKa,GAAI,CAAAD,GAAA,EAAKC,GAAG,CAAA;EAEjC,OAAOb,KAAKY,GAAI,CAAAG,OAAA,EAASf,KAAKa,GAAI,CAAAC,OAAA,EAASH,GAAG,CAAC,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;"}
|
package/lib/utils/tax/index.d.ts
CHANGED
|
@@ -172,7 +172,7 @@ export declare const isValidTaxNumberPattern: (type: AddressType, taxCountryCode
|
|
|
172
172
|
* Depending on store Tax is called different names, so this mapping determines which one to use
|
|
173
173
|
* @see https://ui.slack.com/archives/D0191CBEB27/p1678723218358039?thread_ts=1678722532.763459&cid=D0191CBEB27
|
|
174
174
|
*/
|
|
175
|
-
export declare const getTaxLabelType: (storeId: StoreId) => TaxLabelType.Tax | TaxLabelType.Vat | TaxLabelType.Gst;
|
|
175
|
+
export declare const getTaxLabelType: (storeId: StoreId) => TaxLabelType.Tax | TaxLabelType.Vat | TaxLabelType.Gst | TaxLabelType.Rfc;
|
|
176
176
|
export declare const getTaxLabelTypeByCountry: (country: CountryCode, options: {
|
|
177
177
|
type: "general";
|
|
178
178
|
} | {
|
package/lib/utils/tax/index.js
CHANGED
|
@@ -62,7 +62,6 @@ const getTaxLabelType = storeId => {
|
|
|
62
62
|
case generated.StoreId.Uk:
|
|
63
63
|
case generated.StoreId.Br:
|
|
64
64
|
case generated.StoreId.Tw:
|
|
65
|
-
case generated.StoreId.Mx:
|
|
66
65
|
case generated.StoreId.Jp:
|
|
67
66
|
{
|
|
68
67
|
return types.TaxLabelType.Vat;
|
|
@@ -77,6 +76,10 @@ const getTaxLabelType = storeId => {
|
|
|
77
76
|
{
|
|
78
77
|
return types.TaxLabelType.Gst;
|
|
79
78
|
}
|
|
79
|
+
case generated.StoreId.Mx:
|
|
80
|
+
{
|
|
81
|
+
return types.TaxLabelType.Rfc;
|
|
82
|
+
}
|
|
80
83
|
default:
|
|
81
84
|
{
|
|
82
85
|
errors.checkUnreachable(storeId);
|
|
@@ -104,6 +107,10 @@ const getTaxLabelTypeByCountry = (country, options) => {
|
|
|
104
107
|
{
|
|
105
108
|
return types.TaxLabelType.Gst;
|
|
106
109
|
}
|
|
110
|
+
case generated.CountryCode.Mx:
|
|
111
|
+
{
|
|
112
|
+
return types.TaxLabelType.Rfc;
|
|
113
|
+
}
|
|
107
114
|
case generated.CountryCode.Br:
|
|
108
115
|
{
|
|
109
116
|
switch (options.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/tax/index.ts"],"sourcesContent":["import isRegExp from \"lodash/isRegExp\";\n\nimport {\n BUSINESS_COUNTRY_CODE_MAPPING,\n RESIDENTIAL_COUNTRY_CODE_MAPPING,\n USER_ASSIGNED_COUNTRY_MAPPING_RULES,\n} from \"../../constants/address\";\nimport type { Nullish, UserAssignedCountryCode } from \"../../types\";\nimport { AddressType, CountryCode, StoreId } from \"../../types\";\nimport { assertUnreachable, checkUnreachable } from \"../errors\";\nimport { formatCnpj, formatCpf } from \"./brazil\";\nimport type { TaxCountryCode } from \"./types\";\nimport { TaxLabelType } from \"./types\";\n\n/**\n * Util to get the country code mapping based on address type in a type-safe way\n */\nexport const getValidationMappingByType = (type: AddressType) => {\n switch (type) {\n case AddressType.Business: {\n return BUSINESS_COUNTRY_CODE_MAPPING;\n }\n case AddressType.Residential: {\n return RESIDENTIAL_COUNTRY_CODE_MAPPING;\n }\n default: {\n assertUnreachable(type);\n }\n }\n};\n\n/**\n * Checks if given tax country has regex pattern for tax id's\n */\nexport const hasTaxNumberPatternValidation = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n): taxCountryCode is keyof ReturnType<typeof getValidationMappingByType> =>\n taxCountryCode in getValidationMappingByType(type);\n\n/**\n * Checks if given tax id meets static pattern validation\n */\nexport const isValidTaxNumberPattern = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n taxId: Nullish<string>,\n): boolean => {\n // If country doesn't have a tax number pattern then mark input as valid\n if (!hasTaxNumberPatternValidation(type, taxCountryCode)) {\n return true;\n }\n\n const mapping = getValidationMappingByType(type);\n const { validation, isOptional } = mapping[taxCountryCode];\n\n // Mark input as valid if the tax ID is missing but it's optional\n if (!taxId && isOptional) {\n return true;\n }\n\n // Check for empty tax id's in cases when they are required\n if (!taxId) {\n return false;\n }\n\n // Technically, this should already be covered by the \"hasTaxNumberPatternValidation\"\n // check above but just in case something goes really wrong, we are adding this\n // to avoid unexpected type errors during runtime\n if (!validation) {\n return true;\n }\n\n // Validate pattern\n return isRegExp(validation)\n ? validation.test(taxId)\n : validation({ taxId, taxCountryCode });\n};\n\n/**\n * Depending on store Tax is called different names, so this mapping determines which one to use\n * @see https://ui.slack.com/archives/D0191CBEB27/p1678723218358039?thread_ts=1678722532.763459&cid=D0191CBEB27\n */\nexport const getTaxLabelType = (storeId: StoreId) => {\n switch (storeId) {\n case StoreId.Me:\n case StoreId.Za:\n case StoreId.Eu:\n case StoreId.Uk:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Mx:\n case StoreId.Jp: {\n return TaxLabelType.Vat;\n }\n case StoreId.Ca:\n case StoreId.Us: {\n return TaxLabelType.Tax;\n }\n case StoreId.In:\n case StoreId.Sg: {\n return TaxLabelType.Gst;\n }\n default: {\n checkUnreachable(storeId);\n return TaxLabelType.Tax;\n }\n }\n};\n\nexport const getTaxLabelTypeByCountry = (\n country: CountryCode,\n options:\n | {\n type: \"general\";\n }\n | {\n type: \"specific\";\n addressType: AddressType;\n },\n) => {\n switch (country) {\n case CountryCode.Ca:\n case CountryCode.Us:\n case CountryCode.Pr:\n case CountryCode.Pw:\n case CountryCode.Gu:\n case CountryCode.As:\n case CountryCode.Vi:\n case CountryCode.Mp:\n case CountryCode.Mh:\n case CountryCode.Fm: {\n return TaxLabelType.Tax;\n }\n case CountryCode.In:\n case CountryCode.Sg: {\n return TaxLabelType.Gst;\n }\n case CountryCode.Br: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (options.type) {\n case \"general\":\n return TaxLabelType.Vat;\n case \"specific\": {\n const taxLabelTypesByAddressType = {\n [AddressType.Residential]: TaxLabelType.Cpf,\n [AddressType.Business]: TaxLabelType.Cnpj,\n } satisfies Record<AddressType, TaxLabelType>;\n\n return taxLabelTypesByAddressType[options.addressType];\n }\n default:\n checkUnreachable(options);\n return TaxLabelType.Vat;\n }\n }\n default: {\n return TaxLabelType.Vat;\n }\n }\n};\n\n// #############################################################################\n// Assigned country code\n// #############################################################################\n/**\n * We can't 100% trust the order of countries as compiles can possible rearrange the values, so we have to sort the\n * values with country+province first when looking for the match we can stop at first occurrence\n * @see https://stackoverflow.com/a/5525820\n */\nconst userAssignedCountryRulesSorted = Object.entries(\n USER_ASSIGNED_COUNTRY_MAPPING_RULES,\n)\n .flatMap(([userAssignedCountry, rules]) =>\n rules.map((rule) => {\n return [userAssignedCountry as UserAssignedCountryCode, rule] as const;\n }),\n )\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .sort(([_, a], [__, b]) => {\n return b.length - a.length;\n });\n\n/**\n * Util to get TAX country code for a given country + province combination\n */\nexport const getTaxCountry = ({\n country,\n province,\n}: {\n country: CountryCode;\n province: Nullish<string>;\n}): TaxCountryCode => {\n const match = userAssignedCountryRulesSorted.find(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ([_, [refCountry, refProvince]]) => {\n // Don't match - if countries don't match\n if (refCountry !== country) {\n return false;\n }\n\n // Match - if pattern doesn't include a province\n // TODO: this is debatable whether it should match as input province can be non-nullish\n if (refProvince == null) {\n return true;\n }\n\n return refProvince === province;\n },\n );\n\n const userAssignedCountry = match?.[0];\n\n // If there isn't a user assigned country that matches the result (most likely indicating that it doesnt require\n // unique lookup) then fallback to input country\n return userAssignedCountry ?? country;\n};\n\nexport const isTaxNumberOptional = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n) => {\n if (!hasTaxNumberPatternValidation(type, taxCountryCode)) {\n return true;\n }\n\n const mapping = getValidationMappingByType(type);\n const { isOptional } = mapping[taxCountryCode];\n\n return isOptional;\n};\n\nexport const formatTaxNumber = (\n taxNumber: string,\n { country, addressType }: { country: CountryCode; addressType: AddressType },\n) => {\n // Tax number formatting only needed for Brazil in the foreseeable future.\n if (country !== CountryCode.Br) {\n return taxNumber;\n }\n\n switch (addressType) {\n case AddressType.Residential:\n return formatCpf(taxNumber);\n\n case AddressType.Business:\n return formatCnpj(taxNumber);\n\n default:\n checkUnreachable(addressType);\n return taxNumber;\n }\n};\n"],"names":["getValidationMappingByType","type","AddressType","Business","BUSINESS_COUNTRY_CODE_MAPPING","Residential","RESIDENTIAL_COUNTRY_CODE_MAPPING","assertUnreachable","hasTaxNumberPatternValidation","taxCountryCode","isValidTaxNumberPattern","taxId","mapping","validation","isOptional","isRegExp","test","getTaxLabelType","storeId","StoreId","Me","Za","Eu","Uk","Br","Tw","Mx","Jp","TaxLabelType","Vat","Ca","Us","Tax","In","Sg","Gst","checkUnreachable","getTaxLabelTypeByCountry","country","options","CountryCode","Pr","Pw","Gu","As","Vi","Mp","Mh","Fm","taxLabelTypesByAddressType","Cpf","Cnpj","addressType","userAssignedCountryRulesSorted","Object","entries","USER_ASSIGNED_COUNTRY_MAPPING_RULES","flatMap","userAssignedCountry","rules","map","rule","sort","_","a","__","b","length","getTaxCountry","province","match","find","refCountry","refProvince","isTaxNumberOptional","formatTaxNumber","taxNumber","formatCpf","formatCnpj"],"mappings":";;;;;;;;;;;;;;;;AAiBa,MAAAA,0BAAA,GAA8BC,IAAsB,IAAA;EAC/D,QAAQA,IAAM;IACZ,KAAKC,SAAAA,CAAAA,YAAYC,QAAU;MAAA;QAClB,OAAAC,qCAAA;MACT;IACA,KAAKF,SAAAA,CAAAA,YAAYG,WAAa;MAAA;QACrB,OAAAC,wCAAA;MACT;IACA;MAAS;QACPC,MAAA,CAAAA,iBAAA,CAAkBN,IAAI,CAAA;MACxB;EACF;AACF,CAAA;AAKO,MAAMO,gCAAgCA,CAC3CP,IAAA,EACAQ,cAEA,KAAAA,cAAA,IAAkBT,2BAA2BC,IAAI,CAAA;AAK5C,MAAMS,uBAA0B,GAAAA,CACrCT,IACA,EAAAQ,cAAA,EACAE,KACY,KAAA;EAEZ,IAAI,CAACH,6BAAA,CAA8BP,IAAM,EAAAQ,cAAc,CAAG,EAAA;IACjD,OAAA,IAAA;EACT;EAEM,MAAAG,OAAA,GAAUZ,2BAA2BC,IAAI,CAAA;EAC/C,MAAM;IAAEY,UAAA;IAAYC;EAAW,CAAA,GAAIF,QAAQH,cAAc,CAAA;EAGrD,IAAA,CAACE,SAASG,UAAY,EAAA;IACjB,OAAA,IAAA;EACT;EAGA,IAAI,CAACH,KAAO,EAAA;IACH,OAAA,KAAA;EACT;EAKA,IAAI,CAACE,UAAY,EAAA;IACR,OAAA,IAAA;EACT;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YhB,EAAI,EAAA;IACvB,OAAAoD,SAAA;EACT;EAEA,QAAQxB,WAAa;IACnB,KAAKlD,SAAY,CAAAA,WAAA,CAAAG,WAAA;MACf,OAAOwE,MAAAA,CAAAA,UAAUD,SAAS,CAAA;IAE5B,KAAK1E,SAAY,CAAAA,WAAA,CAAAC,QAAA;MACf,OAAO2E,MAAAA,CAAAA,WAAWF,SAAS,CAAA;IAE7B;MACExC,MAAA,CAAAA,gBAAA,CAAiBgB,WAAW,CAAA;MACrB,OAAAwB,SAAA;EACX;AACF,CAAA;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/tax/index.ts"],"sourcesContent":["import isRegExp from \"lodash/isRegExp\";\n\nimport {\n BUSINESS_COUNTRY_CODE_MAPPING,\n RESIDENTIAL_COUNTRY_CODE_MAPPING,\n USER_ASSIGNED_COUNTRY_MAPPING_RULES,\n} from \"../../constants/address\";\nimport type { Nullish, UserAssignedCountryCode } from \"../../types\";\nimport { AddressType, CountryCode, StoreId } from \"../../types\";\nimport { assertUnreachable, checkUnreachable } from \"../errors\";\nimport { formatCnpj, formatCpf } from \"./brazil\";\nimport type { TaxCountryCode } from \"./types\";\nimport { TaxLabelType } from \"./types\";\n\n/**\n * Util to get the country code mapping based on address type in a type-safe way\n */\nexport const getValidationMappingByType = (type: AddressType) => {\n switch (type) {\n case AddressType.Business: {\n return BUSINESS_COUNTRY_CODE_MAPPING;\n }\n case AddressType.Residential: {\n return RESIDENTIAL_COUNTRY_CODE_MAPPING;\n }\n default: {\n assertUnreachable(type);\n }\n }\n};\n\n/**\n * Checks if given tax country has regex pattern for tax id's\n */\nexport const hasTaxNumberPatternValidation = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n): taxCountryCode is keyof ReturnType<typeof getValidationMappingByType> =>\n taxCountryCode in getValidationMappingByType(type);\n\n/**\n * Checks if given tax id meets static pattern validation\n */\nexport const isValidTaxNumberPattern = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n taxId: Nullish<string>,\n): boolean => {\n // If country doesn't have a tax number pattern then mark input as valid\n if (!hasTaxNumberPatternValidation(type, taxCountryCode)) {\n return true;\n }\n\n const mapping = getValidationMappingByType(type);\n const { validation, isOptional } = mapping[taxCountryCode];\n\n // Mark input as valid if the tax ID is missing but it's optional\n if (!taxId && isOptional) {\n return true;\n }\n\n // Check for empty tax id's in cases when they are required\n if (!taxId) {\n return false;\n }\n\n // Technically, this should already be covered by the \"hasTaxNumberPatternValidation\"\n // check above but just in case something goes really wrong, we are adding this\n // to avoid unexpected type errors during runtime\n if (!validation) {\n return true;\n }\n\n // Validate pattern\n return isRegExp(validation)\n ? validation.test(taxId)\n : validation({ taxId, taxCountryCode });\n};\n\n/**\n * Depending on store Tax is called different names, so this mapping determines which one to use\n * @see https://ui.slack.com/archives/D0191CBEB27/p1678723218358039?thread_ts=1678722532.763459&cid=D0191CBEB27\n */\nexport const getTaxLabelType = (storeId: StoreId) => {\n switch (storeId) {\n case StoreId.Me:\n case StoreId.Za:\n case StoreId.Eu:\n case StoreId.Uk:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Jp: {\n return TaxLabelType.Vat;\n }\n case StoreId.Ca:\n case StoreId.Us: {\n return TaxLabelType.Tax;\n }\n case StoreId.In:\n case StoreId.Sg: {\n return TaxLabelType.Gst;\n }\n case StoreId.Mx: {\n return TaxLabelType.Rfc;\n }\n default: {\n checkUnreachable(storeId);\n return TaxLabelType.Tax;\n }\n }\n};\n\nexport const getTaxLabelTypeByCountry = (\n country: CountryCode,\n options:\n | {\n type: \"general\";\n }\n | {\n type: \"specific\";\n addressType: AddressType;\n },\n) => {\n switch (country) {\n case CountryCode.Ca:\n case CountryCode.Us:\n case CountryCode.Pr:\n case CountryCode.Pw:\n case CountryCode.Gu:\n case CountryCode.As:\n case CountryCode.Vi:\n case CountryCode.Mp:\n case CountryCode.Mh:\n case CountryCode.Fm: {\n return TaxLabelType.Tax;\n }\n case CountryCode.In:\n case CountryCode.Sg: {\n return TaxLabelType.Gst;\n }\n case CountryCode.Mx: {\n return TaxLabelType.Rfc;\n }\n case CountryCode.Br: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (options.type) {\n case \"general\":\n return TaxLabelType.Vat;\n case \"specific\": {\n const taxLabelTypesByAddressType = {\n [AddressType.Residential]: TaxLabelType.Cpf,\n [AddressType.Business]: TaxLabelType.Cnpj,\n } satisfies Record<AddressType, TaxLabelType>;\n\n return taxLabelTypesByAddressType[options.addressType];\n }\n default:\n checkUnreachable(options);\n return TaxLabelType.Vat;\n }\n }\n default: {\n return TaxLabelType.Vat;\n }\n }\n};\n\n// #############################################################################\n// Assigned country code\n// #############################################################################\n/**\n * We can't 100% trust the order of countries as compiles can possible rearrange the values, so we have to sort the\n * values with country+province first when looking for the match we can stop at first occurrence\n * @see https://stackoverflow.com/a/5525820\n */\nconst userAssignedCountryRulesSorted = Object.entries(\n USER_ASSIGNED_COUNTRY_MAPPING_RULES,\n)\n .flatMap(([userAssignedCountry, rules]) =>\n rules.map((rule) => {\n return [userAssignedCountry as UserAssignedCountryCode, rule] as const;\n }),\n )\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .sort(([_, a], [__, b]) => {\n return b.length - a.length;\n });\n\n/**\n * Util to get TAX country code for a given country + province combination\n */\nexport const getTaxCountry = ({\n country,\n province,\n}: {\n country: CountryCode;\n province: Nullish<string>;\n}): TaxCountryCode => {\n const match = userAssignedCountryRulesSorted.find(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ([_, [refCountry, refProvince]]) => {\n // Don't match - if countries don't match\n if (refCountry !== country) {\n return false;\n }\n\n // Match - if pattern doesn't include a province\n // TODO: this is debatable whether it should match as input province can be non-nullish\n if (refProvince == null) {\n return true;\n }\n\n return refProvince === province;\n },\n );\n\n const userAssignedCountry = match?.[0];\n\n // If there isn't a user assigned country that matches the result (most likely indicating that it doesnt require\n // unique lookup) then fallback to input country\n return userAssignedCountry ?? country;\n};\n\nexport const isTaxNumberOptional = (\n type: AddressType,\n taxCountryCode: TaxCountryCode,\n) => {\n if (!hasTaxNumberPatternValidation(type, taxCountryCode)) {\n return true;\n }\n\n const mapping = getValidationMappingByType(type);\n const { isOptional } = mapping[taxCountryCode];\n\n return isOptional;\n};\n\nexport const formatTaxNumber = (\n taxNumber: string,\n { country, addressType }: { country: CountryCode; addressType: AddressType },\n) => {\n // Tax number formatting only needed for Brazil in the foreseeable future.\n if (country !== CountryCode.Br) {\n return taxNumber;\n }\n\n switch (addressType) {\n case AddressType.Residential:\n return formatCpf(taxNumber);\n\n case AddressType.Business:\n return formatCnpj(taxNumber);\n\n default:\n checkUnreachable(addressType);\n return taxNumber;\n }\n};\n"],"names":["getValidationMappingByType","type","AddressType","Business","BUSINESS_COUNTRY_CODE_MAPPING","Residential","RESIDENTIAL_COUNTRY_CODE_MAPPING","assertUnreachable","hasTaxNumberPatternValidation","taxCountryCode","isValidTaxNumberPattern","taxId","mapping","validation","isOptional","isRegExp","test","getTaxLabelType","storeId","StoreId","Me","Za","Eu","Uk","Br","Tw","Jp","TaxLabelType","Vat","Ca","Us","Tax","In","Sg","Gst","Mx","Rfc","checkUnreachable","getTaxLabelTypeByCountry","country","options","CountryCode","Pr","Pw","Gu","As","Vi","Mp","Mh","Fm","taxLabelTypesByAddressType","Cpf","Cnpj","addressType","userAssignedCountryRulesSorted","Object","entries","USER_ASSIGNED_COUNTRY_MAPPING_RULES","flatMap","userAssignedCountry","rules","map","rule","sort","_","a","__","b","length","getTaxCountry","province","match","find","refCountry","refProvince","isTaxNumberOptional","formatTaxNumber","taxNumber","formatCpf","formatCnpj"],"mappings":";;;;;;;;;;;;;;;;AAiBa,MAAAA,0BAAA,GAA8BC,IAAsB,IAAA;EAC/D,QAAQA,IAAM;IACZ,KAAKC,SAAAA,CAAAA,YAAYC,QAAU;MAAA;QAClB,OAAAC,qCAAA;MACT;IACA,KAAKF,SAAAA,CAAAA,YAAYG,WAAa;MAAA;QACrB,OAAAC,wCAAA;MACT;IAC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
|
case StoreId.Br:
|
|
56
56
|
case StoreId.Tw:
|
|
57
|
-
case StoreId.Mx:
|
|
58
57
|
case StoreId.Jp:
|
|
59
58
|
{
|
|
60
59
|
return TaxLabelType.Vat;
|
|
@@ -69,6 +68,10 @@ const getTaxLabelType = storeId => {
|
|
|
69
68
|
{
|
|
70
69
|
return TaxLabelType.Gst;
|
|
71
70
|
}
|
|
71
|
+
case StoreId.Mx:
|
|
72
|
+
{
|
|
73
|
+
return TaxLabelType.Rfc;
|
|
74
|
+
}
|
|
72
75
|
default:
|
|
73
76
|
{
|
|
74
77
|
checkUnreachable(storeId);
|
|
@@ -96,6 +99,10 @@ const getTaxLabelTypeByCountry = (country, options) => {
|
|
|
96
99
|
{
|
|
97
100
|
return TaxLabelType.Gst;
|
|
98
101
|
}
|
|
102
|
+
case CountryCode.Mx:
|
|
103
|
+
{
|
|
104
|
+
return TaxLabelType.Rfc;
|
|
105
|
+
}
|
|
99
106
|
case CountryCode.Br:
|
|
100
107
|
{
|
|
101
108
|
switch (options.type) {
|