@ubnt/store.core 11.12.0-beta.1 → 11.12.0-beta.2
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 +4 -0
- package/lib/assets/ai-360.jpg +0 -0
- package/lib/assets/ai-3602.jpg +0 -0
- package/lib/assets/ai-lpr.jpg +0 -0
- package/lib/assets/ai-lpr2.jpg +0 -0
- package/lib/assets/ai-theta.jpg +0 -0
- package/lib/assets/ai-theta2.jpg +0 -0
- package/lib/assets/attention.svg +1 -1
- package/lib/assets/attention2.svg +1 -1
- package/lib/assets/door-hub-mini.jpg +0 -0
- package/lib/assets/door-hub-mini2.jpg +0 -0
- package/lib/assets/g2-reader-pro.jpg +0 -0
- package/lib/assets/g2-reader-pro2.jpg +0 -0
- package/lib/assets/g3-reader-flex.jpg +0 -0
- package/lib/assets/g3-reader-flex2.jpg +0 -0
- package/lib/assets/g3-reader-pro.jpg +0 -0
- package/lib/assets/g3-reader-pro2.jpg +0 -0
- package/lib/assets/g3-reader.jpg +0 -0
- package/lib/assets/g3-reader2.jpg +0 -0
- package/lib/assets/g3-starter-kit-pro.jpg +0 -0
- package/lib/assets/g3-starter-kit-pro2.jpg +0 -0
- package/lib/assets/g5-dome.jpg +0 -0
- package/lib/assets/g5-dome2.jpg +0 -0
- package/lib/assets/g5-flex.jpg +0 -0
- package/lib/assets/g5-flex2.jpg +0 -0
- package/lib/assets/g5-turret-ultra.jpg +0 -0
- package/lib/assets/g5-turret-ultra2.jpg +0 -0
- package/lib/assets/intercom.jpg +0 -0
- package/lib/assets/intercom2.jpg +0 -0
- package/lib/assets/interior-design.svg +1 -1
- package/lib/assets/interior-design2.svg +1 -1
- package/lib/assets/minus4.svg +1 -1
- package/lib/assets/minus5.svg +1 -1
- package/lib/assets/plus4.svg +1 -1
- package/lib/assets/plus5.svg +1 -1
- package/lib/assets/ptz2.svg +1 -1
- package/lib/assets/ptz3.svg +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/InputSections/CounterSection.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/Bullet/ai-lpr.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/Bullet/ai-lpr.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/Compact/g5-flex.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/Compact/g5-flex.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DomeTurret/ai-360.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DomeTurret/ai-360.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DomeTurret/g5-dome.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DomeTurret/g5-dome.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DomeTurret/g5-turret-ultra.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DomeTurret/g5-turret-ultra.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/door-hub-mini.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/door-hub-mini.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/g2-reader-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/g2-reader-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader-flex.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader-flex.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-reader.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-starter-kit-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/g3-starter-kit-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/DoorAccess/intercom.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/DoorAccess/intercom.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/Interior/ai-theta.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/Interior/ai-theta.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/interior-design.svg.js +1 -1
- package/lib/constants/modelCompareData/assets/interior-design.svg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/bullet/ai-lpr.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/bullet/ai-lpr.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/compact/g5-flex.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/compact/g5-flex.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/ai-360.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/ai-360.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/g5-dome.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/g5-dome.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/g5-turret-ultra.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/g5-turret-ultra.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/door-hub-mini.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/door-hub-mini.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g2-reader-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g2-reader-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader-flex.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader-flex.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-reader.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-starter-kit-pro.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/g3-starter-kit-pro.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/intercom.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/door-access/intercom.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/interior-design/ai-theta.jpg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/cameras/interior-design/ai-theta.jpg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/interior-design.svg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/interior-design.svg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/product-list-assets/ptz.svg.js +1 -1
- package/lib/constants/modelCompareData/assets/product-list-assets/ptz.svg.mjs +2 -2
- package/lib/constants/modelCompareData/assets/ptz.svg.js +1 -1
- package/lib/constants/modelCompareData/assets/ptz.svg.mjs +2 -2
- package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/InteriorDesign.js +1 -1
- package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/InteriorDesign.mjs +1 -1
- package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/Ptz.js +1 -1
- package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/Ptz.mjs +1 -1
- package/lib/constants/modelCompareData/data/product-list-groups/interiorDesign.js +1 -1
- package/lib/constants/modelCompareData/data/product-list-groups/interiorDesign.mjs +1 -1
- package/lib/constants/modelCompareData/data/product-list-groups/ptz.js +1 -1
- package/lib/constants/modelCompareData/data/product-list-groups/ptz.mjs +1 -1
- package/lib/constants/modelCompareData/data/products/ai360.js +2 -2
- package/lib/constants/modelCompareData/data/products/ai360.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/aiLpr.js +2 -2
- package/lib/constants/modelCompareData/data/products/aiLpr.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/doorHubMini.js +2 -2
- package/lib/constants/modelCompareData/data/products/doorHubMini.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g2ReaderPro.js +2 -2
- package/lib/constants/modelCompareData/data/products/g2ReaderPro.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g3Reader.js +2 -2
- package/lib/constants/modelCompareData/data/products/g3Reader.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g3ReaderFlex.js +2 -2
- package/lib/constants/modelCompareData/data/products/g3ReaderFlex.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g3ReaderPro.js +2 -2
- package/lib/constants/modelCompareData/data/products/g3ReaderPro.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g3StarterKitPro.js +2 -2
- package/lib/constants/modelCompareData/data/products/g3StarterKitPro.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g5Dome.js +2 -2
- package/lib/constants/modelCompareData/data/products/g5Dome.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g5Flex.js +2 -2
- package/lib/constants/modelCompareData/data/products/g5Flex.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/g5TurretUltra.js +2 -2
- package/lib/constants/modelCompareData/data/products/g5TurretUltra.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/intercom.js +2 -2
- package/lib/constants/modelCompareData/data/products/intercom.mjs +2 -2
- package/lib/constants/modelCompareData/data/products/theta.js +2 -2
- package/lib/constants/modelCompareData/data/products/theta.mjs +2 -2
- package/lib/utils/money/constants.d.ts +5 -0
- package/lib/utils/money/constants.js +6 -1
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +7 -2
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/tax.d.ts +1 -1
- package/lib/utils/money/tax.js +6 -1
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +8 -3
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/tax.private.d.ts +2 -2
- package/lib/utils/money/tax.private.js +3 -3
- package/lib/utils/money/tax.private.js.map +1 -1
- package/lib/utils/money/tax.private.mjs +3 -3
- package/lib/utils/money/tax.private.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -16,8 +16,8 @@ var mobileTap = require('../properties/mobileTap.js');
|
|
|
16
16
|
var hand = require('../properties/hand.js');
|
|
17
17
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
18
18
|
var readerPowerMethod = require('../properties/readerPowerMethod.js');
|
|
19
|
-
var v3Image = require("../../../../assets/g2-reader-
|
|
20
|
-
var image = require("../../../../assets/g2-reader-
|
|
19
|
+
var v3Image = require("../../../../assets/g2-reader-pro2.jpg");
|
|
20
|
+
var image = require("../../../../assets/g2-reader-pro.jpg");
|
|
21
21
|
function _interopDefault(e) {
|
|
22
22
|
return e && e.__esModule ? e : {
|
|
23
23
|
default: e
|
|
@@ -14,8 +14,8 @@ import { mobileTap } from '../properties/mobileTap.mjs';
|
|
|
14
14
|
import { hand } from '../properties/hand.mjs';
|
|
15
15
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
16
16
|
import { readerPowerMethod } from '../properties/readerPowerMethod.mjs';
|
|
17
|
-
import v3Image__default from "../../../../assets/g2-reader-
|
|
18
|
-
import image__default from "../../../../assets/g2-reader-
|
|
17
|
+
import v3Image__default from "../../../../assets/g2-reader-pro2.jpg";
|
|
18
|
+
import image__default from "../../../../assets/g2-reader-pro.jpg";
|
|
19
19
|
"use strict";
|
|
20
20
|
const g2ReaderPro = {
|
|
21
21
|
id: "g2ReaderPro",
|
|
@@ -17,8 +17,8 @@ var mobileAppAccess = require('../properties/mobileAppAccess.js');
|
|
|
17
17
|
var hand = require('../properties/hand.js');
|
|
18
18
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
19
19
|
var readerPowerMethod = require('../properties/readerPowerMethod.js');
|
|
20
|
-
var v3Image = require("../../../../assets/g3-
|
|
21
|
-
var image = require("../../../../assets/g3-
|
|
20
|
+
var v3Image = require("../../../../assets/g3-reader2.jpg");
|
|
21
|
+
var image = require("../../../../assets/g3-reader.jpg");
|
|
22
22
|
function _interopDefault(e) {
|
|
23
23
|
return e && e.__esModule ? e : {
|
|
24
24
|
default: e
|
|
@@ -15,8 +15,8 @@ import { mobileAppAccess } from '../properties/mobileAppAccess.mjs';
|
|
|
15
15
|
import { hand } from '../properties/hand.mjs';
|
|
16
16
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
17
17
|
import { readerPowerMethod } from '../properties/readerPowerMethod.mjs';
|
|
18
|
-
import v3Image__default from "../../../../assets/g3-
|
|
19
|
-
import image__default from "../../../../assets/g3-
|
|
18
|
+
import v3Image__default from "../../../../assets/g3-reader2.jpg";
|
|
19
|
+
import image__default from "../../../../assets/g3-reader.jpg";
|
|
20
20
|
"use strict";
|
|
21
21
|
const g3Reader = {
|
|
22
22
|
id: "g3Reader",
|
|
@@ -17,8 +17,8 @@ var mobileAppAccess = require('../properties/mobileAppAccess.js');
|
|
|
17
17
|
var hand = require('../properties/hand.js');
|
|
18
18
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
19
19
|
var readerPowerMethod = require('../properties/readerPowerMethod.js');
|
|
20
|
-
var v3Image = require("../../../../assets/g3-reader-
|
|
21
|
-
var image = require("../../../../assets/g3-reader-
|
|
20
|
+
var v3Image = require("../../../../assets/g3-reader-flex.jpg");
|
|
21
|
+
var image = require("../../../../assets/g3-reader-flex2.jpg");
|
|
22
22
|
function _interopDefault(e) {
|
|
23
23
|
return e && e.__esModule ? e : {
|
|
24
24
|
default: e
|
|
@@ -15,8 +15,8 @@ import { mobileAppAccess } from '../properties/mobileAppAccess.mjs';
|
|
|
15
15
|
import { hand } from '../properties/hand.mjs';
|
|
16
16
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
17
17
|
import { readerPowerMethod } from '../properties/readerPowerMethod.mjs';
|
|
18
|
-
import v3Image__default from "../../../../assets/g3-reader-
|
|
19
|
-
import image__default from "../../../../assets/g3-reader-
|
|
18
|
+
import v3Image__default from "../../../../assets/g3-reader-flex.jpg";
|
|
19
|
+
import image__default from "../../../../assets/g3-reader-flex2.jpg";
|
|
20
20
|
"use strict";
|
|
21
21
|
const g3ReaderFlex = {
|
|
22
22
|
id: "g3ReaderFlex",
|
|
@@ -17,8 +17,8 @@ var mobileAppAccess = require('../properties/mobileAppAccess.js');
|
|
|
17
17
|
var hand = require('../properties/hand.js');
|
|
18
18
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
19
19
|
var readerPowerMethod = require('../properties/readerPowerMethod.js');
|
|
20
|
-
var v3Image = require("../../../../assets/g3-reader-
|
|
21
|
-
var productImage = require("../../../../assets/g3-reader-
|
|
20
|
+
var v3Image = require("../../../../assets/g3-reader-pro2.jpg");
|
|
21
|
+
var productImage = require("../../../../assets/g3-reader-pro.jpg");
|
|
22
22
|
function _interopDefault(e) {
|
|
23
23
|
return e && e.__esModule ? e : {
|
|
24
24
|
default: e
|
|
@@ -15,8 +15,8 @@ import { mobileAppAccess } from '../properties/mobileAppAccess.mjs';
|
|
|
15
15
|
import { hand } from '../properties/hand.mjs';
|
|
16
16
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
17
17
|
import { readerPowerMethod } from '../properties/readerPowerMethod.mjs';
|
|
18
|
-
import v3Image__default from "../../../../assets/g3-reader-
|
|
19
|
-
import productImage__default from "../../../../assets/g3-reader-
|
|
18
|
+
import v3Image__default from "../../../../assets/g3-reader-pro2.jpg";
|
|
19
|
+
import productImage__default from "../../../../assets/g3-reader-pro.jpg";
|
|
20
20
|
"use strict";
|
|
21
21
|
const g3ReaderPro = {
|
|
22
22
|
id: "g3ReaderPro",
|
|
@@ -11,8 +11,8 @@ var includedHub = require('../properties/includedHub.js');
|
|
|
11
11
|
var includedReaders = require('../properties/includedReaders.js');
|
|
12
12
|
var includedAccessories = require('../properties/includedAccessories.js');
|
|
13
13
|
var touchPassSupport = require('../properties/touchPassSupport.js');
|
|
14
|
-
var v3Image = require("../../../../assets/g3-starter-kit-
|
|
15
|
-
var image = require("../../../../assets/g3-starter-kit-
|
|
14
|
+
var v3Image = require("../../../../assets/g3-starter-kit-pro2.jpg");
|
|
15
|
+
var image = require("../../../../assets/g3-starter-kit-pro.jpg");
|
|
16
16
|
function _interopDefault(e) {
|
|
17
17
|
return e && e.__esModule ? e : {
|
|
18
18
|
default: e
|
|
@@ -9,8 +9,8 @@ import { includedHub } from '../properties/includedHub.mjs';
|
|
|
9
9
|
import { includedReaders } from '../properties/includedReaders.mjs';
|
|
10
10
|
import { includedAccessories } from '../properties/includedAccessories.mjs';
|
|
11
11
|
import { touchPassSupport } from '../properties/touchPassSupport.mjs';
|
|
12
|
-
import v3Image__default from "../../../../assets/g3-starter-kit-
|
|
13
|
-
import image__default from "../../../../assets/g3-starter-kit-
|
|
12
|
+
import v3Image__default from "../../../../assets/g3-starter-kit-pro2.jpg";
|
|
13
|
+
import image__default from "../../../../assets/g3-starter-kit-pro.jpg";
|
|
14
14
|
"use strict";
|
|
15
15
|
const g3StarterKitPro = {
|
|
16
16
|
id: "g3StarterKitPro",
|
|
@@ -8,8 +8,8 @@ var DomeTurret = require('../product-groups/cameraSecurity/DomeTurret.js');
|
|
|
8
8
|
var domeTurret = require('../product-list-groups/domeTurret.js');
|
|
9
9
|
var deployment = require('../properties/deployment.js');
|
|
10
10
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
11
|
-
var v3Image = require("../../../../assets/g5-
|
|
12
|
-
var image = require("../../../../assets/g5-
|
|
11
|
+
var v3Image = require("../../../../assets/g5-dome2.jpg");
|
|
12
|
+
var image = require("../../../../assets/g5-dome.jpg");
|
|
13
13
|
function _interopDefault(e) {
|
|
14
14
|
return e && e.__esModule ? e : {
|
|
15
15
|
default: e
|
|
@@ -6,8 +6,8 @@ import { domeTurret as domeTurret$1 } from '../product-groups/cameraSecurity/Dom
|
|
|
6
6
|
import { domeTurret } from '../product-list-groups/domeTurret.mjs';
|
|
7
7
|
import { deployment } from '../properties/deployment.mjs';
|
|
8
8
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
9
|
-
import v3Image__default from "../../../../assets/g5-
|
|
10
|
-
import image__default from "../../../../assets/g5-
|
|
9
|
+
import v3Image__default from "../../../../assets/g5-dome2.jpg";
|
|
10
|
+
import image__default from "../../../../assets/g5-dome.jpg";
|
|
11
11
|
"use strict";
|
|
12
12
|
const g5Dome = {
|
|
13
13
|
id: "g5Dome",
|
|
@@ -7,8 +7,8 @@ var Compact = require('../product-groups/cameraSecurity/Compact.js');
|
|
|
7
7
|
var compact = require('../product-list-groups/compact.js');
|
|
8
8
|
var deployment = require('../properties/deployment.js');
|
|
9
9
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
10
|
-
var v3Image = require("../../../../assets/g5-
|
|
11
|
-
var image = require("../../../../assets/g5-
|
|
10
|
+
var v3Image = require("../../../../assets/g5-flex.jpg");
|
|
11
|
+
var image = require("../../../../assets/g5-flex2.jpg");
|
|
12
12
|
function _interopDefault(e) {
|
|
13
13
|
return e && e.__esModule ? e : {
|
|
14
14
|
default: e
|
|
@@ -5,8 +5,8 @@ import { compact as compact$1 } from '../product-groups/cameraSecurity/Compact.m
|
|
|
5
5
|
import { compact } from '../product-list-groups/compact.mjs';
|
|
6
6
|
import { deployment } from '../properties/deployment.mjs';
|
|
7
7
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
8
|
-
import v3Image__default from "../../../../assets/g5-
|
|
9
|
-
import image__default from "../../../../assets/g5-
|
|
8
|
+
import v3Image__default from "../../../../assets/g5-flex.jpg";
|
|
9
|
+
import image__default from "../../../../assets/g5-flex2.jpg";
|
|
10
10
|
"use strict";
|
|
11
11
|
const g5Flex = {
|
|
12
12
|
id: "g5Flex",
|
|
@@ -8,8 +8,8 @@ var DomeTurret = require('../product-groups/cameraSecurity/DomeTurret.js');
|
|
|
8
8
|
var domeTurret = require('../product-list-groups/domeTurret.js');
|
|
9
9
|
var deployment = require('../properties/deployment.js');
|
|
10
10
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
11
|
-
var v3Image = require("../../../../assets/g5-turret-
|
|
12
|
-
var image = require("../../../../assets/g5-turret-
|
|
11
|
+
var v3Image = require("../../../../assets/g5-turret-ultra2.jpg");
|
|
12
|
+
var image = require("../../../../assets/g5-turret-ultra.jpg");
|
|
13
13
|
function _interopDefault(e) {
|
|
14
14
|
return e && e.__esModule ? e : {
|
|
15
15
|
default: e
|
|
@@ -6,8 +6,8 @@ import { domeTurret as domeTurret$1 } from '../product-groups/cameraSecurity/Dom
|
|
|
6
6
|
import { domeTurret } from '../product-list-groups/domeTurret.mjs';
|
|
7
7
|
import { deployment } from '../properties/deployment.mjs';
|
|
8
8
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
9
|
-
import v3Image__default from "../../../../assets/g5-turret-
|
|
10
|
-
import image__default from "../../../../assets/g5-turret-
|
|
9
|
+
import v3Image__default from "../../../../assets/g5-turret-ultra2.jpg";
|
|
10
|
+
import image__default from "../../../../assets/g5-turret-ultra.jpg";
|
|
11
11
|
"use strict";
|
|
12
12
|
const g5TurretUltra = {
|
|
13
13
|
id: "g5TurretUltra",
|
|
@@ -17,8 +17,8 @@ var mobileAppAccess = require('../properties/mobileAppAccess.js');
|
|
|
17
17
|
var hand = require('../properties/hand.js');
|
|
18
18
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
19
19
|
var readerPowerMethod = require('../properties/readerPowerMethod.js');
|
|
20
|
-
var v3Image = require("../../../../assets/
|
|
21
|
-
var image = require("../../../../assets/
|
|
20
|
+
var v3Image = require("../../../../assets/intercom2.jpg");
|
|
21
|
+
var image = require("../../../../assets/intercom.jpg");
|
|
22
22
|
function _interopDefault(e) {
|
|
23
23
|
return e && e.__esModule ? e : {
|
|
24
24
|
default: e
|
|
@@ -15,8 +15,8 @@ import { mobileAppAccess } from '../properties/mobileAppAccess.mjs';
|
|
|
15
15
|
import { hand } from '../properties/hand.mjs';
|
|
16
16
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
17
17
|
import { readerPowerMethod } from '../properties/readerPowerMethod.mjs';
|
|
18
|
-
import v3Image__default from "../../../../assets/
|
|
19
|
-
import image__default from "../../../../assets/
|
|
18
|
+
import v3Image__default from "../../../../assets/intercom2.jpg";
|
|
19
|
+
import image__default from "../../../../assets/intercom.jpg";
|
|
20
20
|
"use strict";
|
|
21
21
|
const intercom = {
|
|
22
22
|
id: "intercom",
|
|
@@ -7,8 +7,8 @@ var InteriorDesign = require('../product-groups/cameraSecurity/InteriorDesign.js
|
|
|
7
7
|
var interiorDesign = require('../product-list-groups/interiorDesign.js');
|
|
8
8
|
var deployment = require('../properties/deployment.js');
|
|
9
9
|
var outdoorReady = require('../properties/outdoorReady.js');
|
|
10
|
-
var v3Image = require("../../../../assets/ai-
|
|
11
|
-
var image = require("../../../../assets/ai-
|
|
10
|
+
var v3Image = require("../../../../assets/ai-theta.jpg");
|
|
11
|
+
var image = require("../../../../assets/ai-theta2.jpg");
|
|
12
12
|
function _interopDefault(e) {
|
|
13
13
|
return e && e.__esModule ? e : {
|
|
14
14
|
default: e
|
|
@@ -5,8 +5,8 @@ import { interiorDesign as interiorDesign$1 } from '../product-groups/cameraSecu
|
|
|
5
5
|
import { interiorDesign } from '../product-list-groups/interiorDesign.mjs';
|
|
6
6
|
import { deployment } from '../properties/deployment.mjs';
|
|
7
7
|
import { outdoorReady } from '../properties/outdoorReady.mjs';
|
|
8
|
-
import v3Image__default from "../../../../assets/ai-
|
|
9
|
-
import image__default from "../../../../assets/ai-
|
|
8
|
+
import v3Image__default from "../../../../assets/ai-theta.jpg";
|
|
9
|
+
import image__default from "../../../../assets/ai-theta2.jpg";
|
|
10
10
|
"use strict";
|
|
11
11
|
const aiTheta = {
|
|
12
12
|
id: "theta",
|
|
@@ -72,6 +72,11 @@ export declare const Round: {
|
|
|
72
72
|
* ! For correct rounding UI Care prices, used for auto managed UI Care products.
|
|
73
73
|
*/
|
|
74
74
|
ValidUiCarePrice: RoundingFn;
|
|
75
|
+
/**
|
|
76
|
+
* Used as an ASAP test for China store launch, need to rework!
|
|
77
|
+
* Search by NEP-4834
|
|
78
|
+
*/
|
|
79
|
+
ChinaRound: import("@dinero.js/core").RoundingMode;
|
|
75
80
|
};
|
|
76
81
|
/**
|
|
77
82
|
* Mapping of how prices should be rounded down to "whole numbers" after certain threshold
|
|
@@ -107,7 +107,12 @@ const Round = {
|
|
|
107
107
|
* ! Disclaimer may not work for "weird" currencies as expected
|
|
108
108
|
* ! For correct rounding UI Care prices, used for auto managed UI Care products.
|
|
109
109
|
*/
|
|
110
|
-
ValidUiCarePrice: roundToNearestValidUiCarePrice
|
|
110
|
+
ValidUiCarePrice: roundToNearestValidUiCarePrice,
|
|
111
|
+
/**
|
|
112
|
+
* Used as an ASAP test for China store launch, need to rework!
|
|
113
|
+
* Search by NEP-4834
|
|
114
|
+
*/
|
|
115
|
+
ChinaRound: dinero_js.up
|
|
111
116
|
};
|
|
112
117
|
const prettifyPriceLookup = /* @__PURE__ */new Map([[currencies.USD.code, 20], [currencies.AED.code, 50],
|
|
113
118
|
// Approximately every price above ~1.1 usd will be rounded in ZAR
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","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,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp, up } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n /**\n * Used as an ASAP test for China store launch, need to rework!\n * Search by NEP-4834\n */\n ChinaRound: up,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","ChinaRound","up","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TA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js/currencies';
|
|
2
|
-
import { halfUp, down, halfAwayFromZero } from 'dinero.js';
|
|
2
|
+
import { up, halfUp, down, halfAwayFromZero } from 'dinero.js';
|
|
3
3
|
import '../../types/index.mjs';
|
|
4
4
|
import { Currency } from '../../types/generated.mjs';
|
|
5
5
|
"use strict";
|
|
@@ -105,7 +105,12 @@ const Round = {
|
|
|
105
105
|
* ! Disclaimer may not work for "weird" currencies as expected
|
|
106
106
|
* ! For correct rounding UI Care prices, used for auto managed UI Care products.
|
|
107
107
|
*/
|
|
108
|
-
ValidUiCarePrice: roundToNearestValidUiCarePrice
|
|
108
|
+
ValidUiCarePrice: roundToNearestValidUiCarePrice,
|
|
109
|
+
/**
|
|
110
|
+
* Used as an ASAP test for China store launch, need to rework!
|
|
111
|
+
* Search by NEP-4834
|
|
112
|
+
*/
|
|
113
|
+
ChinaRound: up
|
|
109
114
|
};
|
|
110
115
|
const prettifyPriceLookup = /* @__PURE__ */new Map([[USD.code, 20], [AED.code, 50],
|
|
111
116
|
// Approximately every price above ~1.1 usd will be rounded in ZAR
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EAAA;EAOH,MAAAC,aAAA,GAAgBC,IAAK,CAAAC,KAAA,CAAMH,KAAK,CAAA;EAGtC,MAAMI,YAAYH,aAAgB,GAAA,EAAA;EAClC,IAAIG,aAAa,CAAG,EAAA;IAElB,OAAOH,aAAgB,GAAAG,SAAA;EAAA,CACzB,MAAA,IAAWA,aAAa,CAAG,EAAA;IAEzB,OAAOH,gBAAgBG,SAAY,GAAA,CAAA;EAAA,C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AAA,EAAQ;CAAS,CAAA;AAAA;AAEjD,CAACH,SAASsC,GAAK,EAAA;EAAEpC,UAAUqC,GAAK;EAAApC,MAAA,EAAQ;CAAS,CAAA;AAAA;AAEjD,CAACH,SAASwC,GAAK,EAAA;EAAEtC,UAAUJ,GAAK;EAAAK,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASyC,GAAK,EAAA;EAAEvC,UAAUN,GAAK;EAAAO,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAS0C,GAAK,EAAA;EAAExC,UAAUyC,GAAK;EAAAxC,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAS4C,GAAK,EAAA;EAAE1C,UAAU2C,GAAK;EAAA1C,MAAA,EAAQ;AAAS,CAAA,CAAA,CAClD,CAAA;AAeY,MAAA2C,wBAAA,GAAA,mBAA+BC,GAAI,CAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA,CAWlC,CAAA;AAKP,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAM0D,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp, up } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n /**\n * Used as an ASAP test for China store launch, need to rework!\n * Search by NEP-4834\n */\n ChinaRound: up,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","ChinaRound","up","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,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A;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;"}
|
package/lib/utils/money/tax.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StoreId } from "../../types";
|
|
2
2
|
import type { Dino, LineItemSummary, TaxRate } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Function to calculate the tax amount for a given line item depending on the store's tax rate calculation strategy
|
package/lib/utils/money/tax.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var dinero_js = require('dinero.js');
|
|
4
|
+
require('../../types/index.js');
|
|
4
5
|
var errors = require('../errors.js');
|
|
5
6
|
var number = require('../number.js');
|
|
6
7
|
var constants = require('./constants.js');
|
|
7
8
|
var tax_private = require('./tax.private.js');
|
|
9
|
+
var generated = require('../../types/generated.js');
|
|
8
10
|
"use strict";
|
|
9
11
|
const calculateLineItemTax = ({
|
|
10
12
|
itemSummary,
|
|
11
13
|
taxRate,
|
|
12
14
|
storeId
|
|
13
15
|
}) => {
|
|
14
|
-
|
|
16
|
+
if (storeId === generated.StoreId.Cn) {
|
|
17
|
+
return tax_private.calculateWholeQtyLineItemTax(itemSummary, taxRate, constants.Round.ChinaRound);
|
|
18
|
+
}
|
|
19
|
+
return constants.storesWithPerItemTaxRate.has(storeId) ? tax_private.calculatePerQtyLineItemTax(itemSummary, taxRate) : tax_private.calculateWholeQtyLineItemTax(itemSummary, taxRate, constants.Round.Financial);
|
|
15
20
|
};
|
|
16
21
|
const removeTaxAmount = (baseAmountWithTaxObj, taxRate) => {
|
|
17
22
|
const snapshot = dinero_js.toSnapshot(baseAmountWithTaxObj);
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 { 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 // TODO: NEP-4834 Talk with @renarsvilnis about this approach:\n // Search by `NEP-4834`\n if (storeId === StoreId.Cn) {\n return calculateWholeQtyLineItemTax(itemSummary, taxRate, Round.ChinaRound);\n }\n\n return storesWithPerItemTaxRate.has(storeId)\n ? calculatePerQtyLineItemTax(itemSummary, taxRate)\n : calculateWholeQtyLineItemTax(itemSummary, taxRate, Round.Financial);\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","StoreId","Cn","calculateWholeQtyLineItemTax","Round","ChinaRound","storesWithPerItemTaxRate","has","calculatePerQtyLineItemTax","Financial","removeTaxAmount","baseAmountWithTaxObj","snapshot","toSnapshot","taxAmount","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;EAGA,IAAAA,OAAA,KAAYC,kBAAQC,EAAI,EAAA;IAC1B,OAAOC,WAA6B,CAAAA,4BAAA,CAAAL,WAAA,EAAaC,OAAS,EAAAK,SAAAA,CAAAA,KAAA,CAAMC,UAAU,CAAA;EAAA;EAG5E,OAAOC,SAAyB,CAAAA,wBAAA,CAAAC,GAAA,CAAIP,OAAO,CAAA,GACvCQ,WAA2B,CAAAA,0BAAA,CAAAV,WAAA,EAAaC,OAAO,CAAA,GAC/CI,WAA6B,CAAAA,4BAAA,CAAAL,WAAA,EAAaC,OAAS,EAAAK,SAAAA,CAAAA,KAAA,CAAMK,SAAS,CAAA;AACxE,CAAA;AAEa,MAAAC,eAAA,GAAkBA,CAC7BC,oBAAA,EACAZ,OACG,KAAA;EACG,MAAAa,QAAA,GAAWC,qBAAWF,oBAAoB,CAAA;EAGhD,MAAMG,YAAYV,SAAAA,CAAAA,KAAM,CAAAK,SAAA,CACtBG,QAAS,CAAAG,MAAA,GAASH,QAAS,CAAAG,MAAA,IAAU,CAAI,GAAAhB,OAAA,CAC3C,CAAA;EAEA,OAAOiB,gBAAO,CAAA;IACZ,GA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AAA,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
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { toSnapshot, dinero, multiply, toUnit, halfEven } from 'dinero.js';
|
|
2
|
+
import '../../types/index.mjs';
|
|
2
3
|
import { assert } from '../errors.mjs';
|
|
3
4
|
import { isFloat, toFixedRate } from '../number.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { Round, storesWithPerItemTaxRate, TAX_RATE_DINERO_CURRENCY } from './constants.mjs';
|
|
6
|
+
import { calculateWholeQtyLineItemTax, calculatePerQtyLineItemTax } from './tax.private.mjs';
|
|
7
|
+
import { StoreId } from '../../types/generated.mjs';
|
|
6
8
|
"use strict";
|
|
7
9
|
const calculateLineItemTax = ({
|
|
8
10
|
itemSummary,
|
|
9
11
|
taxRate,
|
|
10
12
|
storeId
|
|
11
13
|
}) => {
|
|
12
|
-
|
|
14
|
+
if (storeId === StoreId.Cn) {
|
|
15
|
+
return calculateWholeQtyLineItemTax(itemSummary, taxRate, Round.ChinaRound);
|
|
16
|
+
}
|
|
17
|
+
return storesWithPerItemTaxRate.has(storeId) ? calculatePerQtyLineItemTax(itemSummary, taxRate) : calculateWholeQtyLineItemTax(itemSummary, taxRate, Round.Financial);
|
|
13
18
|
};
|
|
14
19
|
const removeTaxAmount = (baseAmountWithTaxObj, taxRate) => {
|
|
15
20
|
const snapshot = toSnapshot(baseAmountWithTaxObj);
|