@ubnt/store.core 10.0.0-beta.9 → 10.0.0-pre-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4952 -136
- package/lib/_virtual/_virtual_multi-entry.js +14 -10
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +14 -10
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/assets/ai-360.jpg +0 -0
- package/lib/assets/ai-dome.jpg +0 -0
- package/lib/assets/ai-theta-pro.jpg +0 -0
- package/lib/assets/ai-theta.jpg +0 -0
- package/lib/assets/ai-turret.jpg +0 -0
- package/lib/assets/attention.svg +5 -5
- package/lib/assets/attention2.svg +5 -5
- package/lib/assets/g4-instant.jpg +0 -0
- package/lib/assets/g5-dome-ultra.jpg +0 -0
- package/lib/assets/g5-dome.jpg +0 -0
- package/lib/assets/g5-flex.jpg +0 -0
- package/lib/assets/g5-ptz.jpg +0 -0
- package/lib/assets/g5-turret-ultra.jpg +0 -0
- package/lib/assets/poe2.svg +2 -3
- package/lib/assets/poe3.svg +3 -2
- package/lib/assets/port.svg +2 -4
- package/lib/assets/port2.svg +4 -2
- package/lib/assets/ucgFiber.jpg +0 -0
- package/lib/assets/ucgFiber2.jpg +0 -0
- package/lib/assets/ucgMax.jpg +0 -0
- package/lib/assets/ucgMax2.jpg +0 -0
- package/lib/assets/ucgUltra.jpg +0 -0
- package/lib/assets/ucgUltra2.jpg +0 -0
- package/lib/assets/udmPro.jpg +0 -0
- package/lib/assets/udmPro2.jpg +0 -0
- package/lib/assets/udmProMax.jpg +0 -0
- package/lib/assets/udmProMax2.jpg +0 -0
- package/lib/assets/udmProSpecial.jpg +0 -0
- package/lib/assets/udmProSpecial2.jpg +0 -0
- package/lib/assets/udr7.jpg +0 -0
- package/lib/assets/udr72.jpg +0 -0
- package/lib/components/Badge/Badge.styles.js +0 -5
- package/lib/components/Badge/Badge.styles.js.map +1 -1
- package/lib/components/Badge/Badge.styles.mjs +0 -5
- package/lib/components/Badge/Badge.styles.mjs.map +1 -1
- package/lib/components/Badge/Badge.types.d.ts +1 -2
- package/lib/components/Badge/Badge.types.js +0 -1
- package/lib/components/Badge/Badge.types.js.map +1 -1
- package/lib/components/Badge/Badge.types.mjs +0 -1
- package/lib/components/Badge/Badge.types.mjs.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.js +1 -7
- package/lib/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.mjs +1 -7
- package/lib/components/ButtonGroup/ButtonGroup.mjs.map +1 -1
- package/lib/components/Footer/hooks/useFooterContent.d.ts +1 -3
- package/lib/components/Footer/hooks/useFooterContent.js +0 -12
- package/lib/components/Footer/hooks/useFooterContent.js.map +1 -1
- package/lib/components/Footer/hooks/useFooterContent.mjs +0 -12
- package/lib/components/Footer/hooks/useFooterContent.mjs.map +1 -1
- package/lib/components/Footer/translations/ar.json.js +0 -2
- package/lib/components/Footer/translations/ar.json.js.map +1 -1
- package/lib/components/Footer/translations/ar.json.mjs +0 -2
- package/lib/components/Footer/translations/ar.json.mjs.map +1 -1
- package/lib/components/Footer/translations/de.json.js +0 -2
- package/lib/components/Footer/translations/de.json.js.map +1 -1
- package/lib/components/Footer/translations/de.json.mjs +0 -2
- package/lib/components/Footer/translations/de.json.mjs.map +1 -1
- package/lib/components/Footer/translations/el.json.js +0 -2
- package/lib/components/Footer/translations/el.json.js.map +1 -1
- package/lib/components/Footer/translations/el.json.mjs +0 -2
- package/lib/components/Footer/translations/el.json.mjs.map +1 -1
- package/lib/components/Footer/translations/en.json.js +0 -2
- package/lib/components/Footer/translations/en.json.js.map +1 -1
- package/lib/components/Footer/translations/en.json.mjs +0 -2
- package/lib/components/Footer/translations/en.json.mjs.map +1 -1
- package/lib/components/Footer/translations/es.json.js +0 -2
- package/lib/components/Footer/translations/es.json.js.map +1 -1
- package/lib/components/Footer/translations/es.json.mjs +0 -2
- package/lib/components/Footer/translations/es.json.mjs.map +1 -1
- package/lib/components/Footer/translations/fr.json.js +0 -2
- package/lib/components/Footer/translations/fr.json.js.map +1 -1
- package/lib/components/Footer/translations/fr.json.mjs +0 -2
- package/lib/components/Footer/translations/fr.json.mjs.map +1 -1
- package/lib/components/Footer/translations/it.json.js +0 -2
- package/lib/components/Footer/translations/it.json.js.map +1 -1
- package/lib/components/Footer/translations/it.json.mjs +0 -2
- package/lib/components/Footer/translations/it.json.mjs.map +1 -1
- package/lib/components/Footer/translations/ja.json.js +0 -2
- package/lib/components/Footer/translations/ja.json.js.map +1 -1
- package/lib/components/Footer/translations/ja.json.mjs +0 -2
- package/lib/components/Footer/translations/ja.json.mjs.map +1 -1
- package/lib/components/Footer/translations/pt-BR.json.js +0 -2
- package/lib/components/Footer/translations/pt-BR.json.js.map +1 -1
- package/lib/components/Footer/translations/pt-BR.json.mjs +0 -2
- package/lib/components/Footer/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/Footer/translations/zh-Hans.json.js +0 -2
- package/lib/components/Footer/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/Footer/translations/zh-Hans.json.mjs +0 -2
- package/lib/components/Footer/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/Footer/translations/zh-Hant-TW.json.js +0 -2
- package/lib/components/Footer/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/Footer/translations/zh-Hant-TW.json.mjs +0 -2
- package/lib/components/Footer/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/Header/CartIcon/CartIcon.d.ts +1 -1
- package/lib/components/Header/CartIcon/CartIcon.js +1 -5
- package/lib/components/Header/CartIcon/CartIcon.js.map +1 -1
- package/lib/components/Header/CartIcon/CartIcon.mjs +1 -5
- package/lib/components/Header/CartIcon/CartIcon.mjs.map +1 -1
- package/lib/components/Header/CartIcon/CartIcon.types.d.ts +0 -2
- package/lib/components/Header/Header.stories.d.ts +0 -2
- package/lib/components/Header/Header.styles.d.ts +2 -5
- package/lib/components/Header/Header.styles.js +1 -10
- package/lib/components/Header/Header.styles.js.map +1 -1
- package/lib/components/Header/Header.styles.mjs +1 -10
- package/lib/components/Header/Header.styles.mjs.map +1 -1
- package/lib/components/Header/Header.types.d.ts +0 -2
- package/lib/components/Header/Header.types.js.map +1 -1
- package/lib/components/Header/Header.types.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.d.ts +0 -2
- package/lib/components/Header/ProHeader/ProHeader.js +28 -70
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +31 -72
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +0 -9
- package/lib/components/Header/ProHeader/ProHeader.styles.js +1 -50
- package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs +2 -46
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +2 -7
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgFiber.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgFiber.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr7.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr7.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/ucgFiber.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgFiber.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udr7.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udr7.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-360.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-360.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-dome.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-dome.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-turret.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/ai-turret.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-dome-ultra.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-dome-ultra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-dome.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-dome.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-turret-ultra.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/g5-turret-ultra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Interior/ai-theta-pro.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Interior/ai-theta-pro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Interior/ai-theta.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Interior/ai-theta.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/poe.svg.js +1 -1
- package/lib/components/ModelCompareV3/assets/poe.svg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/port.svg.js +1 -1
- package/lib/components/ModelCompareV3/assets/port.svg.mjs +2 -2
- package/lib/components/ModelCompareV3/data/Bullet.js +1 -2
- package/lib/components/ModelCompareV3/data/Bullet.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Bullet.mjs +1 -2
- package/lib/components/ModelCompareV3/data/Bullet.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/CameraSecurity.js +1 -58
- package/lib/components/ModelCompareV3/data/CameraSecurity.js.map +1 -1
- package/lib/components/ModelCompareV3/data/CameraSecurity.mjs +1 -33
- package/lib/components/ModelCompareV3/data/CameraSecurity.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/CloudGateways.js +21 -21
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +14 -14
- package/lib/components/ModelCompareV3/data/Compact.js +4 -5
- package/lib/components/ModelCompareV3/data/Compact.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Compact.mjs +4 -5
- package/lib/components/ModelCompareV3/data/Compact.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/Dome.js +2 -3
- package/lib/components/ModelCompareV3/data/Dome.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Dome.mjs +2 -3
- package/lib/components/ModelCompareV3/data/Dome.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js +2 -3
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs +2 -3
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js +3 -10
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs +3 -10
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.js +1 -2
- package/lib/components/ModelCompareV3/data/Switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.mjs +1 -2
- package/lib/components/ModelCompareV3/data/Switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ai360.js +3 -11
- package/lib/components/ModelCompareV3/data/products/ai360.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ai360.mjs +3 -11
- package/lib/components/ModelCompareV3/data/products/ai360.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiDome.js +4 -10
- package/lib/components/ModelCompareV3/data/products/aiDome.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiDome.mjs +4 -10
- package/lib/components/ModelCompareV3/data/products/aiDome.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiDslr.js +1 -9
- package/lib/components/ModelCompareV3/data/products/aiDslr.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiDslr.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/aiDslr.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiLpr.js +2 -8
- package/lib/components/ModelCompareV3/data/products/aiLpr.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiLpr.mjs +2 -8
- package/lib/components/ModelCompareV3/data/products/aiLpr.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiPro.js +1 -9
- package/lib/components/ModelCompareV3/data/products/aiPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiPro.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/aiPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiTurret.js +4 -10
- package/lib/components/ModelCompareV3/data/products/aiTurret.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aiTurret.mjs +4 -10
- package/lib/components/ModelCompareV3/data/products/aiTurret.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/efg.js +1 -0
- package/lib/components/ModelCompareV3/data/products/efg.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/efg.mjs +1 -0
- package/lib/components/ModelCompareV3/data/products/efg.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g4Instant.js +2 -10
- package/lib/components/ModelCompareV3/data/products/g4Instant.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g4Instant.mjs +2 -10
- package/lib/components/ModelCompareV3/data/products/g4Instant.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g4Ptz.js +0 -8
- package/lib/components/ModelCompareV3/data/products/g4Ptz.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g4Ptz.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/g4Ptz.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Bullet.js +1 -9
- package/lib/components/ModelCompareV3/data/products/g5Bullet.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Bullet.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/g5Bullet.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Dome.js +3 -11
- package/lib/components/ModelCompareV3/data/products/g5Dome.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Dome.mjs +3 -11
- package/lib/components/ModelCompareV3/data/products/g5Dome.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5DomeUltra.js +2 -10
- package/lib/components/ModelCompareV3/data/products/g5DomeUltra.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5DomeUltra.mjs +2 -10
- package/lib/components/ModelCompareV3/data/products/g5DomeUltra.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Flex.js +2 -10
- package/lib/components/ModelCompareV3/data/products/g5Flex.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Flex.mjs +2 -10
- package/lib/components/ModelCompareV3/data/products/g5Flex.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Pro.js +1 -9
- package/lib/components/ModelCompareV3/data/products/g5Pro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Pro.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/g5Pro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Ptz.js +2 -10
- package/lib/components/ModelCompareV3/data/products/g5Ptz.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Ptz.mjs +2 -10
- package/lib/components/ModelCompareV3/data/products/g5Ptz.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5TurretUltra.js +3 -11
- package/lib/components/ModelCompareV3/data/products/g5TurretUltra.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5TurretUltra.mjs +3 -11
- package/lib/components/ModelCompareV3/data/products/g5TurretUltra.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js +0 -7
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.js +0 -7
- package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +1 -10
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +1 -10
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/theta.js +1 -9
- package/lib/components/ModelCompareV3/data/products/theta.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/theta.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/theta.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/thetaPro.js +1 -9
- package/lib/components/ModelCompareV3/data/products/thetaPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/thetaPro.mjs +1 -9
- package/lib/components/ModelCompareV3/data/products/thetaPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgFiber.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgFiber.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udr7.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udr7.mjs +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.d.ts +0 -3
- package/lib/components/ModelCompareV3/data/properties/index.js +0 -6
- package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.mjs +0 -3
- package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/powerMethodPoe.js +1 -1
- package/lib/components/ModelCompareV3/data/properties/powerMethodPoe.mjs +1 -1
- package/lib/components/ModelCompareV3/data/properties/readerPowerMethod.js +1 -1
- package/lib/components/ModelCompareV3/data/properties/readerPowerMethod.mjs +1 -1
- package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.js +1 -1
- package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.mjs +1 -1
- package/lib/components/ModelCompareV3/data/property-sets/cameraSecurity.js +6 -7
- package/lib/components/ModelCompareV3/data/property-sets/cameraSecurity.js.map +1 -1
- package/lib/components/ModelCompareV3/data/property-sets/cameraSecurity.mjs +6 -7
- package/lib/components/ModelCompareV3/data/property-sets/cameraSecurity.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.js +14 -19
- package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.mjs +14 -19
- package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +0 -600
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +0 -596
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +1 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +0 -4
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +0 -4
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.js +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/poe.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/poe.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/translations/en.json.js +0 -4
- package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +0 -4
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
- package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -3
- package/lib/constants/proStoreCategories/mapping/index.js +0 -15
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +0 -15
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -4
- package/lib/constants/proStoreCategories/mapping/unifi.js +0 -3
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -3
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -8
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +2 -7
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/contexts/MenuContext/context.js +0 -1
- package/lib/contexts/MenuContext/context.js.map +1 -1
- package/lib/contexts/MenuContext/context.mjs +0 -1
- package/lib/contexts/MenuContext/context.mjs.map +1 -1
- package/lib/contexts/MenuContext/mapping.d.ts +1 -3
- package/lib/contexts/MenuContext/mapping.js +3 -3
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +3 -3
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/presets.d.ts +0 -11
- package/lib/contexts/MenuContext/presets.js +4 -16
- package/lib/contexts/MenuContext/presets.js.map +1 -1
- package/lib/contexts/MenuContext/presets.mjs +5 -13
- package/lib/contexts/MenuContext/presets.mjs.map +1 -1
- package/lib/contexts/MenuContext/types.d.ts +0 -3
- package/lib/contexts/MenuContext/types.js +0 -1
- package/lib/contexts/MenuContext/types.js.map +1 -1
- package/lib/contexts/MenuContext/types.mjs +0 -1
- package/lib/contexts/MenuContext/types.mjs.map +1 -1
- package/lib/contexts/MenuContext/utils.js +7 -8
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs +7 -8
- package/lib/contexts/MenuContext/utils.mjs.map +1 -1
- package/lib/utils/cdn.d.ts +5 -0
- package/lib/utils/collectionSlug.d.ts +5 -0
- package/lib/utils/collectionSlug.js +13 -0
- package/lib/utils/collectionSlug.js.map +1 -0
- package/lib/utils/collectionSlug.mjs +12 -0
- package/lib/utils/collectionSlug.mjs.map +1 -0
- package/lib/utils/collectionSlug.test.d.ts +1 -0
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +10 -6
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/index.mjs +10 -6
- package/lib/utils/index.mjs.map +1 -1
- package/lib/utils/money/constants.d.ts +0 -6
- package/lib/utils/money/constants.js +1 -23
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +2 -23
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/nextjs/navigationPresets.d.ts +4 -14
- package/lib/utils/nextjs/navigationPresets.js +6 -22
- package/lib/utils/nextjs/navigationPresets.js.map +1 -1
- package/lib/utils/nextjs/navigationPresets.mjs +7 -23
- package/lib/utils/nextjs/navigationPresets.mjs.map +1 -1
- package/lib/utils/variant.d.ts +8 -0
- package/lib/utils/variant.test.d.ts +1 -0
- package/lib/utils/wattage.d.ts +11 -0
- package/lib/utils/wattage.js +20 -0
- package/lib/utils/wattage.js.map +1 -0
- package/lib/utils/wattage.mjs +18 -0
- package/lib/utils/wattage.mjs.map +1 -0
- package/lib/utils/wattage.test.d.ts +1 -0
- package/package.json +1 -1
- package/lib/assets/ai-3602.jpg +0 -0
- package/lib/assets/ai-dome2.jpg +0 -0
- package/lib/assets/ai-dslr2.jpg +0 -0
- package/lib/assets/ai-lpr2.jpg +0 -0
- package/lib/assets/ai-pro2.jpg +0 -0
- package/lib/assets/ai-theta-pro2.jpg +0 -0
- package/lib/assets/ai-theta2.jpg +0 -0
- package/lib/assets/ai-turret2.jpg +0 -0
- package/lib/assets/crestron.svg +0 -3
- package/lib/assets/g4-instant2.jpg +0 -0
- package/lib/assets/g4-ptz.jpg +0 -0
- package/lib/assets/g5-bullet2.jpg +0 -0
- package/lib/assets/g5-dome-ultra2.jpg +0 -0
- package/lib/assets/g5-dome2.jpg +0 -0
- package/lib/assets/g5-flex2.jpg +0 -0
- package/lib/assets/g5-pro2.jpg +0 -0
- package/lib/assets/g5-ptz2.jpg +0 -0
- package/lib/assets/g5-turret-ultra2.jpg +0 -0
- package/lib/assets/g6-bullet.jpg +0 -0
- package/lib/assets/g6-bullet2.jpg +0 -0
- package/lib/assets/g6-instant.jpg +0 -0
- package/lib/assets/g6-instant2.jpg +0 -0
- package/lib/assets/g6-turret.jpg +0 -0
- package/lib/assets/g6-turret2.jpg +0 -0
- package/lib/assets/ucg-fiber.png +0 -0
- package/lib/assets/udr7.png +0 -0
- package/lib/assets/ux.png +0 -0
- package/lib/assets/ux7.png +0 -0
- package/lib/components/ModelCompareV3/assets/Bullet/g6-bullet.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/Bullet/g6-bullet.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/Bullet/g6-bullet.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/Bullet/g6-bullet.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-360.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-360.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-360.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-360.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dome.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dome.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dome.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dome.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dslr.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dslr.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dslr.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-dslr.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-lpr.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-lpr.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-lpr.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-lpr.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-pro.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-pro.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-pro.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-pro.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta-pro.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta-pro.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta-pro.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta-pro.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-theta.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-turret.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-turret.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-turret.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/ai-turret.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-instant.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-instant.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-instant.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-instant.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-ptz.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-ptz.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-ptz.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g4-ptz.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-bullet.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-bullet.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-bullet.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-bullet.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome-ultra.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome-ultra.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome-ultra.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome-ultra.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-dome.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-flex.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-flex.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-flex.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-flex.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-pro.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-pro.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-pro.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-pro.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-ptz.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-ptz.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-ptz.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-ptz.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-turret-ultra.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-turret-ultra.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-turret-ultra.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-turret-ultra.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-bullet.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-bullet.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-bullet.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-bullet.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-instant.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-instant.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-instant.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-instant.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-turret.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-turret.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-turret.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/CameraSecurity/g6-turret.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/index.d.ts +0 -20
- package/lib/components/ModelCompareV3/assets/CameraSecurity/index.js +0 -24
- package/lib/components/ModelCompareV3/assets/CameraSecurity/index.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/CameraSecurity/index.mjs +0 -22
- package/lib/components/ModelCompareV3/assets/CameraSecurity/index.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/Compact/g6-instant.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/Compact/g6-instant.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/Compact/g6-instant.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/Compact/g6-instant.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/g6-turret.jpg.js +0 -27
- package/lib/components/ModelCompareV3/assets/DomeTurret/g6-turret.jpg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/DomeTurret/g6-turret.jpg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/DomeTurret/g6-turret.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/crestron.svg.js +0 -27
- package/lib/components/ModelCompareV3/assets/crestron.svg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/crestron.svg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/crestron.svg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Bullet.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/products/g6Bullet.js +0 -113
- package/lib/components/ModelCompareV3/data/products/g6Bullet.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Bullet.mjs +0 -105
- package/lib/components/ModelCompareV3/data/products/g6Bullet.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Instant.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/products/g6Instant.js +0 -121
- package/lib/components/ModelCompareV3/data/products/g6Instant.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Instant.mjs +0 -113
- package/lib/components/ModelCompareV3/data/products/g6Instant.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Turret.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/products/g6Turret.js +0 -101
- package/lib/components/ModelCompareV3/data/products/g6Turret.js.map +0 -1
- package/lib/components/ModelCompareV3/data/products/g6Turret.mjs +0 -93
- package/lib/components/ModelCompareV3/data/products/g6Turret.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/aiRecognition.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/properties/aiRecognition.js +0 -20
- package/lib/components/ModelCompareV3/data/properties/aiRecognition.js.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/aiRecognition.mjs +0 -12
- package/lib/components/ModelCompareV3/data/properties/aiRecognition.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js +0 -18
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs +0 -10
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.mjs.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.js +0 -44
- package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.mjs +0 -42
- package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
- package/lib/utils/money/allocators/productAmount.js +0 -75
- package/lib/utils/money/allocators/productAmount.js.map +0 -1
- package/lib/utils/money/allocators/productAmount.mjs +0 -73
- package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
- package/lib/utils/money/exchangeRate.js +0 -27
- package/lib/utils/money/exchangeRate.js.map +0 -1
- package/lib/utils/money/exchangeRate.mjs +0 -23
- package/lib/utils/money/exchangeRate.mjs.map +0 -1
- package/lib/utils/money/format.js +0 -101
- package/lib/utils/money/format.js.map +0 -1
- package/lib/utils/money/format.mjs +0 -96
- package/lib/utils/money/format.mjs.map +0 -1
- package/lib/utils/money/index.js +0 -57
- package/lib/utils/money/index.js.map +0 -1
- package/lib/utils/money/index.mjs +0 -11
- package/lib/utils/money/index.mjs.map +0 -1
- package/lib/utils/money/shipping.js +0 -8
- package/lib/utils/money/shipping.js.map +0 -1
- package/lib/utils/money/shipping.mjs +0 -6
- package/lib/utils/money/shipping.mjs.map +0 -1
- package/lib/utils/money/tax.js +0 -59
- package/lib/utils/money/tax.js.map +0 -1
- package/lib/utils/money/tax.mjs +0 -51
- package/lib/utils/money/tax.mjs.map +0 -1
- package/lib/utils/money/tax.private.js +0 -56
- package/lib/utils/money/tax.private.js.map +0 -1
- package/lib/utils/money/tax.private.mjs +0 -52
- package/lib/utils/money/tax.private.mjs.map +0 -1
- package/lib/utils/money/types.js +0 -3
- package/lib/utils/money/types.js.map +0 -1
- package/lib/utils/money/types.mjs +0 -2
- package/lib/utils/money/types.mjs.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { CAD, GBP, EUR } from '@dinero.js/currencies';
|
|
2
|
-
import { toFormat, hasSubUnits, toUnit } from 'dinero.js';
|
|
3
|
-
import { assert } from '../errors.mjs';
|
|
4
|
-
import { localizedCurrencyLookup, prettifyPriceLookup, Round } from './constants.mjs';
|
|
5
|
-
import { getDinero, roundDinero } from './misc.mjs';
|
|
6
|
-
"use strict";
|
|
7
|
-
const getLocalizedCurrency = currencyCode => {
|
|
8
|
-
return currencyCode ? localizedCurrencyLookup.get(currencyCode) : void 0;
|
|
9
|
-
};
|
|
10
|
-
const currencyFormatterCache = /* @__PURE__ */new Map();
|
|
11
|
-
const getCurrencyFormatter = (locale, currencyCode) => {
|
|
12
|
-
const cacheKey = `${locale}_${currencyCode}`;
|
|
13
|
-
let formatter = currencyFormatterCache.get(cacheKey);
|
|
14
|
-
if (formatter) {
|
|
15
|
-
return formatter;
|
|
16
|
-
}
|
|
17
|
-
formatter = new Intl.NumberFormat(locale, {
|
|
18
|
-
style: "currency",
|
|
19
|
-
currency: currencyCode,
|
|
20
|
-
/**
|
|
21
|
-
* Explicitly define default behavior - just in case some runtime overrides it
|
|
22
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign
|
|
23
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay
|
|
24
|
-
*/
|
|
25
|
-
currencySign: "standard",
|
|
26
|
-
currencyDisplay: "symbol"
|
|
27
|
-
});
|
|
28
|
-
currencyFormatterCache.set(cacheKey, formatter);
|
|
29
|
-
return formatter;
|
|
30
|
-
};
|
|
31
|
-
function formatPriceRaw(dinero, locale, options) {
|
|
32
|
-
return toFormat(dinero, ({
|
|
33
|
-
amount,
|
|
34
|
-
currency
|
|
35
|
-
}) => {
|
|
36
|
-
if (options?.asNegativeAmount) {
|
|
37
|
-
amount = amount === 0 ? 0 : -Math.abs(amount);
|
|
38
|
-
}
|
|
39
|
-
const formatter = getCurrencyFormatter(locale, currency.code);
|
|
40
|
-
const formatted = formatter.format(amount);
|
|
41
|
-
return options?.removeFractions || options?.removeTrailingZeros ? (
|
|
42
|
-
/**
|
|
43
|
-
* Regex to handle complex removing trailing zeros from currency
|
|
44
|
-
* - Dynamically create regex based on currency as their exponent changes
|
|
45
|
-
* - Also handles some currencies (e.g. EUR) having trailing currency symbol
|
|
46
|
-
*
|
|
47
|
-
* TODO: improve how we detect "decimal separator" for formatted currency, at least right now we have tests for it and doesn't seem like an issue
|
|
48
|
-
*/
|
|
49
|
-
formatted.replace(
|
|
50
|
-
// For some reason `\.` need to be double-escaped `\\` when creating the regex from template string
|
|
51
|
-
new RegExp(`(\\.|,)${
|
|
52
|
-
// Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding
|
|
53
|
-
options?.removeFractions ? "\\d" : 0}{0,${currency.exponent}}(\\s\\D)?$`),
|
|
54
|
-
// In the replaced using "last capture group" (if-exists) so we restore the trailing currency sign
|
|
55
|
-
"$2")) : formatted;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const formatPrice = (money, options) => {
|
|
59
|
-
const localizedCurrency = getLocalizedCurrency(money.currency);
|
|
60
|
-
assert(!!localizedCurrency, `Currency ${money.currency} not supported`);
|
|
61
|
-
return formatPriceRaw(getDinero(money.amount, money.currency), localizedCurrency.locale, options);
|
|
62
|
-
};
|
|
63
|
-
const prettifyTotal = total => {
|
|
64
|
-
const totalJson = total.toJSON();
|
|
65
|
-
switch (totalJson.currency.code) {
|
|
66
|
-
// @see: https://ubiquiti.atlassian.net/browse/NEP-3846
|
|
67
|
-
case EUR.code:
|
|
68
|
-
case GBP.code:
|
|
69
|
-
case CAD.code:
|
|
70
|
-
{
|
|
71
|
-
const totalAsFloat = toUnit(total);
|
|
72
|
-
if (totalAsFloat < 10) {
|
|
73
|
-
return roundDinero(total, Round.PrettifyDecimalCents);
|
|
74
|
-
} else if (totalAsFloat < 20) {
|
|
75
|
-
return roundDinero(total, Round.PrettifyHalfUnitCents);
|
|
76
|
-
} else if (totalAsFloat < 50) {
|
|
77
|
-
return roundDinero(total, Round.Prettify);
|
|
78
|
-
} else {
|
|
79
|
-
return roundDinero(total, Round.PrettifyFull059);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
default:
|
|
83
|
-
{
|
|
84
|
-
if (!hasSubUnits(total)) {
|
|
85
|
-
return total;
|
|
86
|
-
}
|
|
87
|
-
const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(totalJson.currency.code);
|
|
88
|
-
if (minValueInclusiveToRoundDownFrom == null || toUnit(total) < minValueInclusiveToRoundDownFrom) {
|
|
89
|
-
return total;
|
|
90
|
-
}
|
|
91
|
-
return roundDinero(total, Round.Prettify);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal };
|
|
96
|
-
//# sourceMappingURL=format.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { CAD, EUR, GBP } from \"@dinero.js/currencies\";\nimport { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n /**\n * Given amount will be treated as negative and formatted accordingly.\n * In our system we don't have stored negative amounts, but this is useful for displaying discount/refunded amounts\n * @default false\n * @example\n * \"420,66 €\" => \"-420,66 €\"\n */\n asNegativeAmount?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n /**\n * Optionally invert the amount to display it as negative\n * Doing math.abs as if we receive already negative amount, we want to keep it as negative. Also special case for 0\n * where we always want to display it as positive\n */\n if (options?.asNegativeAmount) {\n amount = amount === 0 ? 0 : -Math.abs(amount);\n }\n\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n // eslint-disable-next-line sonarjs/deprecation\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n const totalJson = total.toJSON();\n\n switch (totalJson.currency.code) {\n // @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n case EUR.code:\n case GBP.code:\n case CAD.code: {\n const totalAsFloat = toUnit(total);\n\n if (totalAsFloat < 10) {\n return roundDinero(total, Round.PrettifyDecimalCents);\n } else if (totalAsFloat < 20) {\n return roundDinero(total, Round.PrettifyHalfUnitCents);\n } else if (totalAsFloat < 50) {\n return roundDinero(total, Round.Prettify);\n } else {\n return roundDinero(total, Round.PrettifyFull059);\n }\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n }\n }\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","asNegativeAmount","Math","abs","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","EUR","GBP","CAD","totalAsFloat","toUnit","roundDinero","Round","PrettifyDecimalCents","PrettifyHalfUnitCents","Prettify","PrettifyFull059","hasSubUnits","minValueInclusiveToRoundDownFrom","prettifyPriceLookup"],"mappings":";;;;;;AAaa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,CAAA,CAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EAAA;EAGGA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;AAAA;AAAA;AAAA;AAAA;IAMVa,YAAc,EAAA,UAAA;IACdC,eAAiB,EAAA;EAAA,CAClB,CAAA;EACsBX,sBAAA,CAAAY,GAAA,CAAIR,UAAUC,SAAS,CAAA;EAEvC,OAAAA,SAAA;AACT,CAAA;AA4CgB,SAAAQ,cAAAA,CACdC,MACA,EAAAX,MAAA,EACAY,OACQ,EAAA;EACR,OAAOC,SAASF,MAAQ,EAAA,CAAC;IAAEG,MAAA;IAAQR;GAAe,KAAA;IAMhD,IAAIM,SAASG,gBAAkB,EAAA;MAC7BD,MAAA,GAASA,WAAW,CAAI,GAAA,CAAA,GAAI,CAACE,IAAA,CAAKC,IAAIH,MAAM,CAAA;IAAA;IAG9C,MAAMZ,SAAY,GAAAH,oBAAA,CAAqBC,MAAQ,EAAAM,QAAA,CAASY,IAAI,CAAA;IACtD,MAAAC,SAAA,GAAYjB,SAAU,CAAAkB,MAAA,CAAON,MAAM,CAAA;IAElC,OAAAF,OAAA,EAASS,mBAAmBT,OAAS,EAAAU,mBAAA;IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;IAQxCH,SAAU,CAAAI,OAAA;IAAA;IAER,IAAIC,MAAA,CACF;IAAA;IAEEZ,SAASS,eAAkB,GAAA,KAAA,GAAQ,CACrC,MAAMf,SAASmB,QAAQ,aACzB,CAAA;IAAA;IAEA,IAAA,CAAA,IAEFN,SAAA;EAAA,CACL,CAAA;AACH;AAOa,MAAAO,WAAA,GAAcA,CACzBC,KAAA,EACAf,OACW,KAAA;EACL,MAAAgB,iBAAA,GAAoBnC,oBAAqB,CAAAkC,KAAA,CAAMrB,QAAQ,CAAA;EAC7DuB,MAAA,CAAO,CAAC,CAACD,iBAAA,EAAmB,YAAYD,KAAA,CAAMrB,QAAQ,gBAAgB,CAAA;EAG/D,OAAAI,cAAA,CACLoB,SAAU,CAAAH,KAAA,CAAMb,MAAQ,EAAAa,KAAA,CAAMrB,QAAQ,CAAA,EACtCsB,iBAAkB,CAAA5B,MAAA,EAClBY,OACF,CAAA;AACF,CAAA;AAMa,MAAAmB,aAAA,GAAiBC,KAAsB,IAAA;EAC5C,MAAAC,SAAA,GAAYD,MAAME,MAAO,CAAA,CAAA;EAEvB,QAAAD,SAAA,CAAU3B,SAASY,IAAM;IAAA;IAE/B,KAAKiB,GAAI,CAAAjB,IAAA;IACT,KAAKkB,GAAI,CAAAlB,IAAA;IACT,KAAKmB,IAAInB,IAAM;MAAA;QACP,MAAAoB,YAAA,GAAeC,OAAOP,KAAK,CAAA;QAEjC,IAAIM,eAAe,EAAI,EAAA;UACd,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMC,oBAAoB,CAAA;QAAA,CACtD,MAAA,IAAWJ,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAME,qBAAqB,CAAA;QAAA,CACvD,MAAA,IAAWL,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;QAAA,CACnC,MAAA;UACE,OAAAJ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMI,eAAe,CAAA;QAAA;MACjD;IAEF;MAAS;QAEH,IAAA,CAACC,WAAY,CAAAd,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QAAA;QAGT,MAAMe,mCAAmCC,mBAAoB,CAAApD,GAAA,CAC3DqC,UAAU3B,QAAS,CAAAY,IACrB,CAAA;QAGA,IACE6B,gCAAoC,IAAA,IAAA,IACpCR,MAAO,CAAAP,KAAK,IAAIe,gCAChB,EAAA;UACO,OAAAf,KAAA;QAAA;QAGF,OAAAQ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;MAAA;EAC1C;AAEJ,CAAA;"}
|
package/lib/utils/money/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fixedAmount = require('./allocators/fixedAmount.js');
|
|
4
|
-
var productAmount = require('./allocators/productAmount.js');
|
|
5
|
-
var constants = require('./constants.js');
|
|
6
|
-
var exchangeRate = require('./exchangeRate.js');
|
|
7
|
-
var format = require('./format.js');
|
|
8
|
-
var misc = require('./misc.js');
|
|
9
|
-
var shipping = require('./shipping.js');
|
|
10
|
-
var tax = require('./tax.js');
|
|
11
|
-
require('./types.js');
|
|
12
|
-
"use strict";
|
|
13
|
-
exports.FixedAmountAllocator = fixedAmount.FixedAmountAllocator;
|
|
14
|
-
exports.ProductAmountAllocator = productAmount.ProductAmountAllocator;
|
|
15
|
-
exports.EXCHANGE_RATE_DINERO_CURRENCY = constants.EXCHANGE_RATE_DINERO_CURRENCY;
|
|
16
|
-
exports.Round = constants.Round;
|
|
17
|
-
exports.TAX_RATE_DINERO_CURRENCY = constants.TAX_RATE_DINERO_CURRENCY;
|
|
18
|
-
exports.localizedCurrencyLookup = constants.localizedCurrencyLookup;
|
|
19
|
-
exports.prettifyPriceLookup = constants.prettifyPriceLookup;
|
|
20
|
-
exports.roundToNearestDecimalCent = constants.roundToNearestDecimalCent;
|
|
21
|
-
exports.roundToNearestFull059 = constants.roundToNearestFull059;
|
|
22
|
-
exports.roundToNearestHalfUnitCent = constants.roundToNearestHalfUnitCent;
|
|
23
|
-
exports.roundToNearestValidUiCarePrice = constants.roundToNearestValidUiCarePrice;
|
|
24
|
-
exports.smallestSubunitLookup = constants.smallestSubunitLookup;
|
|
25
|
-
exports.storesWithPerItemTaxRate = constants.storesWithPerItemTaxRate;
|
|
26
|
-
exports.invertExchangeRate = exchangeRate.invertExchangeRate;
|
|
27
|
-
exports.toFixedExchangeRate = exchangeRate.toFixedExchangeRate;
|
|
28
|
-
exports.toSnapshotExchangeRate = exchangeRate.toSnapshotExchangeRate;
|
|
29
|
-
exports.formatPrice = format.formatPrice;
|
|
30
|
-
exports.formatPriceRaw = format.formatPriceRaw;
|
|
31
|
-
exports.getLocalizedCurrency = format.getLocalizedCurrency;
|
|
32
|
-
exports.prettifyTotal = format.prettifyTotal;
|
|
33
|
-
exports.addMany = misc.addMany;
|
|
34
|
-
exports.amount = misc.amount;
|
|
35
|
-
exports.centsToCurrencyUnit = misc.centsToCurrencyUnit;
|
|
36
|
-
exports.currency = misc.currency;
|
|
37
|
-
exports.dineroToCurrencyUnit = misc.dineroToCurrencyUnit;
|
|
38
|
-
exports.getDinero = misc.getDinero;
|
|
39
|
-
exports.getDineroCurrency = misc.getDineroCurrency;
|
|
40
|
-
exports.money = misc.money;
|
|
41
|
-
exports.multiplyByFullPercent = misc.multiplyByFullPercent;
|
|
42
|
-
exports.parseCurrencyCode = misc.parseCurrencyCode;
|
|
43
|
-
exports.parseFloatToDinero = misc.parseFloatToDinero;
|
|
44
|
-
exports.parseFloatToDineroRaw = misc.parseFloatToDineroRaw;
|
|
45
|
-
exports.roundDinero = misc.roundDinero;
|
|
46
|
-
exports.stringAmountToDinero = misc.stringAmountToDinero;
|
|
47
|
-
exports.subtractMany = misc.subtractMany;
|
|
48
|
-
exports.toSmallestSubunit = misc.toSmallestSubunit;
|
|
49
|
-
exports.roundShippingPrice = shipping.roundShippingPrice;
|
|
50
|
-
exports.calculateLineItemTax = tax.calculateLineItemTax;
|
|
51
|
-
exports.calculateTotalTaxRate = tax.calculateTotalTaxRate;
|
|
52
|
-
exports.convertDecimalTaxRateToPercentage = tax.convertDecimalTaxRateToPercentage;
|
|
53
|
-
exports.decimalTaxRateToDinero = tax.decimalTaxRateToDinero;
|
|
54
|
-
exports.formatDecimalTaxRate = tax.formatDecimalTaxRate;
|
|
55
|
-
exports.removeTaxAmount = tax.removeTaxAmount;
|
|
56
|
-
exports.stringTaxRateToFloat = tax.stringTaxRateToFloat;
|
|
57
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
|
|
2
|
-
export { ProductAmountAllocator } from './allocators/productAmount.mjs';
|
|
3
|
-
export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, roundToNearestValidUiCarePrice, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
|
|
4
|
-
export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate } from './exchangeRate.mjs';
|
|
5
|
-
export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal } from './format.mjs';
|
|
6
|
-
export { addMany, amount, centsToCurrencyUnit, currency, dineroToCurrencyUnit, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, parseFloatToDineroRaw, roundDinero, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
|
|
7
|
-
export { roundShippingPrice } from './shipping.mjs';
|
|
8
|
-
export { calculateLineItemTax, calculateTotalTaxRate, convertDecimalTaxRateToPercentage, decimalTaxRateToDinero, formatDecimalTaxRate, removeTaxAmount, stringTaxRateToFloat } from './tax.mjs';
|
|
9
|
-
import './types.mjs';
|
|
10
|
-
"use strict";
|
|
11
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var constants = require('./constants.js');
|
|
4
|
-
var misc = require('./misc.js');
|
|
5
|
-
"use strict";
|
|
6
|
-
const roundShippingPrice = price => misc.roundDinero(price, constants.Round.Shipping);
|
|
7
|
-
exports.roundShippingPrice = roundShippingPrice;
|
|
8
|
-
//# sourceMappingURL=shipping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shipping.js","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,IAAY,CAAAA,WAAA,CAAAD,KAAA,EAAOE,gBAAMC,QAAQ,CAAA;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shipping.mjs","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,WAAY,CAAAD,KAAA,EAAOE,MAAMC,QAAQ,CAAA;"}
|
package/lib/utils/money/tax.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dinero_js = require('dinero.js');
|
|
4
|
-
var errors = require('../errors.js');
|
|
5
|
-
var number = require('../number.js');
|
|
6
|
-
var constants = require('./constants.js');
|
|
7
|
-
var tax_private = require('./tax.private.js');
|
|
8
|
-
"use strict";
|
|
9
|
-
const calculateLineItemTax = ({
|
|
10
|
-
itemSummary,
|
|
11
|
-
taxRate,
|
|
12
|
-
storeId
|
|
13
|
-
}) => {
|
|
14
|
-
return constants.storesWithPerItemTaxRate.has(storeId) ? tax_private.calculatePerQtyLineItemTax(itemSummary, taxRate) : tax_private.calculateWholeQtyLineItemTax(itemSummary, taxRate);
|
|
15
|
-
};
|
|
16
|
-
const removeTaxAmount = (baseAmountWithTaxObj, taxRate) => {
|
|
17
|
-
const snapshot = dinero_js.toSnapshot(baseAmountWithTaxObj);
|
|
18
|
-
const taxAmount = constants.Round.Financial(snapshot.amount - snapshot.amount / (1 + taxRate));
|
|
19
|
-
return dinero_js.dinero({
|
|
20
|
-
...snapshot,
|
|
21
|
-
amount: snapshot.amount - taxAmount
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
const convertDecimalTaxRateToPercentage = taxRate => {
|
|
25
|
-
const dineroObj = decimalTaxRateToDinero(taxRate);
|
|
26
|
-
const t = dinero_js.multiply(dineroObj, 100);
|
|
27
|
-
return dinero_js.toUnit(t, {
|
|
28
|
-
digits: constants.TAX_RATE_DINERO_CURRENCY.exponent,
|
|
29
|
-
round: dinero_js.halfEven
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const decimalTaxRateToDinero = taxRate => {
|
|
33
|
-
const parsedNumber = typeof taxRate === "number" ? taxRate : Number.parseFloat(taxRate);
|
|
34
|
-
number.isFloat(parsedNumber);
|
|
35
|
-
const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(constants.TAX_RATE_DINERO_CURRENCY.base, constants.TAX_RATE_DINERO_CURRENCY.exponent)).toFixed(0));
|
|
36
|
-
return dinero_js.dinero({
|
|
37
|
-
amount: parsedNumberInt,
|
|
38
|
-
currency: constants.TAX_RATE_DINERO_CURRENCY
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const formatDecimalTaxRate = taxRate => {
|
|
42
|
-
return `${convertDecimalTaxRateToPercentage(taxRate)}%`;
|
|
43
|
-
};
|
|
44
|
-
const stringTaxRateToFloat = rate => number.toFixedRate(+rate, constants.TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
45
|
-
const calculateTotalTaxRate = rates => {
|
|
46
|
-
const rateSum = rates.reduce((sum, rate) => sum + rate, 0);
|
|
47
|
-
const result = number.toFixedRate(rateSum, constants.TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
48
|
-
errors.assert(result >= 0, "Tax rate must be positive");
|
|
49
|
-
errors.assert(result < 1, "Tax rate must be less than 1");
|
|
50
|
-
return result;
|
|
51
|
-
};
|
|
52
|
-
exports.calculateLineItemTax = calculateLineItemTax;
|
|
53
|
-
exports.calculateTotalTaxRate = calculateTotalTaxRate;
|
|
54
|
-
exports.convertDecimalTaxRateToPercentage = convertDecimalTaxRateToPercentage;
|
|
55
|
-
exports.decimalTaxRateToDinero = decimalTaxRateToDinero;
|
|
56
|
-
exports.formatDecimalTaxRate = formatDecimalTaxRate;
|
|
57
|
-
exports.removeTaxAmount = removeTaxAmount;
|
|
58
|
-
exports.stringTaxRateToFloat = stringTaxRateToFloat;
|
|
59
|
-
//# sourceMappingURL=tax.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tax.js","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import {\n dinero,\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 Round,\n storesWithPerItemTaxRate,\n TAX_RATE_DINERO_CURRENCY,\n} from \"./constants\";\nimport {\n calculatePerQtyLineItemTax,\n calculateWholeQtyLineItemTax,\n} from \"./tax.private\";\nimport type { 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: Dino,\n taxRate: TaxRate,\n) => {\n const snapshot = toSnapshot(baseAmountWithTaxObj);\n\n // Calculate the tax amount and apply rounding on it so that behavior for reverse process is consistent\n const taxAmount = Round.Financial(\n snapshot.amount - snapshot.amount / (1 + taxRate),\n );\n\n return dinero({\n ...snapshot,\n amount: snapshot.amount - taxAmount,\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","taxAmount","Round","Financial","amount","dinero","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":";;;;;;;;AA0BO,MAAMA,uBAAuBA,CAAC;EACnCC,WAAA;EACAC,OAAA;EACAC;AACF,CAIM,KAAA;EACG,OAAAC,kCAAA,CAAyBC,GAAI,CAAAF,OAAO,CACvC,GAAAG,WAAA,CAAAA,0BAAA,CAA2BL,aAAaC,OAAO,CAAA,GAC/CK,WAAAA,CAAAA,4BAA6B,CAAAN,WAAA,EAAaC,OAAO,CAAA;AACvD,CAAA;AAEa,MAAAM,eAAA,GAAkBA,CAC7BC,oBAAA,EACAP,OACG,KAAA;EACG,MAAAQ,QAAA,GAAWC,qBAAWF,oBAAoB,CAAA;EAGhD,MAAMG,YAAYC,SAAAA,CAAAA,KAAM,CAAAC,SAAA,CACtBJ,QAAS,CAAAK,MAAA,GAASL,QAAS,CAAAK,MAAA,IAAU,CAAI,GAAAb,OAAA,CAC3C,CAAA;EAEA,OAAOc,gBAAO,CAAA;IACZ,GAAGN,QAAA;IACHK,MAAA,EAAQL,SAASK,MAAS,GAAAH;EAAA,CAC3B,CAAA;AACH,CAAA;AAWa,MAAAK,iCAAA,GACXf,OACW,IAAA;EACL,MAAAgB,SAAA,GAAYC,uBAAuBjB,OAAO,CAAA;EAC1C,MAAAkB,CAAA,GAAIC,SAAAA,CAAAA,QAAS,CAAAH,SAAA,EAAW,GAAG,CAAA;EACjC,OAAOI,SAAAA,CAAAA,OAAOF,CAAG,EAAA;IACfG,QAAQC,SAAyB,CAAAA,wBAAA,CAAAC,QAAA;IACjCC,KAAO,EAAAC,SAAAA,CAAAA;EAAA,CACR,CAAA;AACH,CAAA;AAEa,MAAAR,sBAAA,GAA0BjB,OAAmC,IAAA;EACxE,MAAM0B,eACJ,OAAO1B,OAAA,KAAY,WAAWA,OAAU,GAAA2B,MAAA,CAAOC,WAAW5B,OAAO,CAAA;EACnE6B,MAAAA,CAAAA,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAE3B,CAAAL,YAAA,GACAM,KAAKC,GAAI,CAAAX,SAAA,CAAAA,wBAAA,CAAyBY,MAAMZ,kCAAyB,CAAAC,QAAQ,CACzE,EAAAY,OAAA,CAAQ,CAAC,CACb,CAAA;EACA,OAAOrB,gBAAO,CAAA;IACZD,MAAQ,EAAAiB,eAAA;IACRM,QAAU,EAAAd,SAAAA,CAAAA;EAAA,CACX,CAAA;AACH,CAAA;AAWa,MAAAe,oBAAA,GACXrC,OACiB,IAAA;EACV,OAAA,GAAGe,iCAAkC,CAAAf,OAAO,CAAC,GAAA;AACtD,CAAA;AAEa,MAAAsC,oBAAA,GAAwBC,IACnC,IAAAC,MAAA,CAAAA,WAAA,CAAY,CAACD,IAAM,EAAAjB,SAAAA,CAAAA,wBAAA,CAAyBC,UAAU,IAAI,CAAA;AAM/C,MAAAkB,qBAAA,GAAyBC,KAA4B,IAAA;EAC1D,MAAAC,OAAA,GAAUD,MAAME,MAAO,CAAA,CAACC,KAAKN,IAAS,KAAAM,GAAA,GAAMN,MAAM,CAAC,CAAA;EACzD,MAAMO,MAAS,GAAAN,MAAAA,CAAAA,WAAA,CAAYG,OAAS,EAAArB,SAAAA,CAAAA,wBAAA,CAAyBC,UAAU,IAAI,CAAA;EACpEwB,aAAA,CAAAD,MAAA,IAAU,GAAG,2BAA2B,CAAA;EACxCC,aAAA,CAAAD,MAAA,GAAS,GAAG,8BAA8B,CAAA;EAC1C,OAAAA,MAAA;AACT,CAAA;;;;;;;"}
|
package/lib/utils/money/tax.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { toSnapshot, dinero, multiply, toUnit, halfEven } from 'dinero.js';
|
|
2
|
-
import { assert } from '../errors.mjs';
|
|
3
|
-
import { isFloat, toFixedRate } from '../number.mjs';
|
|
4
|
-
import { storesWithPerItemTaxRate, Round, TAX_RATE_DINERO_CURRENCY } from './constants.mjs';
|
|
5
|
-
import { calculatePerQtyLineItemTax, calculateWholeQtyLineItemTax } from './tax.private.mjs';
|
|
6
|
-
"use strict";
|
|
7
|
-
const calculateLineItemTax = ({
|
|
8
|
-
itemSummary,
|
|
9
|
-
taxRate,
|
|
10
|
-
storeId
|
|
11
|
-
}) => {
|
|
12
|
-
return storesWithPerItemTaxRate.has(storeId) ? calculatePerQtyLineItemTax(itemSummary, taxRate) : calculateWholeQtyLineItemTax(itemSummary, taxRate);
|
|
13
|
-
};
|
|
14
|
-
const removeTaxAmount = (baseAmountWithTaxObj, taxRate) => {
|
|
15
|
-
const snapshot = toSnapshot(baseAmountWithTaxObj);
|
|
16
|
-
const taxAmount = Round.Financial(snapshot.amount - snapshot.amount / (1 + taxRate));
|
|
17
|
-
return dinero({
|
|
18
|
-
...snapshot,
|
|
19
|
-
amount: snapshot.amount - taxAmount
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const convertDecimalTaxRateToPercentage = taxRate => {
|
|
23
|
-
const dineroObj = decimalTaxRateToDinero(taxRate);
|
|
24
|
-
const t = multiply(dineroObj, 100);
|
|
25
|
-
return toUnit(t, {
|
|
26
|
-
digits: TAX_RATE_DINERO_CURRENCY.exponent,
|
|
27
|
-
round: halfEven
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const decimalTaxRateToDinero = taxRate => {
|
|
31
|
-
const parsedNumber = typeof taxRate === "number" ? taxRate : Number.parseFloat(taxRate);
|
|
32
|
-
isFloat(parsedNumber);
|
|
33
|
-
const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(TAX_RATE_DINERO_CURRENCY.base, TAX_RATE_DINERO_CURRENCY.exponent)).toFixed(0));
|
|
34
|
-
return dinero({
|
|
35
|
-
amount: parsedNumberInt,
|
|
36
|
-
currency: TAX_RATE_DINERO_CURRENCY
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
const formatDecimalTaxRate = taxRate => {
|
|
40
|
-
return `${convertDecimalTaxRateToPercentage(taxRate)}%`;
|
|
41
|
-
};
|
|
42
|
-
const stringTaxRateToFloat = rate => toFixedRate(+rate, TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
43
|
-
const calculateTotalTaxRate = rates => {
|
|
44
|
-
const rateSum = rates.reduce((sum, rate) => sum + rate, 0);
|
|
45
|
-
const result = toFixedRate(rateSum, TAX_RATE_DINERO_CURRENCY.exponent, true);
|
|
46
|
-
assert(result >= 0, "Tax rate must be positive");
|
|
47
|
-
assert(result < 1, "Tax rate must be less than 1");
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
export { calculateLineItemTax, calculateTotalTaxRate, convertDecimalTaxRateToPercentage, decimalTaxRateToDinero, formatDecimalTaxRate, removeTaxAmount, stringTaxRateToFloat };
|
|
51
|
-
//# sourceMappingURL=tax.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tax.mjs","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import {\n dinero,\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 Round,\n storesWithPerItemTaxRate,\n TAX_RATE_DINERO_CURRENCY,\n} from \"./constants\";\nimport {\n calculatePerQtyLineItemTax,\n calculateWholeQtyLineItemTax,\n} from \"./tax.private\";\nimport type { 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: Dino,\n taxRate: TaxRate,\n) => {\n const snapshot = toSnapshot(baseAmountWithTaxObj);\n\n // Calculate the tax amount and apply rounding on it so that behavior for reverse process is consistent\n const taxAmount = Round.Financial(\n snapshot.amount - snapshot.amount / (1 + taxRate),\n );\n\n return dinero({\n ...snapshot,\n amount: snapshot.amount - taxAmount,\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","taxAmount","Round","Financial","amount","dinero","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":";;;;;;AA0BO,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;EAGhD,MAAMG,YAAYC,KAAM,CAAAC,SAAA,CACtBJ,QAAS,CAAAK,MAAA,GAASL,QAAS,CAAAK,MAAA,IAAU,CAAI,GAAAb,OAAA,CAC3C,CAAA;EAEA,OAAOc,MAAO,CAAA;IACZ,GAAGN,QAAA;IACHK,MAAA,EAAQL,SAASK,MAAS,GAAAH;EAAA,CAC3B,CAAA;AACH,CAAA;AAWa,MAAAK,iCAAA,GACXf,OACW,IAAA;EACL,MAAAgB,SAAA,GAAYC,uBAAuBjB,OAAO,CAAA;EAC1C,MAAAkB,CAAA,GAAIC,QAAS,CAAAH,SAAA,EAAW,GAAG,CAAA;EACjC,OAAOI,OAAOF,CAAG,EAAA;IACfG,QAAQC,wBAAyB,CAAAC,QAAA;IACjCC,KAAO,EAAAC;EAAA,CACR,CAAA;AACH,CAAA;AAEa,MAAAR,sBAAA,GAA0BjB,OAAmC,IAAA;EACxE,MAAM0B,eACJ,OAAO1B,OAAA,KAAY,WAAWA,OAAU,GAAA2B,MAAA,CAAOC,WAAW5B,OAAO,CAAA;EACnE6B,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAE3B,CAAAL,YAAA,GACAM,KAAKC,GAAI,CAAAX,wBAAA,CAAyBY,MAAMZ,wBAAyB,CAAAC,QAAQ,CACzE,EAAAY,OAAA,CAAQ,CAAC,CACb,CAAA;EACA,OAAOrB,MAAO,CAAA;IACZD,MAAQ,EAAAiB,eAAA;IACRM,QAAU,EAAAd;EAAA,CACX,CAAA;AACH,CAAA;AAWa,MAAAe,oBAAA,GACXrC,OACiB,IAAA;EACV,OAAA,GAAGe,iCAAkC,CAAAf,OAAO,CAAC,GAAA;AACtD,CAAA;AAEa,MAAAsC,oBAAA,GAAwBC,IACnC,IAAAC,WAAA,CAAY,CAACD,IAAM,EAAAjB,wBAAA,CAAyBC,UAAU,IAAI,CAAA;AAM/C,MAAAkB,qBAAA,GAAyBC,KAA4B,IAAA;EAC1D,MAAAC,OAAA,GAAUD,MAAME,MAAO,CAAA,CAACC,KAAKN,IAAS,KAAAM,GAAA,GAAMN,MAAM,CAAC,CAAA;EACzD,MAAMO,MAAS,GAAAN,WAAA,CAAYG,OAAS,EAAArB,wBAAA,CAAyBC,UAAU,IAAI,CAAA;EACpEwB,MAAA,CAAAD,MAAA,IAAU,GAAG,2BAA2B,CAAA;EACxCC,MAAA,CAAAD,MAAA,GAAS,GAAG,8BAA8B,CAAA;EAC1C,OAAAA,MAAA;AACT,CAAA;"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dinero_js = require('dinero.js');
|
|
4
|
-
var fixedAmount = require('./allocators/fixedAmount.js');
|
|
5
|
-
var constants = require('./constants.js');
|
|
6
|
-
var misc = require('./misc.js');
|
|
7
|
-
"use strict";
|
|
8
|
-
const allocatePerItemTaxableAmount = itemSummary => {
|
|
9
|
-
if (itemSummary.quantity === 1) {
|
|
10
|
-
return [itemSummary];
|
|
11
|
-
}
|
|
12
|
-
const preDiscountAmount = dinero_js.add(misc.getDinero(itemSummary.taxableAmount, itemSummary.currency), misc.getDinero(itemSummary.discountAmount, itemSummary.currency));
|
|
13
|
-
const allocator = new fixedAmount.FixedAmountAllocator({
|
|
14
|
-
initialAllocateAmount: itemSummary.discountAmount,
|
|
15
|
-
initialTotalAmount: misc.amount(preDiscountAmount),
|
|
16
|
-
currency: itemSummary.currency
|
|
17
|
-
});
|
|
18
|
-
return Array.from({
|
|
19
|
-
length: itemSummary.quantity
|
|
20
|
-
}, () => {
|
|
21
|
-
const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
|
|
22
|
-
const taxableAmount = dinero_js.subtract(misc.getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
|
|
23
|
-
return {
|
|
24
|
-
itemPrice: itemSummary.itemPrice,
|
|
25
|
-
taxableAmount: misc.amount(taxableAmount),
|
|
26
|
-
discountAmount: misc.amount(discountAllocatedAmount),
|
|
27
|
-
currency: itemSummary.currency,
|
|
28
|
-
quantity: 1
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
|
|
33
|
-
if (taxRate === 0) {
|
|
34
|
-
return misc.getDinero(0, itemSummary.currency);
|
|
35
|
-
}
|
|
36
|
-
return dinero_js.dinero({
|
|
37
|
-
amount: constants.Round.Financial(itemSummary.taxableAmount * taxRate),
|
|
38
|
-
currency: misc.getDineroCurrency(itemSummary.currency)
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
|
|
42
|
-
if (taxRate === 0) {
|
|
43
|
-
return misc.getDinero(0, itemSummary.currency);
|
|
44
|
-
}
|
|
45
|
-
const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
|
|
46
|
-
let totalTaxAmount = misc.getDinero(0, itemSummary.currency);
|
|
47
|
-
singleItemSummaries.forEach(itemSummary2 => {
|
|
48
|
-
const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
|
|
49
|
-
totalTaxAmount = dinero_js.add(totalTaxAmount, taxAmount);
|
|
50
|
-
});
|
|
51
|
-
return totalTaxAmount;
|
|
52
|
-
};
|
|
53
|
-
exports.allocatePerItemTaxableAmount = allocatePerItemTaxableAmount;
|
|
54
|
-
exports.calculatePerQtyLineItemTax = calculatePerQtyLineItemTax;
|
|
55
|
-
exports.calculateWholeQtyLineItemTax = calculateWholeQtyLineItemTax;
|
|
56
|
-
//# sourceMappingURL=tax.private.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tax.private.js","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport { add, dinero, subtract } from \"dinero.js\";\n\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { Round } from \"./constants\";\nimport { amount, getDinero, getDineroCurrency } from \"./misc\";\nimport type {\n Dino,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\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): Dino => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * Historically we calculate the tax by using dinero allocation, but we did not have control over how we round things.\n * So instead as we are already working with currency in cents we can multiply and round it ourselves.\n */\n return dinero({\n amount: Round.Financial(itemSummary.taxableAmount * taxRate),\n currency: getDineroCurrency(itemSummary.currency),\n });\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dino => {\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":["allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","length","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxRate","dinero","Round","Financial","getDineroCurrency","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach","taxAmount"],"mappings":";;;;;;;AAoBa,MAAAA,4BAAA,GACXC,WAC4B,IAAA;EAIxB,IAAAA,WAAA,CAAYC,aAAa,CAAG,EAAA;IAC9B,OAAO,CAACD,WAAoC,CAAA;EAAA;EAI9C,MAAME,iBAAoB,GAAAC,SAAA,CAAAA,GAAA,CACxBC,IAAAA,CAAAA,SAAU,CAAAJ,WAAA,CAAYK,aAAe,EAAAL,WAAA,CAAYM,QAAQ,CAAA,EACzDF,IAAAA,CAAAA,SAAU,CAAAJ,WAAA,CAAYO,cAAgB,EAAAP,WAAA,CAAYM,QAAQ,CAC5D,CAAA;EAEM,MAAAE,SAAA,GAAY,IAAIC,gCAAqB,CAAA;IACzCC,uBAAuBV,WAAY,CAAAO,cAAA;IACnCI,kBAAA,EAAoBC,YAAOV,iBAAiB,CAAA;IAC5CI,UAAUN,WAAY,CAAAM;EAAA,CACvB,CAAA;EAGD,OAAOO,MAAMC,IAAK,CAAA;IAAEC,QAAQf,WAAY,CAAAC;EAAA,GAAY,MAAM;IACxD,MAAMe,0BAA0BR,SAAU,CAAAS,QAAA,CACxCjB,WAAY,CAAAkB,SAAA,EACZlB,WAAY,CAAAM,QACd,CAAA;IAEA,MAAMD,aAAgB,GAAAc,SAAA,CAAAA,QAAA,CACpBf,IAAAA,CAAAA,SAAU,CAAAJ,WAAA,CAAYkB,SAAW,EAAAlB,WAAA,CAAYM,QAAQ,CAAA,EACrDU,uBACF,CAAA;IAEO,OAAA;MACLE,WAAWlB,WAAY,CAAAkB,SAAA;MACvBb,aAAA,EAAeO,YAAOP,aAAa,CAAA;MACnCE,cAAA,EAAgBK,YAAOI,uBAAuB,CAAA;MAC9CV,UAAUN,WAAY,CAAAM,QAAA;MACtBL,QAAU,EAAA;IACZ,CAAA;EAAA,CACD,CAAA;AACH,CAAA;AAEa,MAAAmB,4BAAA,GAA+BA,CAC1CpB,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,cAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAAA;EAO1C,OAAOgB,gBAAO,CAAA;IACZV,MAAQ,EAAAW,SAAAA,CAAAA,KAAA,CAAMC,SAAU,CAAAxB,WAAA,CAAYK,gBAAgBgB,OAAO,CAAA;IAC3Df,QAAA,EAAUmB,IAAAA,CAAAA,iBAAkB,CAAAzB,WAAA,CAAYM,QAAQ;EAAA,CACjD,CAAA;AACH,CAAA;AAEa,MAAAoB,0BAAA,GAA6BA,CACxC1B,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,cAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAAA;EAIpC,MAAAqB,mBAAA,GAAsB5B,6BAA6BC,WAAW,CAAA;EAGpE,IAAI4B,cAAiB,GAAAxB,IAAA,CAAAA,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCqB,mBAAA,CAAAE,OAAA,CAAS7B,YAAgB,IAAA;IAGrC,MAAA8B,SAAA,GAAYV,4BAA6BpB,CAAAA,YAAAA,EAAaqB,OAAO,CAAA;IAClDO,cAAA,GAAAzB,SAAAA,CAAAA,GAAA,CAAIyB,gBAAgBE,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAF,cAAA;AACT,CAAA;;;"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { add, subtract, dinero } from 'dinero.js';
|
|
2
|
-
import { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
|
|
3
|
-
import { Round } from './constants.mjs';
|
|
4
|
-
import { getDinero, amount, getDineroCurrency } from './misc.mjs';
|
|
5
|
-
"use strict";
|
|
6
|
-
const allocatePerItemTaxableAmount = itemSummary => {
|
|
7
|
-
if (itemSummary.quantity === 1) {
|
|
8
|
-
return [itemSummary];
|
|
9
|
-
}
|
|
10
|
-
const preDiscountAmount = add(getDinero(itemSummary.taxableAmount, itemSummary.currency), getDinero(itemSummary.discountAmount, itemSummary.currency));
|
|
11
|
-
const allocator = new FixedAmountAllocator({
|
|
12
|
-
initialAllocateAmount: itemSummary.discountAmount,
|
|
13
|
-
initialTotalAmount: amount(preDiscountAmount),
|
|
14
|
-
currency: itemSummary.currency
|
|
15
|
-
});
|
|
16
|
-
return Array.from({
|
|
17
|
-
length: itemSummary.quantity
|
|
18
|
-
}, () => {
|
|
19
|
-
const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
|
|
20
|
-
const taxableAmount = subtract(getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
|
|
21
|
-
return {
|
|
22
|
-
itemPrice: itemSummary.itemPrice,
|
|
23
|
-
taxableAmount: amount(taxableAmount),
|
|
24
|
-
discountAmount: amount(discountAllocatedAmount),
|
|
25
|
-
currency: itemSummary.currency,
|
|
26
|
-
quantity: 1
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
|
|
31
|
-
if (taxRate === 0) {
|
|
32
|
-
return getDinero(0, itemSummary.currency);
|
|
33
|
-
}
|
|
34
|
-
return dinero({
|
|
35
|
-
amount: Round.Financial(itemSummary.taxableAmount * taxRate),
|
|
36
|
-
currency: getDineroCurrency(itemSummary.currency)
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
|
|
40
|
-
if (taxRate === 0) {
|
|
41
|
-
return getDinero(0, itemSummary.currency);
|
|
42
|
-
}
|
|
43
|
-
const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
|
|
44
|
-
let totalTaxAmount = getDinero(0, itemSummary.currency);
|
|
45
|
-
singleItemSummaries.forEach(itemSummary2 => {
|
|
46
|
-
const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
|
|
47
|
-
totalTaxAmount = add(totalTaxAmount, taxAmount);
|
|
48
|
-
});
|
|
49
|
-
return totalTaxAmount;
|
|
50
|
-
};
|
|
51
|
-
export { allocatePerItemTaxableAmount, calculatePerQtyLineItemTax, calculateWholeQtyLineItemTax };
|
|
52
|
-
//# sourceMappingURL=tax.private.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { add, dinero, subtract } from \"dinero.js\";\n\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { Round } from \"./constants\";\nimport { amount, getDinero, getDineroCurrency } from \"./misc\";\nimport type {\n Dino,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\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): Dino => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * Historically we calculate the tax by using dinero allocation, but we did not have control over how we round things.\n * So instead as we are already working with currency in cents we can multiply and round it ourselves.\n */\n return dinero({\n amount: Round.Financial(itemSummary.taxableAmount * taxRate),\n currency: getDineroCurrency(itemSummary.currency),\n });\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dino => {\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":["allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","length","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxRate","dinero","Round","Financial","getDineroCurrency","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach","taxAmount"],"mappings":";;;;;AAoBa,MAAAA,4BAAA,GACXC,WAC4B,IAAA;EAIxB,IAAAA,WAAA,CAAYC,aAAa,CAAG,EAAA;IAC9B,OAAO,CAACD,WAAoC,CAAA;EAAA;EAI9C,MAAME,iBAAoB,GAAAC,GAAA,CACxBC,SAAU,CAAAJ,WAAA,CAAYK,aAAe,EAAAL,WAAA,CAAYM,QAAQ,CAAA,EACzDF,SAAU,CAAAJ,WAAA,CAAYO,cAAgB,EAAAP,WAAA,CAAYM,QAAQ,CAC5D,CAAA;EAEM,MAAAE,SAAA,GAAY,IAAIC,oBAAqB,CAAA;IACzCC,uBAAuBV,WAAY,CAAAO,cAAA;IACnCI,kBAAA,EAAoBC,OAAOV,iBAAiB,CAAA;IAC5CI,UAAUN,WAAY,CAAAM;EAAA,CACvB,CAAA;EAGD,OAAOO,MAAMC,IAAK,CAAA;IAAEC,QAAQf,WAAY,CAAAC;EAAA,GAAY,MAAM;IACxD,MAAMe,0BAA0BR,SAAU,CAAAS,QAAA,CACxCjB,WAAY,CAAAkB,SAAA,EACZlB,WAAY,CAAAM,QACd,CAAA;IAEA,MAAMD,aAAgB,GAAAc,QAAA,CACpBf,SAAU,CAAAJ,WAAA,CAAYkB,SAAW,EAAAlB,WAAA,CAAYM,QAAQ,CAAA,EACrDU,uBACF,CAAA;IAEO,OAAA;MACLE,WAAWlB,WAAY,CAAAkB,SAAA;MACvBb,aAAA,EAAeO,OAAOP,aAAa,CAAA;MACnCE,cAAA,EAAgBK,OAAOI,uBAAuB,CAAA;MAC9CV,UAAUN,WAAY,CAAAM,QAAA;MACtBL,QAAU,EAAA;IACZ,CAAA;EAAA,CACD,CAAA;AACH,CAAA;AAEa,MAAAmB,4BAAA,GAA+BA,CAC1CpB,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAAA;EAO1C,OAAOgB,MAAO,CAAA;IACZV,MAAQ,EAAAW,KAAA,CAAMC,SAAU,CAAAxB,WAAA,CAAYK,gBAAgBgB,OAAO,CAAA;IAC3Df,QAAA,EAAUmB,iBAAkB,CAAAzB,WAAA,CAAYM,QAAQ;EAAA,CACjD,CAAA;AACH,CAAA;AAEa,MAAAoB,0BAAA,GAA6BA,CACxC1B,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAAA;EAIpC,MAAAqB,mBAAA,GAAsB5B,6BAA6BC,WAAW,CAAA;EAGpE,IAAI4B,cAAiB,GAAAxB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCqB,mBAAA,CAAAE,OAAA,CAAS7B,YAAgB,IAAA;IAGrC,MAAA8B,SAAA,GAAYV,4BAA6BpB,CAAAA,YAAAA,EAAaqB,OAAO,CAAA;IAClDO,cAAA,GAAAzB,GAAA,CAAIyB,gBAAgBE,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAF,cAAA;AACT,CAAA;"}
|
package/lib/utils/money/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|