@ubnt/store.core 9.36.0-beta.2 → 9.36.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 (57) 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/icons/wizard/plus.svg.js +1 -1
  5. package/lib/assets/icons/wizard/plus.svg.mjs +2 -2
  6. package/lib/assets/plus.svg +22 -4
  7. package/lib/assets/plus2.svg +4 -22
  8. package/lib/assets/udmPro.jpg +0 -0
  9. package/lib/assets/udmPro2.jpg +0 -0
  10. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
  11. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
  12. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
  13. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
  14. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  15. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  16. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
  17. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
  18. package/lib/components/ModelCompareV3/data/CloudGateways.js +3 -3
  19. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +2 -2
  20. package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
  21. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
  22. package/lib/components/ProductWizard/ProductWizard.js +1 -1
  23. package/lib/components/ProductWizard/ProductWizard.mjs +1 -1
  24. package/lib/components/QuantityInput/QuantityInput.js +1 -1
  25. package/lib/components/QuantityInput/QuantityInput.mjs +1 -1
  26. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  27. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  28. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  29. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  30. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  31. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  32. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  33. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  34. package/lib/constants/proStoreCategories/mapping/index.js +4 -0
  35. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  36. package/lib/constants/proStoreCategories/mapping/index.mjs +4 -0
  37. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  38. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -0
  39. package/lib/constants/proStoreCategories/mapping/unifi.js +1 -0
  40. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  41. package/lib/constants/proStoreCategories/mapping/unifi.mjs +1 -0
  42. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  43. package/lib/utils/money/constants.d.ts +13 -11
  44. package/lib/utils/money/constants.js +16 -11
  45. package/lib/utils/money/constants.js.map +1 -1
  46. package/lib/utils/money/constants.mjs +17 -12
  47. package/lib/utils/money/constants.mjs.map +1 -1
  48. package/lib/utils/money/tax.d.ts +3 -4
  49. package/lib/utils/money/tax.js +2 -1
  50. package/lib/utils/money/tax.js.map +1 -1
  51. package/lib/utils/money/tax.mjs +4 -3
  52. package/lib/utils/money/tax.mjs.map +1 -1
  53. package/lib/utils/money/tax.private.d.ts +3 -4
  54. package/lib/utils/money/tax.private.js.map +1 -1
  55. package/lib/utils/money/tax.private.mjs.map +1 -1
  56. package/lib/utils/money/types.d.ts +8 -8
  57. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tax.private.mjs","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport type { Dinero } from \"dinero.js\";\nimport { add, dinero, subtract } from \"dinero.js\";\n\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { Round } from \"./constants\";\nimport { amount, getDinero, getDineroCurrency } from \"./misc\";\nimport type {\n Cents,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\n\n/**\n * Reverse engineer the taxable amount from \"whole item\" taxable amount into \"per item\" taxable amount for custom tax\n * rate calculations\n */\nexport const allocatePerItemTaxableAmount = (\n itemSummary: LineItemSummary,\n): SingleLineItemSummary[] => {\n /**\n * If the item quantity is 1, we can just return the item summary as is\n */\n if (itemSummary.quantity === 1) {\n return [itemSummary as SingleLineItemSummary];\n }\n\n // Reverse engineer price before discount\n const preDiscountAmount = add(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n getDinero(itemSummary.discountAmount, itemSummary.currency),\n );\n\n const allocator = new FixedAmountAllocator({\n initialAllocateAmount: itemSummary.discountAmount,\n initialTotalAmount: amount(preDiscountAmount),\n currency: itemSummary.currency,\n });\n\n // Iterate over the amount of qty to reverse engineer the discount price\n return Array.from({ length: itemSummary.quantity }, () => {\n const discountAllocatedAmount = allocator.allocate(\n itemSummary.itemPrice,\n itemSummary.currency,\n );\n\n const taxableAmount = subtract(\n getDinero(itemSummary.itemPrice, itemSummary.currency),\n discountAllocatedAmount,\n );\n\n return {\n itemPrice: itemSummary.itemPrice,\n taxableAmount: amount(taxableAmount),\n discountAmount: amount(discountAllocatedAmount),\n currency: itemSummary.currency,\n quantity: 1,\n } as SingleLineItemSummary;\n });\n};\n\nexport const calculateWholeQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * Historically we calculate the tax by using dinero allocation, but we did not have control over how we round things.\n * So instead as we are already working with currency in cents we can multiply and round it ourselves.\n */\n return dinero({\n amount: Round.Financial(itemSummary.taxableAmount * taxRate),\n currency: getDineroCurrency(itemSummary.currency),\n });\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n // Split the item summary into per individual item qty summaries\n const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);\n\n // Calculate individual item qty tax and sum them up\n let totalTaxAmount = getDinero(0, itemSummary.currency);\n\n singleItemSummaries.forEach((itemSummary) => {\n // Probably a bit confusing at first, but calling the whole qty tax calculation function here as we can safely use\n // it as item summary is always a single item summary here\n const taxAmount = calculateWholeQtyLineItemTax(itemSummary, taxRate);\n totalTaxAmount = add(totalTaxAmount, taxAmount);\n });\n\n return totalTaxAmount;\n};\n"],"names":["allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","length","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxRate","dinero","Round","Financial","getDineroCurrency","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach","taxAmount"],"mappings":";;;;;AAqBa,MAAAA,4BAAA,GACXC,WAC4B,IAAA;EAIxB,IAAAA,WAAA,CAAYC,aAAa,CAAG,EAAA;IAC9B,OAAO,CAACD,WAAoC,CAAA;EAC9C;EAGA,MAAME,iBAAoB,GAAAC,GAAA,CACxBC,SAAU,CAA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,0BAAA,GAA6BA,CACxC1B,WAAA,EACAqB,OACkB,KAAA;EAElB,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAGM,MAAAqB,mBAAA,GAAsB5B,6BAA6BC,WAAW,CAAA;EAGpE,IAAI4B,cAAiB,GAAAxB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCqB,mBAAA,CAAAE,OAAA,CAAS7B,YAAgB,IAAA;IAGrC,MAAA8B,SAAA,GAAYV,4BAA6BpB,CAAAA,YAAAA,EAAaqB,OAAO,CAAA;IAClDO,cAAA,GAAAzB,GAAA,CAAIyB,gBAAgBE,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAF,cAAA;AACT,CAAA;"}
1
+ {"version":3,"file":"tax.private.mjs","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport { add, dinero, subtract } from \"dinero.js\";\n\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { Round } from \"./constants\";\nimport { amount, getDinero, getDineroCurrency } from \"./misc\";\nimport type {\n Dino,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\n\n/**\n * Reverse engineer the taxable amount from \"whole item\" taxable amount into \"per item\" taxable amount for custom tax\n * rate calculations\n */\nexport const allocatePerItemTaxableAmount = (\n itemSummary: LineItemSummary,\n): SingleLineItemSummary[] => {\n /**\n * If the item quantity is 1, we can just return the item summary as is\n */\n if (itemSummary.quantity === 1) {\n return [itemSummary as SingleLineItemSummary];\n }\n\n // Reverse engineer price before discount\n const preDiscountAmount = add(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n getDinero(itemSummary.discountAmount, itemSummary.currency),\n );\n\n const allocator = new FixedAmountAllocator({\n initialAllocateAmount: itemSummary.discountAmount,\n initialTotalAmount: amount(preDiscountAmount),\n currency: itemSummary.currency,\n });\n\n // Iterate over the amount of qty to reverse engineer the discount price\n return Array.from({ length: itemSummary.quantity }, () => {\n const discountAllocatedAmount = allocator.allocate(\n itemSummary.itemPrice,\n itemSummary.currency,\n );\n\n const taxableAmount = subtract(\n getDinero(itemSummary.itemPrice, itemSummary.currency),\n discountAllocatedAmount,\n );\n\n return {\n itemPrice: itemSummary.itemPrice,\n taxableAmount: amount(taxableAmount),\n discountAmount: amount(discountAllocatedAmount),\n currency: itemSummary.currency,\n quantity: 1,\n } as SingleLineItemSummary;\n });\n};\n\nexport const calculateWholeQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dino => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * Historically we calculate the tax by using dinero allocation, but we did not have control over how we round things.\n * So instead as we are already working with currency in cents we can multiply and round it ourselves.\n */\n return dinero({\n amount: Round.Financial(itemSummary.taxableAmount * taxRate),\n currency: getDineroCurrency(itemSummary.currency),\n });\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dino => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n // Split the item summary into per individual item qty summaries\n const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);\n\n // Calculate individual item qty tax and sum them up\n let totalTaxAmount = getDinero(0, itemSummary.currency);\n\n singleItemSummaries.forEach((itemSummary) => {\n // Probably a bit confusing at first, but calling the whole qty tax calculation function here as we can safely use\n // it as item summary is always a single item summary here\n const taxAmount = calculateWholeQtyLineItemTax(itemSummary, taxRate);\n totalTaxAmount = add(totalTaxAmount, taxAmount);\n });\n\n return totalTaxAmount;\n};\n"],"names":["allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","length","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxRate","dinero","Round","Financial","getDineroCurrency","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach","taxAmount"],"mappings":";;;;;AAoBa,MAAAA,4BAAA,GACXC,WAC4B,IAAA;EAIxB,IAAAA,WAAA,CAAYC,aAAa,CAAG,EAAA;IAC9B,OAAO,CAACD,WAAoC,CAAA;EAC9C;EAGA,MAAME,iBAAoB,GAAAC,GAAA,CACxBC,SAAU,CAAAJ,WAAA,CAAYK,aAAe,EAAAL,WAAA,CAAYM,QAAQ,CAAA,EACzDF,SAAU,CAAAJ,WAAA,CAAYO,cAAgB,EAAAP,WAAA,CAAYM,QAAQ,CAAA,CAC5D;EAEM,MAAAE,SAAA,GAAY,IAAIC,oBAAqB,CAAA;IACzCC,uBAAuBV,WAAY,CAAAO,cAAA;IACnCI,kBAAA,EAAoBC,OAAOV,iBAAiB,CAAA;IAC5CI,UAAUN,WAAY,CAAAM;EAAA,CACvB,CAAA;EAGD,OAAOO,MAAMC,IAAK,CAAA;IAAEC,QAAQf,WAAY,CAAAC;EAAA,GAAY,MAAM;IACxD,MAAMe,0BAA0BR,SAAU,CAAAS,QAAA,CACxCjB,WAAY,CAAAkB,SAAA,EACZlB,WAAY,CAAAM,QAAA,CACd;IAEA,MAAMD,aAAgB,GAAAc,QAAA,CACpBf,SAAU,CAAAJ,WAAA,CAAYkB,SAAW,EAAAlB,WAAA,CAAYM,QAAQ,CAAA,EACrDU,uBAAA,CACF;IAEO,OAAA;MACLE,WAAWlB,WAAY,CAAAkB,SAAA;MACvBb,aAAA,EAAeO,OAAOP,aAAa,CAAA;MACnCE,cAAA,EAAgBK,OAAOI,uBAAuB,CAAA;MAC9CV,UAAUN,WAAY,CAAAM,QAAA;MACtBL,QAAU,EAAA;IAAA,CACZ;EAAA,CACD,CAAA;AACH,CAAA;AAEa,MAAAmB,4BAAA,GAA+BA,CAC1CpB,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAMA,OAAOgB,MAAO,CAAA;IACZV,MAAQ,EAAAW,KAAA,CAAMC,SAAU,CAAAxB,WAAA,CAAYK,gBAAgBgB,OAAO,CAAA;IAC3Df,QAAA,EAAUmB,iBAAkB,CAAAzB,WAAA,CAAYM,QAAQ;EAAA,CACjD,CAAA;AACH,CAAA;AAEa,MAAAoB,0BAAA,GAA6BA,CACxC1B,WAAA,EACAqB,OACS,KAAA;EAET,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAjB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAGM,MAAAqB,mBAAA,GAAsB5B,6BAA6BC,WAAW,CAAA;EAGpE,IAAI4B,cAAiB,GAAAxB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCqB,mBAAA,CAAAE,OAAA,CAAS7B,YAAgB,IAAA;IAGrC,MAAA8B,SAAA,GAAYV,4BAA6BpB,CAAAA,YAAAA,EAAaqB,OAAO,CAAA;IAClDO,cAAA,GAAAzB,GAAA,CAAIyB,gBAAgBE,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAF,cAAA;AACT,CAAA;"}
@@ -7,14 +7,6 @@ import type { Currency } from "../../types";
7
7
  * 0.09 // 9%
8
8
  */
9
9
  export type TaxRate = number;
10
- /**
11
- * Shorthand for Dinero.js instance with number as the amount
12
- */
13
- export type Dino = Dinero<number>;
14
- /**
15
- * Shorthand for Dinero.js currency instance representing either a currency or custom currency such as tax-rate or shipping
16
- */
17
- export type DinoCurrency = DineroCurrency<number>;
18
10
  /**
19
11
  * Cents representation of specific currency
20
12
  * As a helper to easily understand the code, we use `Cents` as a type alias for `number` as historically we have had
@@ -24,6 +16,14 @@ export type DinoCurrency = DineroCurrency<number>;
24
16
  * 100 // in YEN this is ¥100
25
17
  */
26
18
  export type Cents = number;
19
+ /**
20
+ * Shorthand for Dinero.js instance with number as the amount
21
+ */
22
+ export type Dino = Dinero<Cents>;
23
+ /**
24
+ * Shorthand for Dinero.js currency instance representing either a currency or custom currency such as tax-rate or shipping
25
+ */
26
+ export type DinoCurrency = DineroCurrency<number>;
27
27
  /**
28
28
  * Type definition for a rounding function that can be used to round fractions
29
29
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.36.0-beta.2",
3
+ "version": "9.36.0-beta.4",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {