@acmekit/utils 2.13.2 → 2.13.3

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 (192) hide show
  1. package/dist/bundles.d.ts +0 -7
  2. package/dist/bundles.d.ts.map +1 -1
  3. package/dist/bundles.js +1 -8
  4. package/dist/bundles.js.map +1 -1
  5. package/dist/common/define-config.d.ts.map +1 -1
  6. package/dist/common/define-config.js +2 -49
  7. package/dist/common/define-config.js.map +1 -1
  8. package/dist/index.d.ts +0 -9
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +0 -9
  11. package/dist/index.js.map +1 -1
  12. package/dist/link/links.d.ts +0 -21
  13. package/dist/link/links.d.ts.map +1 -1
  14. package/dist/link/links.js +0 -21
  15. package/dist/link/links.js.map +1 -1
  16. package/dist/modules-sdk/definition.d.ts +0 -39
  17. package/dist/modules-sdk/definition.d.ts.map +1 -1
  18. package/dist/modules-sdk/definition.js +0 -26
  19. package/dist/modules-sdk/definition.js.map +1 -1
  20. package/dist/modules-sdk/modules-to-container-types.d.ts.map +1 -1
  21. package/dist/modules-sdk/modules-to-container-types.js +0 -13
  22. package/dist/modules-sdk/modules-to-container-types.js.map +1 -1
  23. package/dist/translations/index.d.ts +0 -1
  24. package/dist/translations/index.d.ts.map +1 -1
  25. package/dist/translations/index.js +0 -1
  26. package/dist/translations/index.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +3 -3
  29. package/dist/fulfillment/events.d.ts +0 -77
  30. package/dist/fulfillment/events.d.ts.map +0 -1
  31. package/dist/fulfillment/events.js +0 -117
  32. package/dist/fulfillment/events.js.map +0 -1
  33. package/dist/fulfillment/geo-zone.d.ts +0 -7
  34. package/dist/fulfillment/geo-zone.d.ts.map +0 -1
  35. package/dist/fulfillment/geo-zone.js +0 -11
  36. package/dist/fulfillment/geo-zone.js.map +0 -1
  37. package/dist/fulfillment/index.d.ts +0 -5
  38. package/dist/fulfillment/index.d.ts.map +0 -1
  39. package/dist/fulfillment/index.js +0 -21
  40. package/dist/fulfillment/index.js.map +0 -1
  41. package/dist/fulfillment/provider.d.ts +0 -394
  42. package/dist/fulfillment/provider.d.ts.map +0 -1
  43. package/dist/fulfillment/provider.js +0 -412
  44. package/dist/fulfillment/provider.js.map +0 -1
  45. package/dist/fulfillment/shipping-options.d.ts +0 -5
  46. package/dist/fulfillment/shipping-options.d.ts.map +0 -1
  47. package/dist/fulfillment/shipping-options.js +0 -9
  48. package/dist/fulfillment/shipping-options.js.map +0 -1
  49. package/dist/inventory/events.d.ts +0 -26
  50. package/dist/inventory/events.d.ts.map +0 -1
  51. package/dist/inventory/events.js +0 -40
  52. package/dist/inventory/events.js.map +0 -1
  53. package/dist/inventory/index.d.ts +0 -2
  54. package/dist/inventory/index.d.ts.map +0 -1
  55. package/dist/inventory/index.js +0 -18
  56. package/dist/inventory/index.js.map +0 -1
  57. package/dist/order/index.d.ts +0 -4
  58. package/dist/order/index.d.ts.map +0 -1
  59. package/dist/order/index.js +0 -20
  60. package/dist/order/index.js.map +0 -1
  61. package/dist/order/order-change-action.d.ts +0 -25
  62. package/dist/order/order-change-action.d.ts.map +0 -1
  63. package/dist/order/order-change-action.js +0 -29
  64. package/dist/order/order-change-action.js.map +0 -1
  65. package/dist/order/order-change.d.ts +0 -31
  66. package/dist/order/order-change.d.ts.map +0 -1
  67. package/dist/order/order-change.js +0 -36
  68. package/dist/order/order-change.js.map +0 -1
  69. package/dist/order/status.d.ts +0 -85
  70. package/dist/order/status.d.ts.map +0 -1
  71. package/dist/order/status.js +0 -92
  72. package/dist/order/status.js.map +0 -1
  73. package/dist/payment/abstract-payment-provider.d.ts +0 -632
  74. package/dist/payment/abstract-payment-provider.d.ts.map +0 -1
  75. package/dist/payment/abstract-payment-provider.js +0 -110
  76. package/dist/payment/abstract-payment-provider.js.map +0 -1
  77. package/dist/payment/index.d.ts +0 -5
  78. package/dist/payment/index.d.ts.map +0 -1
  79. package/dist/payment/index.js +0 -21
  80. package/dist/payment/index.js.map +0 -1
  81. package/dist/payment/payment-collection.d.ts +0 -40
  82. package/dist/payment/payment-collection.d.ts.map +0 -1
  83. package/dist/payment/payment-collection.js +0 -44
  84. package/dist/payment/payment-collection.js.map +0 -1
  85. package/dist/payment/payment-session.d.ts +0 -32
  86. package/dist/payment/payment-session.d.ts.map +0 -1
  87. package/dist/payment/payment-session.js +0 -36
  88. package/dist/payment/payment-session.js.map +0 -1
  89. package/dist/payment/webhook.d.ts +0 -37
  90. package/dist/payment/webhook.d.ts.map +0 -1
  91. package/dist/payment/webhook.js +0 -42
  92. package/dist/payment/webhook.js.map +0 -1
  93. package/dist/pricing/builders.d.ts +0 -10
  94. package/dist/pricing/builders.d.ts.map +0 -1
  95. package/dist/pricing/builders.js +0 -53
  96. package/dist/pricing/builders.js.map +0 -1
  97. package/dist/pricing/enums.d.ts +0 -8
  98. package/dist/pricing/enums.d.ts.map +0 -1
  99. package/dist/pricing/enums.js +0 -12
  100. package/dist/pricing/enums.js.map +0 -1
  101. package/dist/pricing/events.d.ts +0 -38
  102. package/dist/pricing/events.d.ts.map +0 -1
  103. package/dist/pricing/events.js +0 -50
  104. package/dist/pricing/events.js.map +0 -1
  105. package/dist/pricing/index.d.ts +0 -5
  106. package/dist/pricing/index.d.ts.map +0 -1
  107. package/dist/pricing/index.js +0 -21
  108. package/dist/pricing/index.js.map +0 -1
  109. package/dist/pricing/price-list.d.ts +0 -9
  110. package/dist/pricing/price-list.d.ts.map +0 -1
  111. package/dist/pricing/price-list.js +0 -14
  112. package/dist/pricing/price-list.js.map +0 -1
  113. package/dist/product/csv-normalizer.d.ts +0 -43
  114. package/dist/product/csv-normalizer.d.ts.map +0 -1
  115. package/dist/product/csv-normalizer.js +0 -382
  116. package/dist/product/csv-normalizer.js.map +0 -1
  117. package/dist/product/enums.d.ts +0 -7
  118. package/dist/product/enums.d.ts.map +0 -1
  119. package/dist/product/enums.js +0 -11
  120. package/dist/product/enums.js.map +0 -1
  121. package/dist/product/events.d.ts +0 -62
  122. package/dist/product/events.d.ts.map +0 -1
  123. package/dist/product/events.js +0 -88
  124. package/dist/product/events.js.map +0 -1
  125. package/dist/product/get-variant-availability.d.ts +0 -59
  126. package/dist/product/get-variant-availability.d.ts.map +0 -1
  127. package/dist/product/get-variant-availability.js +0 -111
  128. package/dist/product/get-variant-availability.js.map +0 -1
  129. package/dist/product/index.d.ts +0 -6
  130. package/dist/product/index.d.ts.map +0 -1
  131. package/dist/product/index.js +0 -45
  132. package/dist/product/index.js.map +0 -1
  133. package/dist/product/validators.d.ts +0 -894
  134. package/dist/product/validators.d.ts.map +0 -1
  135. package/dist/product/validators.js +0 -163
  136. package/dist/product/validators.js.map +0 -1
  137. package/dist/promotion/index.d.ts +0 -57
  138. package/dist/promotion/index.d.ts.map +0 -1
  139. package/dist/promotion/index.js +0 -70
  140. package/dist/promotion/index.js.map +0 -1
  141. package/dist/shipping/index.d.ts +0 -6
  142. package/dist/shipping/index.d.ts.map +0 -1
  143. package/dist/shipping/index.js +0 -10
  144. package/dist/shipping/index.js.map +0 -1
  145. package/dist/totals/adjustment/index.d.ts +0 -16
  146. package/dist/totals/adjustment/index.d.ts.map +0 -1
  147. package/dist/totals/adjustment/index.js +0 -49
  148. package/dist/totals/adjustment/index.js.map +0 -1
  149. package/dist/totals/cart/index.d.ts +0 -40
  150. package/dist/totals/cart/index.d.ts.map +0 -1
  151. package/dist/totals/cart/index.js +0 -165
  152. package/dist/totals/cart/index.js.map +0 -1
  153. package/dist/totals/create-raw-properties-from-bignumber.d.ts +0 -5
  154. package/dist/totals/create-raw-properties-from-bignumber.d.ts.map +0 -1
  155. package/dist/totals/create-raw-properties-from-bignumber.js +0 -52
  156. package/dist/totals/create-raw-properties-from-bignumber.js.map +0 -1
  157. package/dist/totals/credit-lines/index.d.ts +0 -14
  158. package/dist/totals/credit-lines/index.d.ts.map +0 -1
  159. package/dist/totals/credit-lines/index.js +0 -46
  160. package/dist/totals/credit-lines/index.js.map +0 -1
  161. package/dist/totals/index.d.ts +0 -9
  162. package/dist/totals/index.d.ts.map +0 -1
  163. package/dist/totals/index.js +0 -25
  164. package/dist/totals/index.js.map +0 -1
  165. package/dist/totals/line-item/index.d.ts +0 -48
  166. package/dist/totals/line-item/index.d.ts.map +0 -1
  167. package/dist/totals/line-item/index.js +0 -123
  168. package/dist/totals/line-item/index.js.map +0 -1
  169. package/dist/totals/math.d.ts +0 -26
  170. package/dist/totals/math.d.ts.map +0 -1
  171. package/dist/totals/math.js +0 -107
  172. package/dist/totals/math.js.map +0 -1
  173. package/dist/totals/promotion/index.d.ts +0 -5
  174. package/dist/totals/promotion/index.d.ts.map +0 -1
  175. package/dist/totals/promotion/index.js +0 -124
  176. package/dist/totals/promotion/index.js.map +0 -1
  177. package/dist/totals/shipping-method/index.d.ts +0 -28
  178. package/dist/totals/shipping-method/index.d.ts.map +0 -1
  179. package/dist/totals/shipping-method/index.js +0 -59
  180. package/dist/totals/shipping-method/index.js.map +0 -1
  181. package/dist/totals/tax/index.d.ts +0 -16
  182. package/dist/totals/tax/index.d.ts.map +0 -1
  183. package/dist/totals/tax/index.js +0 -37
  184. package/dist/totals/tax/index.js.map +0 -1
  185. package/dist/totals/transform-properties-to-bignumber.d.ts +0 -6
  186. package/dist/totals/transform-properties-to-bignumber.d.ts.map +0 -1
  187. package/dist/totals/transform-properties-to-bignumber.js +0 -40
  188. package/dist/totals/transform-properties-to-bignumber.js.map +0 -1
  189. package/dist/translations/apply-translations-to-tax-lines.d.ts +0 -12
  190. package/dist/translations/apply-translations-to-tax-lines.d.ts.map +0 -1
  191. package/dist/translations/apply-translations-to-tax-lines.js +0 -38
  192. package/dist/translations/apply-translations-to-tax-lines.js.map +0 -1
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPromotionValue = getPromotionValue;
4
- exports.getApplicableQuantity = getApplicableQuantity;
5
- exports.calculateAdjustmentAmountFromPromotion = calculateAdjustmentAmountFromPromotion;
6
- const promotion_1 = require("../../promotion");
7
- const math_1 = require("../math");
8
- const big_number_1 = require("../big-number");
9
- function getPromotionValueForPercentage(promotion, lineItemAmount) {
10
- return math_1.MathBN.mult(math_1.MathBN.div(promotion.value, 100), lineItemAmount);
11
- }
12
- function getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount, lineItem) {
13
- if (promotion.allocation === promotion_1.ApplicationMethodAllocation.ACROSS) {
14
- const promotionValueForItem = math_1.MathBN.mult(math_1.MathBN.div(lineItemAmount, lineItemsAmount), promotion.value);
15
- if (math_1.MathBN.lte(promotionValueForItem, lineItemAmount)) {
16
- return promotionValueForItem;
17
- }
18
- const percentage = math_1.MathBN.div(math_1.MathBN.mult(lineItemAmount, 100), promotionValueForItem);
19
- return math_1.MathBN.mult(promotionValueForItem, math_1.MathBN.div(percentage, 100));
20
- }
21
- // For each allocation, promotion is applied in the scope of the line item.
22
- // lineItemAmount will be the total applicable amount for the line item
23
- // maximumPromotionAmount is the maximum amount that can be applied to the line item
24
- // We need to return the minimum of the two
25
- const maximumQuantity = math_1.MathBN.min(lineItem.quantity, promotion.max_quantity ?? math_1.MathBN.convert(1));
26
- const maximumPromotionAmount = math_1.MathBN.mult(promotion.value, maximumQuantity);
27
- return math_1.MathBN.min(maximumPromotionAmount, lineItemAmount);
28
- }
29
- function getPromotionValue(promotion, lineItemAmount, lineItemsAmount, lineItem) {
30
- if (promotion.type === promotion_1.ApplicationMethodType.PERCENTAGE) {
31
- return getPromotionValueForPercentage(promotion, lineItemAmount);
32
- }
33
- return getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount, lineItem);
34
- }
35
- function getApplicableQuantity(lineItem, maxQuantity) {
36
- if (maxQuantity && lineItem.quantity) {
37
- return math_1.MathBN.min(lineItem.quantity, maxQuantity);
38
- }
39
- return lineItem.quantity;
40
- }
41
- function getLineItemSubtotal(lineItem) {
42
- return math_1.MathBN.div(lineItem.subtotal, lineItem.quantity);
43
- }
44
- function getLineItemOriginalTotal(lineItem) {
45
- return math_1.MathBN.div(lineItem.original_total, lineItem.quantity);
46
- }
47
- function calculateAdjustmentAmountFromPromotion(lineItem, promotion, lineItemsAmount = 0) {
48
- /*
49
- For a promotion with an across allocation, we consider not only the line item total, but also the total of all other line items in the order.
50
-
51
- We then distribute the promotion value proportionally across the line items based on the total of each line item.
52
-
53
- For example, if the promotion is 100$, and the order total is 400$, and the items are:
54
- item1: 250$
55
- item2: 150$
56
- total: 400$
57
-
58
- The promotion value for the line items would be:
59
- item1: 62.5$
60
- item2: 37.5$
61
- total: 100$
62
-
63
- For the next 100$ promotion, we remove the applied promotions value from the line item total and redistribute the promotion value across the line items based on the updated totals.
64
-
65
- Example:
66
- item1: (250 - 62.5) = 187.5
67
- item2: (150 - 37.5) = 112.5
68
- total: 300
69
-
70
- The promotion value for the line items would be:
71
- item1: $62.5
72
- item2: $37.5
73
- total: 100$
74
-
75
- */
76
- if (promotion.allocation === promotion_1.ApplicationMethodAllocation.ACROSS) {
77
- const quantity = getApplicableQuantity(lineItem, promotion.max_quantity);
78
- const lineItemAmount = math_1.MathBN.mult(promotion.is_tax_inclusive
79
- ? getLineItemOriginalTotal(lineItem)
80
- : getLineItemSubtotal(lineItem), quantity);
81
- const applicableAmount = math_1.MathBN.sub(lineItemAmount, promotion.applied_value);
82
- if (math_1.MathBN.lte(applicableAmount, big_number_1.MEDUSA_EPSILON)) {
83
- return math_1.MathBN.convert(0);
84
- }
85
- const promotionValue = getPromotionValue(promotion, applicableAmount, lineItemsAmount, lineItem);
86
- const returnValue = math_1.MathBN.min(promotionValue, applicableAmount);
87
- if (math_1.MathBN.lte(returnValue, big_number_1.MEDUSA_EPSILON)) {
88
- return math_1.MathBN.convert(0);
89
- }
90
- return returnValue;
91
- }
92
- /*
93
- For a promotion with an EACH allocation, we calculate the promotion value on the line item as a whole.
94
-
95
- Example:
96
- item1: {
97
- subtotal: 200$,
98
- unit_price: 50$,
99
- quantity: 4,
100
- }
101
-
102
- When applying promotions, we need to consider 2 values:
103
- 1. What is the maximum promotion value?
104
- 2. What is the maximum promotion we can apply on the line item?
105
-
106
- After applying each promotion, we reduce the maximum promotion that you can add to the line item by the value of the promotions applied.
107
-
108
- We then apply whichever is lower.
109
- */
110
- const remainingItemAmount = math_1.MathBN.sub(promotion.is_tax_inclusive ? lineItem.original_total : lineItem.subtotal, promotion.applied_value);
111
- const itemAmount = math_1.MathBN.div(promotion.is_tax_inclusive ? lineItem.original_total : lineItem.subtotal, lineItem.quantity);
112
- const maximumPromotionAmount = math_1.MathBN.mult(itemAmount, promotion.max_quantity ?? math_1.MathBN.convert(1));
113
- const applicableAmount = math_1.MathBN.min(remainingItemAmount, maximumPromotionAmount);
114
- if (math_1.MathBN.lte(applicableAmount, big_number_1.MEDUSA_EPSILON)) {
115
- return math_1.MathBN.convert(0);
116
- }
117
- const promotionValue = getPromotionValue(promotion, applicableAmount, lineItemsAmount, lineItem);
118
- const returnValue = math_1.MathBN.min(promotionValue, applicableAmount);
119
- if (math_1.MathBN.lte(returnValue, big_number_1.MEDUSA_EPSILON)) {
120
- return math_1.MathBN.convert(0);
121
- }
122
- return returnValue;
123
- }
124
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/totals/promotion/index.ts"],"names":[],"mappings":";;AAkDA,8CAgBC;AAED,sDAMC;AAUD,wFAuHC;AA1MD,+CAGwB;AACxB,kCAAgC;AAChC,8CAA8C;AAE9C,SAAS,8BAA8B,CAAC,SAAS,EAAE,cAAc;IAC/D,OAAO,aAAM,CAAC,IAAI,CAAC,aAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,CAAA;AACtE,CAAC;AAED,SAAS,yBAAyB,CAChC,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ;IAER,IAAI,SAAS,CAAC,UAAU,KAAK,uCAA2B,CAAC,MAAM,EAAE,CAAC;QAChE,MAAM,q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AE,CAAC;QAC5C,OAAO,aAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -1,28 +0,0 @@
1
- import { AdjustmentLineDTO, TaxLineDTO } from "@acmekit/types";
2
- import { BigNumber } from "../big-number";
3
- interface GetShippingMethodsTotalsContext {
4
- includeTax?: boolean;
5
- }
6
- export interface GetShippingMethodTotalInput {
7
- id: string;
8
- amount: BigNumber;
9
- is_tax_inclusive?: boolean;
10
- tax_lines?: TaxLineDTO[];
11
- adjustments?: Pick<AdjustmentLineDTO, "amount">[];
12
- }
13
- export interface GetShippingMethodTotalOutput {
14
- amount: BigNumber;
15
- subtotal: BigNumber;
16
- original_subtotal: BigNumber;
17
- total: BigNumber;
18
- original_total: BigNumber;
19
- discount_total: BigNumber;
20
- discount_subtotal: BigNumber;
21
- discount_tax_total: BigNumber;
22
- tax_total: BigNumber;
23
- original_tax_total: BigNumber;
24
- }
25
- export declare function getShippingMethodsTotals(shippingMethods: GetShippingMethodTotalInput[], context: GetShippingMethodsTotalsContext): Record<string, GetShippingMethodTotalOutput>;
26
- export declare function getShippingMethodTotals(shippingMethod: GetShippingMethodTotalInput, context: GetShippingMethodsTotalsContext): GetShippingMethodTotalOutput;
27
- export {};
28
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/totals/shipping-method/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAIzC,UAAU,+BAA+B;IACvC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,SAAS,CAAA;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,SAAS,CAAC,EAAE,UAAU,EAAE,CAAA;IACxB,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAA;CAClD;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,SAAS,CAAA;IAEjB,QAAQ,EAAE,SAAS,CAAA;IACnB,iBAAiB,EAAE,SAAS,CAAA;IAE5B,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,SAAS,CAAA;IAEzB,cAAc,EAAE,SAAS,CAAA;IACzB,iBAAiB,EAAE,SAAS,CAAA;IAC5B,kBAAkB,EAAE,SAAS,CAAA;IAE7B,SAAS,EAAE,SAAS,CAAA;IACpB,kBAAkB,EAAE,SAAS,CAAA;CAC9B;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,2BAA2B,EAAE,EAC9C,OAAO,EAAE,+BAA+B,GACvC,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAa9C;AAED,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,2BAA2B,EAC3C,OAAO,EAAE,+BAA+B,gCAmEzC"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getShippingMethodsTotals = getShippingMethodsTotals;
4
- exports.getShippingMethodTotals = getShippingMethodTotals;
5
- const adjustment_1 = require("../adjustment");
6
- const big_number_1 = require("../big-number");
7
- const math_1 = require("../math");
8
- const tax_1 = require("../tax");
9
- function getShippingMethodsTotals(shippingMethods, context) {
10
- const shippingMethodsTotals = {};
11
- let index = 0;
12
- for (const shippingMethod of shippingMethods) {
13
- shippingMethodsTotals[shippingMethod.id ?? index] = getShippingMethodTotals(shippingMethod, context);
14
- index++;
15
- }
16
- return shippingMethodsTotals;
17
- }
18
- function getShippingMethodTotals(shippingMethod, context) {
19
- const isTaxInclusive = shippingMethod.is_tax_inclusive ?? context.includeTax;
20
- const shippingMethodAmount = math_1.MathBN.convert(shippingMethod.amount);
21
- const sumTax = math_1.MathBN.sum(...(shippingMethod.tax_lines?.map((taxLine) => taxLine.rate) ?? []));
22
- const sumTaxRate = math_1.MathBN.div(sumTax, 100);
23
- const subtotal = isTaxInclusive
24
- ? math_1.MathBN.div(shippingMethodAmount, math_1.MathBN.add(1, sumTaxRate))
25
- : shippingMethodAmount;
26
- const { adjustmentsTotal: discountsTotal, adjustmentsSubtotal: discountsSubtotal, adjustmentsTaxTotal: discountsTaxTotal, } = (0, adjustment_1.calculateAdjustmentTotal)({
27
- adjustments: shippingMethod.adjustments || [],
28
- taxRate: sumTaxRate,
29
- });
30
- const taxLines = shippingMethod.tax_lines || [];
31
- const taxTotal = (0, tax_1.calculateTaxTotal)({
32
- taxLines,
33
- taxableAmount: math_1.MathBN.sub(subtotal, discountsSubtotal),
34
- setTotalField: "total",
35
- });
36
- const originalTaxTotal = (0, tax_1.calculateTaxTotal)({
37
- taxLines,
38
- taxableAmount: subtotal,
39
- setTotalField: "subtotal",
40
- });
41
- const totals = {
42
- amount: new big_number_1.BigNumber(shippingMethodAmount),
43
- subtotal: new big_number_1.BigNumber(subtotal),
44
- total: new big_number_1.BigNumber(math_1.MathBN.sum(math_1.MathBN.sub(subtotal, discountsSubtotal), taxTotal)),
45
- original_subtotal: new big_number_1.BigNumber(math_1.MathBN.sub(isTaxInclusive
46
- ? shippingMethodAmount
47
- : math_1.MathBN.add(subtotal, originalTaxTotal), originalTaxTotal)),
48
- original_total: new big_number_1.BigNumber(isTaxInclusive
49
- ? shippingMethodAmount
50
- : math_1.MathBN.add(subtotal, originalTaxTotal)),
51
- discount_total: new big_number_1.BigNumber(discountsTotal),
52
- discount_subtotal: new big_number_1.BigNumber(discountsSubtotal),
53
- discount_tax_total: new big_number_1.BigNumber(discountsTaxTotal),
54
- tax_total: new big_number_1.BigNumber(taxTotal),
55
- original_tax_total: new big_number_1.BigNumber(originalTaxTotal),
56
- };
57
- return totals;
58
- }
59
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1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AE,IAAI,sBAAS,CAAC,iBAAiB,CAAC;QAEpD,SAAS,EAAE,IAAI,sBAAS,CAAC,QAAQ,CAAC;QAClC,kBAAkB,EAAE,IAAI,sBAAS,CAAC,gBAAgB,CAAC;KACpD,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,16 +0,0 @@
1
- import { BigNumberInput, TaxLineDTO } from "@acmekit/types";
2
- export declare function calculateTaxTotal({ isTaxInclusive, taxLines, taxableAmount, setTotalField, }: {
3
- isTaxInclusive?: boolean;
4
- taxLines: Pick<TaxLineDTO, "rate">[];
5
- taxableAmount: BigNumberInput;
6
- setTotalField?: string;
7
- }): globalThis.BigNumber;
8
- export declare function calculateAmountsWithTax({ taxLines, amount, includesTax, }: {
9
- taxLines: Pick<TaxLineDTO, "rate">[];
10
- amount: number;
11
- includesTax?: boolean;
12
- }): {
13
- priceWithTax: number;
14
- priceWithoutTax: number;
15
- };
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/totals/tax/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAI3D,wBAAgB,iBAAiB,CAAC,EAChC,cAAsB,EACtB,QAAQ,EACR,aAAa,EACb,aAAa,GACd,EAAE;IACD,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAA;IACpC,aAAa,EAAE,cAAc,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,wBAkBA;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAM,EACN,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAA;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;;;EAmBA"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateTaxTotal = calculateTaxTotal;
4
- exports.calculateAmountsWithTax = calculateAmountsWithTax;
5
- const big_number_1 = require("../big-number");
6
- const math_1 = require("../math");
7
- function calculateTaxTotal({ isTaxInclusive = false, taxLines, taxableAmount, setTotalField, }) {
8
- let taxTotal = math_1.MathBN.convert(0);
9
- if (isTaxInclusive) {
10
- return taxTotal;
11
- }
12
- for (const taxLine of taxLines) {
13
- const rate = math_1.MathBN.div(taxLine.rate, 100);
14
- let taxAmount = math_1.MathBN.mult(taxableAmount, rate);
15
- if (setTotalField) {
16
- ;
17
- taxLine[setTotalField] = new big_number_1.BigNumber(taxAmount);
18
- }
19
- taxTotal = math_1.MathBN.add(taxTotal, taxAmount);
20
- }
21
- return taxTotal;
22
- }
23
- function calculateAmountsWithTax({ taxLines, amount, includesTax, }) {
24
- const sumTaxRate = math_1.MathBN.div(math_1.MathBN.sum(...((taxLines ?? []).map((taxLine) => taxLine.rate) ?? [])), 100);
25
- const taxableAmount = includesTax
26
- ? math_1.MathBN.div(amount, math_1.MathBN.add(1, sumTaxRate))
27
- : amount;
28
- const tax = calculateTaxTotal({
29
- taxLines,
30
- taxableAmount,
31
- });
32
- return {
33
- priceWithTax: includesTax ? amount : math_1.MathBN.add(tax, amount).toNumber(),
34
- priceWithoutTax: includesTax ? math_1.MathBN.sub(amount, tax).toNumber() : amount,
35
- };
36
- }
37
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/totals/tax/index.ts"],"names":[],"mappings":";;AAIA,8CA4BC;AAED,0DA2BC;AA5DD,8CAAyC;AACzC,kCAAgC;AAEhC,SAAgB,iBAAiB,CAAC,EAChC,cAAc,GAAG,KAAK,EACtB,QAAQ,EACR,aAAa,EACb,aAAa,GAMd;IACC,IAAI,QAAQ,GAAG,aAAM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GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE;QACvE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,aAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM;KAC3E,CAAA;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function transformPropertiesToBigNumber(obj: any, { prefix, include, exclude, }?: {
2
- prefix?: string;
3
- include?: string[];
4
- exclude?: string[];
5
- }): void;
6
- //# sourceMappingURL=transform-properties-to-bignumber.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-properties-to-bignumber.d.ts","sourceRoot":"","sources":["../../src/totals/transform-properties-to-bignumber.ts"],"names":[],"mappings":"AAEA,wBAAgB,8BAA8B,CAC5C,GAAG,KAAA,EACH,EACE,MAAe,EACf,OAAY,EACZ,OAAY,GACb,GAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACd,QA2CP"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformPropertiesToBigNumber = transformPropertiesToBigNumber;
4
- const big_number_1 = require("./big-number");
5
- function transformPropertiesToBigNumber(obj, { prefix = "raw_", include = [], exclude = [], } = {}) {
6
- const stack = [{ current: obj, path: "" }];
7
- while (stack.length > 0) {
8
- const { current, path } = stack.pop();
9
- if (current == null ||
10
- typeof current !== "object" ||
11
- current instanceof big_number_1.BigNumber) {
12
- continue;
13
- }
14
- if (Array.isArray(current)) {
15
- current.forEach((element, index) => stack.push({ current: element, path }));
16
- }
17
- else {
18
- for (const key of Object.keys(current)) {
19
- const value = current[key];
20
- const currentPath = path ? `${path}.${key}` : key;
21
- if (value != null && !exclude.includes(currentPath)) {
22
- if (key.startsWith(prefix)) {
23
- const newKey = key.replace(prefix, "");
24
- const newPath = path ? `${path}.${newKey}` : newKey;
25
- if (!exclude.includes(newPath)) {
26
- current[newKey] = new big_number_1.BigNumber(value);
27
- continue;
28
- }
29
- }
30
- else if (include.includes(currentPath)) {
31
- current[key] = new big_number_1.BigNumber(value);
32
- continue;
33
- }
34
- }
35
- stack.push({ current: value, path: currentPath });
36
- }
37
- }
38
- }
39
- }
40
- //# sourceMappingURL=transform-properties-to-bignumber.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-properties-to-bignumber.js","sourceRoot":"","sources":["../../src/totals/transform-properties-to-bignumber.ts"],"names":[],"mappings":";;AAEA,wEAqDC;AAvDD,6CAAwC;AAExC,SAAgB,8BAA8B,CAC5C,GAAG,EACH,EACE,MAAM,GAAG,MAAM,EACf,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,EAAE,MAKV,EAAE;IAEN,MAAM,KAAK,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAE1C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;QAEtC,IACE,OAAO,IAAI,IAAI;YACf,OAAO,OAAO,KAAK,QAAQ;YAC3B,OAAO,YAAY,sBAAS,EAC5B,CAAC;YACD,SAAQ;QACV,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACjC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CACvC,CAAA;QACH,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;gBAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;gBAEjD,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBACpD,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;wBAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;wBAEtC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAA;wBACnD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,sBAAS,CAAC,KAAK,CAAC,CAAA;4BACtC,SAAQ;wBACV,CAAC;oBACH,CAAC;yBAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;wBACzC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,sBAAS,CAAC,KAAK,CAAC,CAAA;wBACnC,SAAQ;oBACV,CAAC;gBACH,CAAC;gBAED,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,12 +0,0 @@
1
- import { ItemTaxLineDTO, AcmeKitContainer, ShippingTaxLineDTO } from "@acmekit/types";
2
- /**
3
- * Applies translations to tax lines. If you are using a tax provider that doesn't have TaxRates defined in the database,
4
- * you should apply the translations inside of your tax provider's `getTaxLines` method, using the `locale` provided in the context.
5
- *
6
- * @param taxLines - The tax lines to apply translations to.
7
- * @param locale - The locale to apply translations to.
8
- * @param container - The container to use for the translations.
9
- * @returns The tax lines with translations applied.
10
- */
11
- export declare const applyTranslationsToTaxLines: (taxLines: ItemTaxLineDTO[] | ShippingTaxLineDTO[], locale: string | undefined, container: AcmeKitContainer) => Promise<ItemTaxLineDTO[] | ShippingTaxLineDTO[]>;
12
- //# sourceMappingURL=apply-translations-to-tax-lines.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-translations-to-tax-lines.d.ts","sourceRoot":"","sources":["../../src/translations/apply-translations-to-tax-lines.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAA;AAEvB;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,cAAc,EAAE,GAAG,kBAAkB,EAAE,EACjD,QAAQ,MAAM,GAAG,SAAS,EAC1B,WAAW,gBAAgB,qDA6B5B,CAAA"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyTranslationsToTaxLines = void 0;
4
- const apply_translations_1 = require("./apply-translations");
5
- /**
6
- * Applies translations to tax lines. If you are using a tax provider that doesn't have TaxRates defined in the database,
7
- * you should apply the translations inside of your tax provider's `getTaxLines` method, using the `locale` provided in the context.
8
- *
9
- * @param taxLines - The tax lines to apply translations to.
10
- * @param locale - The locale to apply translations to.
11
- * @param container - The container to use for the translations.
12
- * @returns The tax lines with translations applied.
13
- */
14
- const applyTranslationsToTaxLines = async (taxLines, locale, container) => {
15
- const translatedTaxRates = taxLines.map((taxLine) => ({
16
- id: taxLine.rate_id,
17
- name: taxLine.name,
18
- }));
19
- await (0, apply_translations_1.applyTranslations)({
20
- localeCode: locale,
21
- objects: translatedTaxRates,
22
- container,
23
- });
24
- const rateTranslationMap = new Map();
25
- for (const translatedRate of translatedTaxRates) {
26
- if (!!translatedRate.id) {
27
- rateTranslationMap.set(translatedRate.id, translatedRate.name);
28
- }
29
- }
30
- for (const taxLine of taxLines) {
31
- if (taxLine.rate_id) {
32
- taxLine.name = rateTranslationMap.get(taxLine.rate_id);
33
- }
34
- }
35
- return taxLines;
36
- };
37
- exports.applyTranslationsToTaxLines = applyTranslationsToTaxLines;
38
- //# sourceMappingURL=apply-translations-to-tax-lines.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-translations-to-tax-lines.js","sourceRoot":"","sources":["../../src/translations/apply-translations-to-tax-lines.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AAOxD;;;;;;;;GAQG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAC9C,QAAiD,EACjD,MAA0B,EAC1B,SAA2B,EAC3B,EAAE;IACF,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,CACrC,CAAC,OAA4C,EAAE,EAAE,CAAC,CAAC;QACjD,EAAE,EAAE,OAAO,CAAC,OAAO;QACnB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CACH,CAAA;IAED,MAAM,IAAA,sCAAiB,EAAC;QACtB,UAAU,EAAE,MAAM;QAClB,OAAO,EAAE,kBAAkB;QAC3B,SAAS;KACV,CAAC,CAAA;IAEF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;IACpD,KAAK,MAAM,cAAc,IAAI,kBAAkB,EAAE,CAAC;QAChD,IAAI,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;YACxB,kBAAkB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAE,CAAA;QACzD,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAhCY,QAAA,2BAA2B,+BAgCvC"}