@ubnt/store.core 9.34.0-beta.3 → 9.34.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/assets/attention.svg +5 -5
  3. package/lib/assets/attention2.svg +5 -5
  4. package/lib/assets/ucgMax.jpg +0 -0
  5. package/lib/assets/ucgMax2.jpg +0 -0
  6. package/lib/assets/ucgUltra.jpg +0 -0
  7. package/lib/assets/ucgUltra2.jpg +0 -0
  8. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.js +5 -5
  9. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.mjs +2 -2
  10. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.js +5 -5
  11. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.mjs +2 -2
  12. package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.js +1 -1
  13. package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.mjs +2 -2
  14. package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.js +1 -1
  15. package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.mjs +2 -2
  16. package/lib/components/ModelCompareV3/data/CloudGateways.js +6 -6
  17. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +4 -4
  18. package/lib/components/ModelCompareV3/data/products/ucgMax.js +1 -1
  19. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
  20. package/lib/components/ModelCompareV3/data/products/ucgUltra.js +1 -1
  21. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +1 -1
  22. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  23. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  24. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  25. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  26. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  27. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  28. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  29. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  30. package/lib/utils/money/constants.d.ts +26 -4
  31. package/lib/utils/money/constants.js +39 -6
  32. package/lib/utils/money/constants.js.map +1 -1
  33. package/lib/utils/money/constants.mjs +38 -7
  34. package/lib/utils/money/constants.mjs.map +1 -1
  35. package/lib/utils/money/format.js +14 -5
  36. package/lib/utils/money/format.js.map +1 -1
  37. package/lib/utils/money/format.mjs +15 -6
  38. package/lib/utils/money/format.mjs.map +1 -1
  39. package/lib/utils/money/index.js +3 -1
  40. package/lib/utils/money/index.js.map +1 -1
  41. package/lib/utils/money/index.mjs +1 -1
  42. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  ## Releases
8
8
 
9
+ ### 9.34.0-beta.4
10
+
11
+ - [Feat] [NEP-3846](https://ubiquiti.atlassian.net/browse/NEP-3846) Adjust prettify price logic
12
+
9
13
  ### 9.34.0-beta.3
10
14
 
11
15
  - [Fix] [MIC-456](https://ubiquiti.atlassian.net/browse/MIC-456) Fix aspect ratio precision for microsite hero
@@ -25,6 +29,12 @@
25
29
  - [Feat] [MIC-453](https://ubiquiti.atlassian.net/browse/MIC-453) Add new property for Switching compare tables
26
30
  - Upstream master branch
27
31
 
32
+ ### 9.33.1
33
+
34
+ - [Fix] [MIC-456](https://ubiquiti.atlassian.net/browse/MIC-456) Update UISP GPON and XGS-PON compare tables, fix menu sublabel placement, and aspect ratio precision for microsite hero
35
+ - [Fix] [MIC-455](https://ubiquiti.atlassian.net/browse/MIC-455) Remove Pro AV from ECS switches in compare table
36
+ - [Fix] [MIC-452](https://ubiquiti.atlassian.net/browse/MIC-452) Fix UISP Dish compare table data
37
+
28
38
  ### 9.33.0
29
39
 
30
40
  - [Feat] [NEP-3699](https://ubiquiti.atlassian.net/browse/NEP-3699) Clean up collections in pro store mapping
@@ -1,6 +1,6 @@
1
- <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <circle cx="9" cy="9" r="9" fill="#F7D55E"/>
3
- <path d="M9.73071 4.64062C9.40595 4.07813 8.59405 4.07812 8.26929 4.64062L4.37218 11.3906C4.04742 11.9531 4.45336 12.6562 5.10288 12.6562H12.8971C13.5466 12.6562 13.9526 11.9531 13.6278 11.3906L9.73071 4.64062Z" stroke="white" stroke-width="0.5625"/>
4
- <path d="M9.22274 9.12833L9.48295 7.30685C9.52494 7.01295 9.29688 6.75 9 6.75C8.70312 6.75 8.47506 7.01295 8.51705 7.30685L8.77726 9.12833C8.81406 9.3859 9.18594 9.3859 9.22274 9.12833Z" fill="white"/>
5
- <circle cx="9" cy="10.6875" r="0.5625" fill="#F7D55E"/>
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="8" cy="8" r="8" fill="#A4A7B5"/>
3
+ <path d="M12.1136 10.125L8.64952 4.125C8.36084 3.625 7.63916 3.625 7.35048 4.125L3.88638 10.125C3.5977 10.625 3.95855 11.25 4.5359 11.25H11.4641C12.0415 11.25 12.4023 10.625 12.1136 10.125Z" stroke="white" stroke-width="0.5"/>
4
+ <path d="M8.19799 8.11407L8.42929 6.49497C8.46661 6.23373 8.2639 6 8 6C7.7361 6 7.53339 6.23373 7.57071 6.49497L7.80201 8.11407C7.83472 8.34302 8.16528 8.34303 8.19799 8.11407Z" fill="white"/>
5
+ <circle cx="8" cy="9.5" r="0.5" fill="white"/>
6
6
  </svg>
@@ -1,6 +1,6 @@
1
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <circle cx="8" cy="8" r="8" fill="#A4A7B5"/>
3
- <path d="M12.1136 10.125L8.64952 4.125C8.36084 3.625 7.63916 3.625 7.35048 4.125L3.88638 10.125C3.5977 10.625 3.95855 11.25 4.5359 11.25H11.4641C12.0415 11.25 12.4023 10.625 12.1136 10.125Z" stroke="white" stroke-width="0.5"/>
4
- <path d="M8.19799 8.11407L8.42929 6.49497C8.46661 6.23373 8.2639 6 8 6C7.7361 6 7.53339 6.23373 7.57071 6.49497L7.80201 8.11407C7.83472 8.34302 8.16528 8.34303 8.19799 8.11407Z" fill="white"/>
5
- <circle cx="8" cy="9.5" r="0.5" fill="white"/>
1
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="9" cy="9" r="9" fill="#F7D55E"/>
3
+ <path d="M9.73071 4.64062C9.40595 4.07813 8.59405 4.07812 8.26929 4.64062L4.37218 11.3906C4.04742 11.9531 4.45336 12.6562 5.10288 12.6562H12.8971C13.5466 12.6562 13.9526 11.9531 13.6278 11.3906L9.73071 4.64062Z" stroke="white" stroke-width="0.5625"/>
4
+ <path d="M9.22274 9.12833L9.48295 7.30685C9.52494 7.01295 9.29688 6.75 9 6.75C8.70312 6.75 8.47506 7.01295 8.51705 7.30685L8.77726 9.12833C8.81406 9.3859 9.18594 9.3859 9.22274 9.12833Z" fill="white"/>
5
+ <circle cx="9" cy="10.6875" r="0.5625" fill="#F7D55E"/>
6
6
  </svg>
Binary file
Binary file
Binary file
Binary file
@@ -3,24 +3,24 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var _externalAssets_DfjB$I0W = require("../../../../../assets/ucgMax.jpg");
6
+ var _externalAssets_ReJhRoVe = require("../../../../../assets/ucgMax2.jpg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
10
10
  };
11
11
  }
12
- var _externalAssets_DfjB$I0W__default = /*#__PURE__*/_interopDefault(_externalAssets_DfjB$I0W);
12
+ var _externalAssets_ReJhRoVe__default = /*#__PURE__*/_interopDefault(_externalAssets_ReJhRoVe);
13
13
  Object.defineProperty(exports, "default", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _externalAssets_DfjB$I0W__default["default"];
16
+ return _externalAssets_ReJhRoVe__default["default"];
17
17
  }
18
18
  });
19
- Object.keys(_externalAssets_DfjB$I0W).forEach(function (k) {
19
+ Object.keys(_externalAssets_ReJhRoVe).forEach(function (k) {
20
20
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
21
21
  enumerable: true,
22
22
  get: function () {
23
- return _externalAssets_DfjB$I0W[k];
23
+ return _externalAssets_ReJhRoVe[k];
24
24
  }
25
25
  });
26
26
  });
@@ -1,3 +1,3 @@
1
- export * from "../../../../../assets/ucgMax.jpg";
2
- export { default } from "../../../../../assets/ucgMax.jpg";
1
+ export * from "../../../../../assets/ucgMax2.jpg";
2
+ export { default } from "../../../../../assets/ucgMax2.jpg";
3
3
  //# sourceMappingURL=ucgMax.jpg.mjs.map
@@ -3,24 +3,24 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var _externalAssets_BGAVPUHK = require("../../../../../assets/ucgUltra.jpg");
6
+ var _externalAssets_sWF40Ihh = require("../../../../../assets/ucgUltra2.jpg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
10
10
  };
11
11
  }
12
- var _externalAssets_BGAVPUHK__default = /*#__PURE__*/_interopDefault(_externalAssets_BGAVPUHK);
12
+ var _externalAssets_sWF40Ihh__default = /*#__PURE__*/_interopDefault(_externalAssets_sWF40Ihh);
13
13
  Object.defineProperty(exports, "default", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _externalAssets_BGAVPUHK__default["default"];
16
+ return _externalAssets_sWF40Ihh__default["default"];
17
17
  }
18
18
  });
19
- Object.keys(_externalAssets_BGAVPUHK).forEach(function (k) {
19
+ Object.keys(_externalAssets_sWF40Ihh).forEach(function (k) {
20
20
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
21
21
  enumerable: true,
22
22
  get: function () {
23
- return _externalAssets_BGAVPUHK[k];
23
+ return _externalAssets_sWF40Ihh[k];
24
24
  }
25
25
  });
26
26
  });
@@ -1,3 +1,3 @@
1
- export * from "../../../../../assets/ucgUltra.jpg";
2
- export { default } from "../../../../../assets/ucgUltra.jpg";
1
+ export * from "../../../../../assets/ucgUltra2.jpg";
2
+ export { default } from "../../../../../assets/ucgUltra2.jpg";
3
3
  //# sourceMappingURL=ucgUltra.jpg.mjs.map
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var image = require("../../../../assets/ucgMax2.jpg");
6
+ var image = require("../../../../assets/ucgMax.jpg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
@@ -1,3 +1,3 @@
1
- export * from "../../../../assets/ucgMax2.jpg";
2
- export { default } from "../../../../assets/ucgMax2.jpg";
1
+ export * from "../../../../assets/ucgMax.jpg";
2
+ export { default } from "../../../../assets/ucgMax.jpg";
3
3
  //# sourceMappingURL=ucgMax.jpg.mjs.map
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var image = require("../../../../assets/ucgUltra2.jpg");
6
+ var image = require("../../../../assets/ucgUltra.jpg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
@@ -1,3 +1,3 @@
1
- export * from "../../../../assets/ucgUltra2.jpg";
2
- export { default } from "../../../../assets/ucgUltra2.jpg";
1
+ export * from "../../../../assets/ucgUltra.jpg";
2
+ export { default } from "../../../../assets/ucgUltra.jpg";
3
3
  //# sourceMappingURL=ucgUltra.jpg.mjs.map
@@ -26,8 +26,8 @@ var _externalAssets_CMbJW0VT = require("../../../assets/udmProMax2.jpg");
26
26
  var _externalAssets_CCo8CEpV = require("../../../assets/udmPro2.jpg");
27
27
  var _externalAssets_CBGnWxM$ = require("../../../assets/udmProSpecial2.jpg");
28
28
  var image = require("../../../assets/udw2.jpg");
29
- var _externalAssets_DfjB$I0W = require("../../../assets/ucgMax.jpg");
30
- var _externalAssets_BGAVPUHK = require("../../../assets/ucgUltra.jpg");
29
+ var _externalAssets_ReJhRoVe = require("../../../assets/ucgMax2.jpg");
30
+ var _externalAssets_sWF40Ihh = require("../../../assets/ucgUltra2.jpg");
31
31
  var image$1 = require("../../../assets/udr2.jpg");
32
32
  var image$2 = require("../../../assets/express.jpg");
33
33
  var nextAiInspection = require('./properties/nextAiInspection.js');
@@ -40,8 +40,8 @@ var _externalAssets_CMbJW0VT__default = /*#__PURE__*/_interopDefault(_externalAs
40
40
  var _externalAssets_CCo8CEpV__default = /*#__PURE__*/_interopDefault(_externalAssets_CCo8CEpV);
41
41
  var _externalAssets_CBGnWxM$__default = /*#__PURE__*/_interopDefault(_externalAssets_CBGnWxM$);
42
42
  var image__default = /*#__PURE__*/_interopDefault(image);
43
- var _externalAssets_DfjB$I0W__default = /*#__PURE__*/_interopDefault(_externalAssets_DfjB$I0W);
44
- var _externalAssets_BGAVPUHK__default = /*#__PURE__*/_interopDefault(_externalAssets_BGAVPUHK);
43
+ var _externalAssets_ReJhRoVe__default = /*#__PURE__*/_interopDefault(_externalAssets_ReJhRoVe);
44
+ var _externalAssets_sWF40Ihh__default = /*#__PURE__*/_interopDefault(_externalAssets_sWF40Ihh);
45
45
  var image__default$1 = /*#__PURE__*/_interopDefault(image$1);
46
46
  var image__default$2 = /*#__PURE__*/_interopDefault(image$2);
47
47
  "use strict";
@@ -75,12 +75,12 @@ const udw = {
75
75
  };
76
76
  const ucgMax = {
77
77
  ...ucgMax$1.ucgMax,
78
- image: getImage(_externalAssets_DfjB$I0W__default["default"]),
78
+ image: getImage(_externalAssets_ReJhRoVe__default["default"]),
79
79
  notes: ["ucgMax.note.accessory"]
80
80
  };
81
81
  const ucgUltra = {
82
82
  ...ucgUltra$1.ucgUltra,
83
- image: getImage(_externalAssets_BGAVPUHK__default["default"])
83
+ image: getImage(_externalAssets_sWF40Ihh__default["default"])
84
84
  };
85
85
  const udr = {
86
86
  ...udr$1.udr,
@@ -24,8 +24,8 @@ import _externalAssets_CMbJW0VT__default from "../../../assets/udmProMax2.jpg";
24
24
  import _externalAssets_CCo8CEpV__default from "../../../assets/udmPro2.jpg";
25
25
  import _externalAssets_CBGnWxM$__default from "../../../assets/udmProSpecial2.jpg";
26
26
  import image__default from "../../../assets/udw2.jpg";
27
- import _externalAssets_DfjB$I0W__default from "../../../assets/ucgMax.jpg";
28
- import _externalAssets_BGAVPUHK__default from "../../../assets/ucgUltra.jpg";
27
+ import _externalAssets_ReJhRoVe__default from "../../../assets/ucgMax2.jpg";
28
+ import _externalAssets_sWF40Ihh__default from "../../../assets/ucgUltra2.jpg";
29
29
  import image__default$1 from "../../../assets/udr2.jpg";
30
30
  import image__default$2 from "../../../assets/express.jpg";
31
31
  import { nextAiInspection } from './properties/nextAiInspection.mjs';
@@ -60,12 +60,12 @@ const udw = {
60
60
  };
61
61
  const ucgMax = {
62
62
  ...ucgMax$1,
63
- image: getImage(_externalAssets_DfjB$I0W__default),
63
+ image: getImage(_externalAssets_ReJhRoVe__default),
64
64
  notes: ["ucgMax.note.accessory"]
65
65
  };
66
66
  const ucgUltra = {
67
67
  ...ucgUltra$1,
68
- image: getImage(_externalAssets_BGAVPUHK__default)
68
+ image: getImage(_externalAssets_sWF40Ihh__default)
69
69
  };
70
70
  const udr = {
71
71
  ...udr$1,
@@ -9,7 +9,7 @@ require('../../assets/applications.svg.js');
9
9
  require('../../assets/Consoles/ucgMax.jpg.js');
10
10
  require('../properties/index.js');
11
11
  var integratedWiFi6 = require('../properties/integratedWiFi6.js');
12
- var image = require("../../../../assets/ucgMax2.jpg");
12
+ var image = require("../../../../assets/ucgMax.jpg");
13
13
  var unifiAppSuite = require('../properties/unifiAppSuite.js');
14
14
  var StyleableSvgImage = require('../../../StyleableSvgImage/StyleableSvgImage.js');
15
15
  var applications = require("../../../../assets/applications.svg");
@@ -7,7 +7,7 @@ import '../../assets/applications.svg.mjs';
7
7
  import '../../assets/Consoles/ucgMax.jpg.mjs';
8
8
  import '../properties/index.mjs';
9
9
  import { integratedWiFi6 } from '../properties/integratedWiFi6.mjs';
10
- import image__default from "../../../../assets/ucgMax2.jpg";
10
+ import image__default from "../../../../assets/ucgMax.jpg";
11
11
  import { unifiAppSuite } from '../properties/unifiAppSuite.mjs';
12
12
  import { StyleableSvgImage } from '../../../StyleableSvgImage/StyleableSvgImage.mjs';
13
13
  import applications__default from "../../../../assets/applications.svg";
@@ -21,7 +21,7 @@ var unifiDevices = require('../properties/unifiDevices.js');
21
21
  var wanPorts = require('../properties/wanPorts.js');
22
22
  var StyleableSvgImage$1 = require('../../../StyleableSvgImage/StyleableSvgImage.js');
23
23
  var unifi = require('../../../../constants/proStoreCategories/mapping/unifi.js');
24
- var image = require("../../../../assets/ucgUltra2.jpg");
24
+ var image = require("../../../../assets/ucgUltra.jpg");
25
25
  var applications = require("../../../../assets/wifi-device.svg");
26
26
  var nextAiInspection = require('../properties/nextAiInspection.js');
27
27
  function _interopDefault(e) {
@@ -19,7 +19,7 @@ import { unifiDevices } from '../properties/unifiDevices.mjs';
19
19
  import { wanPorts } from '../properties/wanPorts.mjs';
20
20
  import { StyleableSvgImage as StyleableSvgImage$1 } from '../../../StyleableSvgImage/StyleableSvgImage.mjs';
21
21
  import { UniFiCategoryId } from '../../../../constants/proStoreCategories/mapping/unifi.mjs';
22
- import image__default from "../../../../assets/ucgUltra2.jpg";
22
+ import image__default from "../../../../assets/ucgUltra.jpg";
23
23
  import applications__default from "../../../../assets/wifi-device.svg";
24
24
  import { nextAiInspection } from '../properties/nextAiInspection.mjs';
25
25
  "use strict";
@@ -12,7 +12,7 @@ require('./assets/attention.svg.js');
12
12
  var InputCard_styles = require('./InputCard.styles.js');
13
13
  require('./InputSections/index.js');
14
14
  var CustomImage = require('../../../../CustomImage/CustomImage.js');
15
- var attentionIcon = require("../../../../../assets/attention2.svg");
15
+ var attentionIcon = require("../../../../../assets/attention.svg");
16
16
  var OptionSelectSection = require('./InputSections/OptionSelectSection.js');
17
17
  var SliderSection = require('./InputSections/SliderSection.js');
18
18
  var CounterSection = require('./InputSections/CounterSection.js');
@@ -10,7 +10,7 @@ import './assets/attention.svg.mjs';
10
10
  import { Card, Header, HeaderHeadingSection, HeadingIcon, HeadingTitle, HeaderActionSection, SubduedInfo, OverlayFilter, NotAvailableNoteWrap, NotAvailableNoteIcon, InputBody, InputSectionSpacing, Footer, FooterContent, FooterNote } from './InputCard.styles.mjs';
11
11
  import './InputSections/index.mjs';
12
12
  import { CustomImage } from '../../../../CustomImage/CustomImage.mjs';
13
- import attentionIcon__default from "../../../../../assets/attention2.svg";
13
+ import attentionIcon__default from "../../../../../assets/attention.svg";
14
14
  import { OptionSelectSection } from './InputSections/OptionSelectSection.mjs';
15
15
  import { SliderSection } from './InputSections/SliderSection.mjs';
16
16
  import { CounterSection } from './InputSections/CounterSection.mjs';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var attentionIcon = require("../../../../../../assets/attention2.svg");
6
+ var attentionIcon = require("../../../../../../assets/attention.svg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
@@ -1,3 +1,3 @@
1
- export * from "../../../../../../assets/attention2.svg";
2
- export { default } from "../../../../../../assets/attention2.svg";
1
+ export * from "../../../../../../assets/attention.svg";
2
+ export { default } from "../../../../../../assets/attention.svg";
3
3
  //# sourceMappingURL=attention.svg.mjs.map
@@ -6,7 +6,7 @@ var asset = require('../../../../../utils/asset.js');
6
6
  require('./assets/attention.svg.js');
7
7
  var Part = require('./Part.js');
8
8
  var ProgressBarChart_styles = require('./ProgressBarChart.styles.js');
9
- var attentionIcon = require("../../../../../assets/attention.svg");
9
+ var attentionIcon = require("../../../../../assets/attention2.svg");
10
10
  function _interopDefault(e) {
11
11
  return e && e.__esModule ? e : {
12
12
  default: e
@@ -4,7 +4,7 @@ import { imageSrc } from '../../../../../utils/asset.mjs';
4
4
  import './assets/attention.svg.mjs';
5
5
  import { PART_GAP_PX, PART_WIDTH_PX, Part } from './Part.mjs';
6
6
  import { ProgressBarChartContainer, ProgressBarChartHeader, ProgressBarChartTitle, ProgressBarWrapper, ProgressBarPartsContainer, ProgressBarAttentionLabel, ProgressBarAttentionLabelIcon } from './ProgressBarChart.styles.mjs';
7
- import attentionIcon__default from "../../../../../assets/attention.svg";
7
+ import attentionIcon__default from "../../../../../assets/attention2.svg";
8
8
  "use strict";
9
9
  const ProgressBarChart = ({
10
10
  title,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
- var attentionIcon = require("../../../../../../assets/attention.svg");
6
+ var attentionIcon = require("../../../../../../assets/attention2.svg");
7
7
  function _interopDefault(e) {
8
8
  return e && e.__esModule ? e : {
9
9
  default: e
@@ -1,3 +1,3 @@
1
- export * from "../../../../../../assets/attention.svg";
2
- export { default } from "../../../../../../assets/attention.svg";
1
+ export * from "../../../../../../assets/attention2.svg";
2
+ export { default } from "../../../../../../assets/attention2.svg";
3
3
  //# sourceMappingURL=attention.svg.mjs.map
@@ -4,11 +4,26 @@ import type { LocalizedCurrency, RoundingFn } from "./types";
4
4
  /**
5
5
  * Custom rounding method to be used with dinero.js
6
6
  * This rounding method will round to nearest FULL 0/5/9 (and strip cents)
7
- * (moved here to mitigate ReferenceError: Cannot access 'roundToNearestFull059Fn' before initialization)
8
7
  *
9
8
  * @see: https://ubiquiti.atlassian.net/browse/NEP-3846
10
9
  */
11
- export declare const roundToNearestFull059Fn: RoundingFn;
10
+ export declare const roundToNearestFull059: RoundingFn;
11
+ /**
12
+ * Custom rounding method to be used with dinero.js
13
+ * This rounding method will round to
14
+ * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60
15
+ *
16
+ * @see: https://ubiquiti.atlassian.net/browse/NEP-3846
17
+ */
18
+ export declare const roundToNearestDecimalCent: RoundingFn;
19
+ /**
20
+ * Custom rounding method to be used with dinero.js
21
+ * This rounding method will round to
22
+ * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12
23
+ *
24
+ * @see: https://ubiquiti.atlassian.net/browse/NEP-3846
25
+ */
26
+ export declare const roundToNearestHalfUnitCent: RoundingFn;
12
27
  export declare const Round: {
13
28
  /**
14
29
  * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
@@ -16,8 +31,7 @@ export declare const Round: {
16
31
  * normalise the values so we use this method.
17
32
  *
18
33
  * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
19
- * @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
20
- * @see
34
+ * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts
21
35
  *
22
36
  * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
23
37
  * number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
@@ -41,6 +55,14 @@ export declare const Round: {
41
55
  * ! Disclaimer may not work for "weird" currencies as expected
42
56
  */
43
57
  PrettifyFull059: RoundingFn;
58
+ /**
59
+ * ! Disclaimer may not work for "weird" currencies as expected
60
+ */
61
+ PrettifyDecimalCents: RoundingFn;
62
+ /**
63
+ * ! Disclaimer may not work for "weird" currencies as expected
64
+ */
65
+ PrettifyHalfUnitCents: RoundingFn;
44
66
  Subunit: import("@dinero.js/core").RoundingMode;
45
67
  };
46
68
  /**
@@ -5,7 +5,13 @@ var dinero_js = require('dinero.js');
5
5
  require('../../types/index.js');
6
6
  var generated = require('../../types/generated.js');
7
7
  "use strict";
8
- const roundToNearestFull059Fn = input => {
8
+ const roundToNearestFull059 = input => {
9
+ if (input === 0) {
10
+ return 0;
11
+ }
12
+ if (input <= 3) {
13
+ return 5;
14
+ }
9
15
  const roundedNumber = Math.round(input);
10
16
  const remainder = roundedNumber % 10;
11
17
  if (remainder <= 2) {
@@ -16,6 +22,24 @@ const roundToNearestFull059Fn = input => {
16
22
  return roundedNumber - remainder + 9;
17
23
  }
18
24
  };
25
+ const roundToNearestDecimalCent = input => {
26
+ if (input === 0) {
27
+ return 0;
28
+ }
29
+ if (input < 0.1) {
30
+ return 0.1;
31
+ }
32
+ return parseFloat((Math.round(input * 10) / 10).toFixed(1));
33
+ };
34
+ const roundToNearestHalfUnitCent = input => {
35
+ if (input === 0) {
36
+ return 0;
37
+ }
38
+ if (input < 0.5) {
39
+ return 0.5;
40
+ }
41
+ return parseFloat((Math.round(input * 2) / 2).toFixed(2));
42
+ };
19
43
  const Round = {
20
44
  /**
21
45
  * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
@@ -23,8 +47,7 @@ const Round = {
23
47
  * normalise the values so we use this method.
24
48
  *
25
49
  * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
26
- * @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
27
- * @see
50
+ * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts
28
51
  *
29
52
  * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
30
53
  * number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
@@ -52,10 +75,18 @@ const Round = {
52
75
  /**
53
76
  * ! Disclaimer may not work for "weird" currencies as expected
54
77
  */
55
- PrettifyFull059: roundToNearestFull059Fn,
78
+ PrettifyFull059: roundToNearestFull059,
79
+ /**
80
+ * ! Disclaimer may not work for "weird" currencies as expected
81
+ */
82
+ PrettifyDecimalCents: roundToNearestDecimalCent,
83
+ /**
84
+ * ! Disclaimer may not work for "weird" currencies as expected
85
+ */
86
+ PrettifyHalfUnitCents: roundToNearestHalfUnitCent,
56
87
  Subunit: dinero_js.halfUp
57
88
  };
58
- const prettifyPriceLookup = /* @__PURE__ */new Map([[currencies.USD.code, 20], [currencies.CAD.code, 50], [currencies.EUR.code, 50], [currencies.GBP.code, 50], [currencies.AED.code, 50],
89
+ const prettifyPriceLookup = /* @__PURE__ */new Map([[currencies.USD.code, 20], [currencies.AED.code, 50],
59
90
  // Approximately every price above ~1.1 usd will be rounded in ZAR
60
91
  [currencies.ZAR.code, 20]]);
61
92
  const smallestSubunitLookup = /* @__PURE__ */new Map([
@@ -176,7 +207,9 @@ exports.Round = Round;
176
207
  exports.TAX_RATE_DINERO_CURRENCY = TAX_RATE_DINERO_CURRENCY;
177
208
  exports.localizedCurrencyLookup = localizedCurrencyLookup;
178
209
  exports.prettifyPriceLookup = prettifyPriceLookup;
179
- exports.roundToNearestFull059Fn = roundToNearestFull059Fn;
210
+ exports.roundToNearestDecimalCent = roundToNearestDecimalCent;
211
+ exports.roundToNearestFull059 = roundToNearestFull059;
212
+ exports.roundToNearestHalfUnitCent = roundToNearestHalfUnitCent;
180
213
  exports.smallestSubunitLookup = smallestSubunitLookup;
181
214
  exports.storesWithPerItemTaxRate = storesWithPerItemTaxRate;
182
215
  //# sourceMappingURL=constants.js.map
@@ -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 CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\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 * (moved here to mitigate ReferenceError: Cannot access 'roundToNearestFull059Fn' before initialization)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059Fn: RoundingFn = (input: number) => {\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 Round = {\n /**\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 * normalise 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/main/packages/core/src/round/halfEven.ts\n * @see\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded\n * 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 (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 * !!!!!!!!!!!!!!\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 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: down,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059Fn,\n Subunit: halfUp,\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 [CAD.code, 50],\n [EUR.code, 50],\n [GBP.code, 50],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.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]);\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":["roundToNearestFull059Fn","input","roundedNumber","Math","round","remainder","Round","Financial","halfAwayFromZero","Shipping","down","Prettify","PrettifyFull059","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","CAD","EUR","GBP","AED","ZAR","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","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","MXN","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;;;AA8Ca,MAAAA,uBAAA,GAAuCC,KAAkB,IAAA;EAK9D,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,CAC9B,MAAA;IAEL,OAAOH,gBAAgBG,SAAY,GAAA,CAAA;EACrC;AACF,CAAA;AAEO,MAAMC,KAAQ,GAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AKP,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVrD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAMsD,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVrD,IAAM,EAAA;EAAA;AACR,CAAA;;;;;;;;"}
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 CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\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-3.00\n if (input <= 3) {\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\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 * ⚠️ 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 * normalise 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 behaviour based on if the rounded\n * 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 (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 * !!!!!!!!!!!!!!\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 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: down,\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} 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]);\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]);\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","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","down","Prettify","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","AED","ZAR","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","MXN","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;;;AA6Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EACT;EAGA,IAAIA,SAAS,CAAG,EAAA;IACP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;;;;"}
@@ -1,9 +1,15 @@
1
- import { USD, CAD, EUR, GBP, AED, ZAR, TWD, BGN, CHF, CZK, DKK, HRK, HUF, NOK, PLN, RON, SEK, INR, SGD, BRL, JPY, MXN } from '@dinero.js/currencies';
1
+ import { USD, AED, ZAR, TWD, BGN, CAD, CHF, CZK, DKK, EUR, GBP, HRK, HUF, NOK, PLN, RON, SEK, INR, SGD, BRL, JPY, MXN } from '@dinero.js/currencies';
2
2
  import { halfAwayFromZero, down, halfUp } from 'dinero.js';
3
3
  import '../../types/index.mjs';
4
4
  import { Currency } from '../../types/generated.mjs';
5
5
  "use strict";
6
- const roundToNearestFull059Fn = input => {
6
+ const roundToNearestFull059 = input => {
7
+ if (input === 0) {
8
+ return 0;
9
+ }
10
+ if (input <= 3) {
11
+ return 5;
12
+ }
7
13
  const roundedNumber = Math.round(input);
8
14
  const remainder = roundedNumber % 10;
9
15
  if (remainder <= 2) {
@@ -14,6 +20,24 @@ const roundToNearestFull059Fn = input => {
14
20
  return roundedNumber - remainder + 9;
15
21
  }
16
22
  };
23
+ const roundToNearestDecimalCent = input => {
24
+ if (input === 0) {
25
+ return 0;
26
+ }
27
+ if (input < 0.1) {
28
+ return 0.1;
29
+ }
30
+ return parseFloat((Math.round(input * 10) / 10).toFixed(1));
31
+ };
32
+ const roundToNearestHalfUnitCent = input => {
33
+ if (input === 0) {
34
+ return 0;
35
+ }
36
+ if (input < 0.5) {
37
+ return 0.5;
38
+ }
39
+ return parseFloat((Math.round(input * 2) / 2).toFixed(2));
40
+ };
17
41
  const Round = {
18
42
  /**
19
43
  * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
@@ -21,8 +45,7 @@ const Round = {
21
45
  * normalise the values so we use this method.
22
46
  *
23
47
  * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
24
- * @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
25
- * @see
48
+ * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts
26
49
  *
27
50
  * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
28
51
  * number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
@@ -50,10 +73,18 @@ const Round = {
50
73
  /**
51
74
  * ! Disclaimer may not work for "weird" currencies as expected
52
75
  */
53
- PrettifyFull059: roundToNearestFull059Fn,
76
+ PrettifyFull059: roundToNearestFull059,
77
+ /**
78
+ * ! Disclaimer may not work for "weird" currencies as expected
79
+ */
80
+ PrettifyDecimalCents: roundToNearestDecimalCent,
81
+ /**
82
+ * ! Disclaimer may not work for "weird" currencies as expected
83
+ */
84
+ PrettifyHalfUnitCents: roundToNearestHalfUnitCent,
54
85
  Subunit: halfUp
55
86
  };
56
- const prettifyPriceLookup = /* @__PURE__ */new Map([[USD.code, 20], [CAD.code, 50], [EUR.code, 50], [GBP.code, 50], [AED.code, 50],
87
+ const prettifyPriceLookup = /* @__PURE__ */new Map([[USD.code, 20], [AED.code, 50],
57
88
  // Approximately every price above ~1.1 usd will be rounded in ZAR
58
89
  [ZAR.code, 20]]);
59
90
  const smallestSubunitLookup = /* @__PURE__ */new Map([
@@ -169,5 +200,5 @@ const EXCHANGE_RATE_DINERO_CURRENCY = {
169
200
  code: ""
170
201
  // Not important
171
202
  };
172
- export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestFull059Fn, smallestSubunitLookup, storesWithPerItemTaxRate };
203
+ export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, smallestSubunitLookup, storesWithPerItemTaxRate };
173
204
  //# sourceMappingURL=constants.mjs.map
@@ -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 CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\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 * (moved here to mitigate ReferenceError: Cannot access 'roundToNearestFull059Fn' before initialization)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059Fn: RoundingFn = (input: number) => {\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 Round = {\n /**\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 * normalise 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/main/packages/core/src/round/halfEven.ts\n * @see\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded\n * 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 (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 * !!!!!!!!!!!!!!\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 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: down,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059Fn,\n Subunit: halfUp,\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 [CAD.code, 50],\n [EUR.code, 50],\n [GBP.code, 50],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.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]);\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":["roundToNearestFull059Fn","input","roundedNumber","Math","round","remainder","Round","Financial","halfAwayFromZero","Shipping","down","Prettify","PrettifyFull059","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","CAD","EUR","GBP","AED","ZAR","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","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","MXN","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA8Ca,MAAAA,uBAAA,GAAuCC,KAAkB,IAAA;EAK9D,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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,EAAA;EAAE3B,UAAU4B,GAAK;EAAA3B,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAS+B,GAAK,EAAA;EAAE7B,UAAU8B,GAAK;EAAA7B,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASiC,GAAK,EAAA;EAAE/B,UAAUgC,GAAK;EAAA/B,MAAA,EAAQ;CAAS,CAAA;AAAA;AAEjD,CAACH,SAASmC,GAAK,EAAA;EAAEjC,UAAUkC,GAAK;EAAAjC,MAAA,EAAQ;CAAS,CAAA;AAAA;AAEjD,CAACH,SAASqC,GAAK,EAAA;EAAEnC,UAAUJ,GAAK;EAAAK,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASsC,GAAK,EAAA;EAAEpC,UAAUqC,GAAK;EAAApC,MAAA,EAAQ;CAAS,CAAA,CAClD,CAAA;AAeY,MAAAqC,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;EACVrD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAMsD,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVrD,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 CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\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-3.00\n if (input <= 3) {\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\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 * ⚠️ 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 * normalise 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 behaviour based on if the rounded\n * 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 (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 * !!!!!!!!!!!!!!\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 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: down,\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} 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]);\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]);\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","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","down","Prettify","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","AED","ZAR","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","MXN","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA6Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EACT;EAGA,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EACT;EAMM,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,CAC9B,MAAA;IAEL,OAAOH,gBAAgBG,SAAY,GAAA,CAAA;EACrC;AACF,CAAA;AASa,MAAAC,yBAAA,GAAyCL,KAAkB,IAAA;EACtE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EACT;EAGA,IAAIA,QAAQ,GAAK,EAAA;IACR,OAAA,GAAA;EACT;EAMO,OAAAM,UAAA,CAAA,CAAYJ,KAAKC,KAAM,CAAAH,KAAA,GAAQ,EAAE,CAAI,GA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AAA;EAAE5B,UAAUT,GAAK;EAAAU,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAS+B,GAAK,EAAA;EAAE7B,UAAUN,GAAK;EAAAO,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASgC,GAAK,EAAA;EAAE9B,UAAU+B,GAAK;EAAA9B,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASkC,GAAK,EAAA;EAAEhC,UAAUiC,GAAK;EAAAhC,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAASoC,GAAK,EAAA;EAAElC,UAAUmC,GAAK;EAAAlC,MAAA,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,UAAUwC,GAAK;EAAAvC,MAAA,EAAQ;CAAS,CAAA,CAClD,CAAA;AAeY,MAAAwC,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;EACVrD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAMsD,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVrD,IAAM,EAAA;EAAA;AACR,CAAA;"}
@@ -60,23 +60,32 @@ const formatPrice = (money, options) => {
60
60
  };
61
61
  const prettifyTotal = total => {
62
62
  const totalJson = total.toJSON();
63
- const minValueInclusiveToRoundDownFrom = constants.prettifyPriceLookup.get(totalJson.currency.code);
64
- if (minValueInclusiveToRoundDownFrom == null || dinero_js.toUnit(total) < minValueInclusiveToRoundDownFrom) {
65
- return total;
66
- }
67
63
  switch (totalJson.currency.code) {
68
64
  // @see: https://ubiquiti.atlassian.net/browse/NEP-3846
69
65
  case currencies.EUR.code:
70
66
  case currencies.GBP.code:
71
67
  case currencies.CAD.code:
72
68
  {
73
- return misc.roundDinero(total, constants.Round.PrettifyFull059);
69
+ const totalAsFloat = dinero_js.toUnit(total);
70
+ if (totalAsFloat < 10) {
71
+ return misc.roundDinero(total, constants.Round.PrettifyDecimalCents);
72
+ } else if (totalAsFloat < 20) {
73
+ return misc.roundDinero(total, constants.Round.PrettifyHalfUnitCents);
74
+ } else if (totalAsFloat < 50) {
75
+ return misc.roundDinero(total, constants.Round.Prettify);
76
+ } else {
77
+ return misc.roundDinero(total, constants.Round.PrettifyFull059);
78
+ }
74
79
  }
75
80
  default:
76
81
  {
77
82
  if (!dinero_js.hasSubUnits(total)) {
78
83
  return total;
79
84
  }
85
+ const minValueInclusiveToRoundDownFrom = constants.prettifyPriceLookup.get(totalJson.currency.code);
86
+ if (minValueInclusiveToRoundDownFrom == null || dinero_js.toUnit(total) < minValueInclusiveToRoundDownFrom) {
87
+ return total;
88
+ }
80
89
  return misc.roundDinero(total, constants.Round.Prettify);
81
90
  }
82
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","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\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 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 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 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 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 return roundDinero(total, Round.PrettifyFull059);\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\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","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","minValueInclusiveToRoundDownFrom","prettifyPriceLookup","toUnit","EUR","GBP","CAD","roundDinero","Round","PrettifyFull059","hasSubUnits","Prettify"],"mappings":";;;;;;;;AAaa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,SAAAA,CAAAA,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;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EAC/B,MAAMC,mCAAmCC,SAAAA,CAAAA,mBAAoB,CAAArC,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;EAGA,IACEiB,gCAAoC,IAAA,IAAA,IACpCE,SAAO,CAAAA,MAAA,CAAAL,KAAK,IAAIG,gCAChB,EAAA;IACO,OAAAH,KAAA;EACT;EAEQ,QAAAC,SAAA,CAAUxB,SAASS,IAAM;IAAA;IAE/B,KAAKoB,UAAAA,CAAAA,GAAI,CAAApB,IAAA;IACT,KAAKqB,UAAAA,CAAAA,GAAI,CAAArB,IAAA;IACT,KAAKsB,UAAAA,CAAAA,IAAItB,IAAM;MAAA;QACN,OAAAuB,gBAAA,CAAYT,KAAO,EAAAU,SAAA,CAAAA,KAAA,CAAMC,eAAe,CAAA;MACjD;IACA;MAAS;QAEH,IAAA,CAACC,SAAAA,CAAAA,WAAY,CAAAZ,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEO,OAAAS,gBAAA,CAAYT,KAAO,EAAAU,SAAA,CAAAA,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"format.js","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\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 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 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","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,SAAAA,CAAAA,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAA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@dinero.js/currencies';
2
- import { toFormat, toUnit, hasSubUnits } from 'dinero.js';
2
+ import { toFormat, hasSubUnits, toUnit } from 'dinero.js';
3
3
  import { assert } from '../errors.mjs';
4
4
  import { localizedCurrencyLookup, prettifyPriceLookup, Round } from './constants.mjs';
5
5
  import { getDinero, roundDinero } from './misc.mjs';
@@ -58,23 +58,32 @@ const formatPrice = (money, options) => {
58
58
  };
59
59
  const prettifyTotal = total => {
60
60
  const totalJson = total.toJSON();
61
- const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(totalJson.currency.code);
62
- if (minValueInclusiveToRoundDownFrom == null || toUnit(total) < minValueInclusiveToRoundDownFrom) {
63
- return total;
64
- }
65
61
  switch (totalJson.currency.code) {
66
62
  // @see: https://ubiquiti.atlassian.net/browse/NEP-3846
67
63
  case EUR.code:
68
64
  case GBP.code:
69
65
  case CAD.code:
70
66
  {
71
- return roundDinero(total, Round.PrettifyFull059);
67
+ const totalAsFloat = toUnit(total);
68
+ if (totalAsFloat < 10) {
69
+ return roundDinero(total, Round.PrettifyDecimalCents);
70
+ } else if (totalAsFloat < 20) {
71
+ return roundDinero(total, Round.PrettifyHalfUnitCents);
72
+ } else if (totalAsFloat < 50) {
73
+ return roundDinero(total, Round.Prettify);
74
+ } else {
75
+ return roundDinero(total, Round.PrettifyFull059);
76
+ }
72
77
  }
73
78
  default:
74
79
  {
75
80
  if (!hasSubUnits(total)) {
76
81
  return total;
77
82
  }
83
+ const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(totalJson.currency.code);
84
+ if (minValueInclusiveToRoundDownFrom == null || toUnit(total) < minValueInclusiveToRoundDownFrom) {
85
+ return total;
86
+ }
78
87
  return roundDinero(total, Round.Prettify);
79
88
  }
80
89
  }
@@ -1 +1 @@
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\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 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 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 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 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 return roundDinero(total, Round.PrettifyFull059);\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\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","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","minValueInclusiveToRoundDownFrom","prettifyPriceLookup","toUnit","EUR","GBP","CAD","roundDinero","Round","PrettifyFull059","hasSubUnits","Prettify"],"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,EAAA;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,C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,KAAA,CAAMlB,QAAQ,CAAA,EACtCmB,iBAAkB,CAAAzB,MAAA,EAClBY,OAAA,CACF;AACF,CAAA;AAMa,MAAAgB,aAAA,GAAiBC,KAAsB,IAAA;EAC5C,MAAAC,SAAA,GAAYD,MAAME,MAAO,EAAA;EAC/B,MAAMC,mCAAmCC,mBAAoB,CAAArC,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;EAGA,IACEiB,gCAAoC,IAAA,IAAA,IACpCE,MAAO,CAAAL,KAAK,IAAIG,gCAChB,EAAA;IACO,OAAAH,KAAA;EACT;EAEQ,QAAAC,SAAA,CAAUxB,SAASS,IAAM;IAAA;IAE/B,KAAKoB,GAAI,CAAApB,IAAA;IACT,KAAKqB,GAAI,CAAArB,IAAA;IACT,KAAKsB,IAAItB,IAAM;MAAA;QACN,OAAAuB,WAAA,CAAYT,KAAO,EAAAU,KAAA,CAAMC,eAAe,CAAA;MACjD;IACA;MAAS;QAEH,IAAA,CAACC,WAAY,CAAAZ,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEO,OAAAS,WAAA,CAAYT,KAAO,EAAAU,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;"}
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\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 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 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","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,EAAA;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;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,C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B,aAAA,GAAiBC,KAAsB,IAAA;EAC5C,MAAAC,SAAA,GAAYD,MAAME,MAAO,EAAA;EAEvB,QAAAD,SAAA,CAAUxB,SAASS,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;QACjD;MACF;IACA;MAAS;QAEH,IAAA,CAACC,WAAY,CAAAd,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEA,MAAMe,mCAAmCC,mBAAoB,CAAAjD,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;QAGA,IACE6B,gCAAoC,IAAA,IAAA,IACpCR,MAAO,CAAAP,KAAK,IAAIe,gCAChB,EAAA;UACO,OAAAf,KAAA;QACT;QAEO,OAAAQ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;"}
@@ -17,7 +17,9 @@ exports.Round = constants.Round;
17
17
  exports.TAX_RATE_DINERO_CURRENCY = constants.TAX_RATE_DINERO_CURRENCY;
18
18
  exports.localizedCurrencyLookup = constants.localizedCurrencyLookup;
19
19
  exports.prettifyPriceLookup = constants.prettifyPriceLookup;
20
- exports.roundToNearestFull059Fn = constants.roundToNearestFull059Fn;
20
+ exports.roundToNearestDecimalCent = constants.roundToNearestDecimalCent;
21
+ exports.roundToNearestFull059 = constants.roundToNearestFull059;
22
+ exports.roundToNearestHalfUnitCent = constants.roundToNearestHalfUnitCent;
21
23
  exports.smallestSubunitLookup = constants.smallestSubunitLookup;
22
24
  exports.storesWithPerItemTaxRate = constants.storesWithPerItemTaxRate;
23
25
  exports.invertExchangeRate = exchangeRate.invertExchangeRate;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  export { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
2
2
  export { ProductAmountAllocator } from './allocators/productAmount.mjs';
3
- export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestFull059Fn, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
3
+ export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
4
4
  export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate } from './exchangeRate.mjs';
5
5
  export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal } from './format.mjs';
6
6
  export { addMany, amount, centsToCurrencyUnit, currency, dineroToCurrencyUnit, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, parseFloatToDineroRaw, roundDinero, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.34.0-beta.3",
3
+ "version": "9.34.0-beta.4",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {