@medusajs/promotion 0.0.5-snapshot-20240530075042 → 0.0.5-snapshot-20240531083729

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"promotion-module.d.ts","sourceRoot":"","sources":["../../src/services/promotion-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,GAAG,EACH,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EASL,eAAe,EAOhB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,SAAS,EACT,aAAa,EACb,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,0BAA0B,EAU3B,MAAM,QAAQ,CAAA;AAWf,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAC5D,wBAAwB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACpE,oBAAoB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAChE,yBAAyB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACrE,eAAe,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAC3D,qBAAqB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;CAClE,CAAA;;uBAsBwB;QAAE,GAAG,EAAE,eAAe,oBAAoB,CAAA;KAAE;cACrD;QAAE,GAAG,EAAE,eAAe,WAAW,CAAA;KAAE;oBAC7B;QAAE,GAAG,EAAE,eAAe,iBAAiB,CAAA;KAAE;mBAC1C;QAAE,GAAG,EAAE,eAAe,gBAAgB,CAAA;KAAE;wBACnC;QAAE,GAAG,EAAE,eAAe,qBAAqB,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CAC3C,IAAI,EAAE,cAAc,CAAC,0BAA0B,EAC9B,aAAa,GAAE,OAAY;CAiC/C"}
@@ -63,10 +63,9 @@ class PromotionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServi
63
63
  }
64
64
  if (campaignBudget.type === utils_1.CampaignBudgetType.SPEND) {
65
65
  const campaignBudgetData = promotionCodeCampaignBudgetMap.get(campaignBudget.id) || { id: campaignBudget.id, used: campaignBudget.used ?? 0 };
66
- campaignBudgetData.used =
67
- (campaignBudgetData.used ?? 0) + computedAction.amount;
66
+ campaignBudgetData.used = utils_1.MathBN.add(campaignBudgetData.used ?? 0, computedAction.amount);
68
67
  if (campaignBudget.limit &&
69
- campaignBudgetData.used > campaignBudget.limit) {
68
+ utils_1.MathBN.gt(campaignBudgetData.used, campaignBudget.limit)) {
70
69
  continue;
71
70
  }
72
71
  promotionCodeCampaignBudgetMap.set(campaignBudget.id, campaignBudgetData);
@@ -78,10 +77,10 @@ class PromotionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServi
78
77
  }
79
78
  const campaignBudgetData = {
80
79
  id: campaignBudget.id,
81
- used: (campaignBudget.used ?? 0) + 1,
80
+ used: utils_1.MathBN.add(campaignBudget.used ?? 0, 1),
82
81
  };
83
82
  if (campaignBudget.limit &&
84
- campaignBudgetData.used > campaignBudget.limit) {
83
+ utils_1.MathBN.gt(campaignBudgetData.used, campaignBudget.limit)) {
85
84
  continue;
86
85
  }
87
86
  promotionCodeCampaignBudgetMap.set(campaignBudget.id, campaignBudgetData);
@@ -209,6 +208,7 @@ class PromotionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServi
209
208
  }
210
209
  }
211
210
  }
211
+ (0, utils_1.transformPropertiesToBigNumber)(computedActions, { include: ["amount"] });
212
212
  return computedActions;
213
213
  }
214
214
  async create(data, sharedContext = {}) {
@@ -1,26 +1,26 @@
1
- import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, PromotionDTO } from "@medusajs/types";
1
+ import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, BigNumberInput, PromotionDTO } from "@medusajs/types";
2
2
  import { Promotion } from "../models";
3
3
  export interface CreateApplicationMethodDTO {
4
4
  type: ApplicationMethodTypeValues;
5
5
  target_type: ApplicationMethodTargetTypeValues;
6
6
  allocation?: ApplicationMethodAllocationValues;
7
- value?: number;
7
+ value?: BigNumberInput;
8
8
  currency_code: string;
9
9
  promotion: Promotion | string | PromotionDTO;
10
- max_quantity?: number | null;
11
- buy_rules_min_quantity?: number | null;
12
- apply_to_quantity?: number | null;
10
+ max_quantity?: BigNumberInput | null;
11
+ buy_rules_min_quantity?: BigNumberInput | null;
12
+ apply_to_quantity?: BigNumberInput | null;
13
13
  }
14
14
  export interface UpdateApplicationMethodDTO {
15
15
  id?: string;
16
16
  type?: ApplicationMethodTypeValues;
17
17
  target_type?: ApplicationMethodTargetTypeValues;
18
18
  allocation?: ApplicationMethodAllocationValues;
19
- value?: number;
19
+ value?: BigNumberInput;
20
20
  currency_code?: string;
21
21
  promotion?: Promotion | string | PromotionDTO;
22
- max_quantity?: number | null;
23
- buy_rules_min_quantity?: number | null;
24
- apply_to_quantity?: number | null;
22
+ max_quantity?: BigNumberInput | null;
23
+ buy_rules_min_quantity?: BigNumberInput | null;
24
+ apply_to_quantity?: BigNumberInput | null;
25
25
  }
26
26
  //# sourceMappingURL=application-method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../src/types/application-method.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,EAC3B,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,2BAA2B,CAAA;IACjC,WAAW,EAAE,iCAAiC,CAAA;IAC9C,UAAU,CAAC,EAAE,iCA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AAA;IAC5C,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACpC,sBAAsB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9C,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAC1C;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,2BAA2B,CAAA;IAClC,WAAW,CAAC,EAAE,iCAAiC,CAAA;IAC/C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAC9C,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;IAC7C,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACpC,sBAAsB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9C,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAC1C"}
@@ -1,17 +1,17 @@
1
- import { CampaignBudgetTypeValues } from "@medusajs/types";
1
+ import { BigNumberInput, CampaignBudgetTypeValues } from "@medusajs/types";
2
2
  import { Campaign } from "../models";
3
3
  export interface CreateCampaignBudgetDTO {
4
4
  type?: CampaignBudgetTypeValues;
5
- limit?: number | null;
5
+ limit?: BigNumberInput | null;
6
6
  currency_code?: string | null;
7
- used?: number;
7
+ used?: BigNumberInput;
8
8
  campaign?: Campaign | string;
9
9
  }
10
10
  export interface UpdateCampaignBudgetDTO {
11
11
  id: string;
12
12
  type?: CampaignBudgetTypeValues;
13
- limit?: number | null;
13
+ limit?: BigNumberInput | null;
14
14
  currency_code?: string | null;
15
- used?: number;
15
+ used?: BigNumberInput;
16
16
  }
17
17
  //# sourceMappingURL=campaign-budget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"campaign-budget.d.ts","sourceRoot":"","sources":["../../src/types/campaign-budget.ts"],"names":[],"mappings":"AAAA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AA;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB"}
@@ -1,5 +1,5 @@
1
- import { PromotionTypes } from "@medusajs/types";
1
+ import { BigNumberInput, PromotionTypes } from "@medusajs/types";
2
2
  import { ApplicationMethodTargetType } from "@medusajs/utils";
3
- export declare function getComputedActionsForBuyGet(promotion: PromotionTypes.PromotionDTO, itemsContext: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.ITEMS], methodIdPromoValueMap: Map<string, number>): PromotionTypes.ComputeActions[];
3
+ export declare function getComputedActionsForBuyGet(promotion: PromotionTypes.PromotionDTO, itemsContext: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.ITEMS], methodIdPromoValueMap: Map<string, BigNumberInput>): PromotionTypes.ComputeActions[];
4
4
  export declare function sortByBuyGetType(a: any, b: any): 0 | 1 | -1;
5
5
  //# sourceMappingURL=buy-get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buy-get.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/buy-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,2BAA2B,EAK5B,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,YAAY,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EACpF,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,cAAc,EAAE,CA6EjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,cAWpC"}
1
+ {"version":3,"file":"buy-get.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/buy-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EACL,2BAA2B,EAM5B,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,YAAY,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EACpF,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GACjD,cAAc,CAAC,cAAc,EAAE,CAkFjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,cAWpC"}
@@ -17,29 +17,29 @@ function getComputedActionsForBuyGet(promotion, itemsContext, methodIdPromoValue
17
17
  if (!Array.isArray(buyRules) || !Array.isArray(targetRules)) {
18
18
  return [];
19
19
  }
20
- const validQuantity = itemsContext
20
+ const validQuantity = utils_1.MathBN.sum(...itemsContext
21
21
  .filter((item) => (0, validations_1.areRulesValidForContext)(buyRules, item))
22
- .reduce((acc, next) => acc + next.quantity, 0);
22
+ .map((item) => item.quantity));
23
23
  if (!buyRulesMinQuantity ||
24
24
  !applyToQuantity ||
25
- buyRulesMinQuantity > validQuantity) {
25
+ utils_1.MathBN.gt(buyRulesMinQuantity, validQuantity)) {
26
26
  return [];
27
27
  }
28
28
  const validItemsForTargetRules = itemsContext
29
29
  .filter((item) => (0, validations_1.areRulesValidForContext)(targetRules, item))
30
30
  .filter((item) => (0, utils_1.isPresent)(item.subtotal) && (0, utils_1.isPresent)(item.quantity))
31
31
  .sort((a, b) => {
32
- const aPrice = a.subtotal / a.quantity;
33
- const bPrice = b.subtotal / b.quantity;
34
- return bPrice - aPrice;
32
+ const aPrice = utils_1.MathBN.div(a.subtotal, a.quantity);
33
+ const bPrice = utils_1.MathBN.div(b.subtotal, b.quantity);
34
+ return utils_1.MathBN.lt(bPrice, aPrice) ? -1 : 1;
35
35
  });
36
- let remainingQtyToApply = applyToQuantity;
36
+ let remainingQtyToApply = utils_1.MathBN.convert(applyToQuantity);
37
37
  for (const method of validItemsForTargetRules) {
38
38
  const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0;
39
- const multiplier = Math.min(method.quantity, remainingQtyToApply);
40
- const amount = (method.subtotal / method.quantity) * multiplier;
41
- const newRemainingQtyToApply = remainingQtyToApply - multiplier;
42
- if (newRemainingQtyToApply < 0 || amount <= 0) {
39
+ const multiplier = utils_1.MathBN.min(method.quantity, remainingQtyToApply);
40
+ const amount = utils_1.MathBN.mult(utils_1.MathBN.div(method.subtotal, method.quantity), multiplier);
41
+ const newRemainingQtyToApply = utils_1.MathBN.sub(remainingQtyToApply, multiplier);
42
+ if (utils_1.MathBN.lt(newRemainingQtyToApply, 0) || utils_1.MathBN.lte(amount, 0)) {
43
43
  break;
44
44
  }
45
45
  else {
@@ -50,7 +50,7 @@ function getComputedActionsForBuyGet(promotion, itemsContext, methodIdPromoValue
50
50
  computedActions.push(budgetExceededAction);
51
51
  continue;
52
52
  }
53
- methodIdPromoValueMap.set(method.id, appliedPromoValue + amount);
53
+ methodIdPromoValueMap.set(method.id, utils_1.MathBN.add(appliedPromoValue, amount));
54
54
  computedActions.push({
55
55
  action: utils_1.ComputedActions.ADD_ITEM_ADJUSTMENT,
56
56
  item_id: method.id,
@@ -1 +1 @@
1
- {"version":3,"file":"line-items.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/line-items.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAIL,2BAA2B,IAAI,UAAU,EAE1C,MAAM,iBAAiB,CAAA;AAgBxB,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,KAAK,EAAE,cAAc,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,EAC5D,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,kBAAkB,CAAC,EAAE,iCAAiC,GACrD,cAAc,CAAC,cAAc,EAAE,CASjC;AAED,wBAAgB,oCAAoC,CAClD,SAAS,EA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,GACzC,cAAc,CAAC,cAAc,EAAE,CAOjC"}
@@ -32,9 +32,9 @@ function applyPromotionToItems(promotion, items, appliedPromotionsMap, allocatio
32
32
  const isTargetShippingMethod = target === utils_1.ApplicationMethodTargetType.SHIPPING_METHODS;
33
33
  const isTargetLineItems = target === utils_1.ApplicationMethodTargetType.ITEMS;
34
34
  const isTargetOrder = target === utils_1.ApplicationMethodTargetType.ORDER;
35
- let lineItemsTotal = 0;
35
+ let lineItemsTotal = utils_1.MathBN.convert(0);
36
36
  if (allocation === utils_1.ApplicationMethodAllocation.ACROSS) {
37
- lineItemsTotal = applicableItems.reduce((acc, item) => acc + item.subtotal - (appliedPromotionsMap.get(item.id) ?? 0), 0);
37
+ lineItemsTotal = applicableItems.reduce((acc, item) => utils_1.MathBN.sub(utils_1.MathBN.add(acc, item.subtotal), appliedPromotionsMap.get(item.id) ?? 0), utils_1.MathBN.convert(0));
38
38
  }
39
39
  for (const item of applicableItems) {
40
40
  const appliedPromoValue = appliedPromotionsMap.get(item.id) ?? 0;
@@ -51,7 +51,7 @@ function applyPromotionToItems(promotion, items, appliedPromotionsMap, allocatio
51
51
  type: applicationMethod?.type,
52
52
  allocation,
53
53
  }, lineItemsTotal);
54
- if (amount <= 0) {
54
+ if (utils_1.MathBN.lte(amount, 0)) {
55
55
  continue;
56
56
  }
57
57
  const budgetExceededAction = (0, usage_1.computeActionForBudgetExceeded)(promotion, amount);
@@ -59,7 +59,7 @@ function applyPromotionToItems(promotion, items, appliedPromotionsMap, allocatio
59
59
  computedActions.push(budgetExceededAction);
60
60
  continue;
61
61
  }
62
- appliedPromotionsMap.set(item.id, appliedPromoValue + amount);
62
+ appliedPromotionsMap.set(item.id, utils_1.MathBN.add(appliedPromoValue, amount));
63
63
  if (isTargetLineItems || isTargetOrder) {
64
64
  computedActions.push({
65
65
  action: utils_1.ComputedActions.ADD_ITEM_ADJUSTMENT,
@@ -1,5 +1,5 @@
1
- import { PromotionTypes } from "@medusajs/types";
1
+ import { BigNumberInput, PromotionTypes } from "@medusajs/types";
2
2
  import { ApplicationMethodTargetType } from "@medusajs/utils";
3
3
  export declare function getComputedActionsForShippingMethods(promotion: PromotionTypes.PromotionDTO, shippingMethodApplicationContext: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.SHIPPING_METHODS], methodIdPromoValueMap: Map<string, number>): PromotionTypes.ComputeActions[];
4
- export declare function applyPromotionToShippingMethods(promotion: PromotionTypes.PromotionDTO, shippingMethods: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.SHIPPING_METHODS], methodIdPromoValueMap: Map<string, number>): PromotionTypes.ComputeActions[];
4
+ export declare function applyPromotionToShippingMethods(promotion: PromotionTypes.PromotionDTO, shippingMethods: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.SHIPPING_METHODS], methodIdPromoValueMap: Map<string, BigNumberInput>): PromotionTypes.ComputeActions[];
5
5
  //# sourceMappingURL=shipping-methods.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shipping-methods.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/shipping-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAEL,2BAA2B,EAI5B,MAAM,iBAAiB,CAAA;AAIxB,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,gCAAgC,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,EACnH,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,cAAc,EAAE,CA6BjC;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,eAAe,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,EAClG,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,cAAc,EAAE,CA0GjC"}
1
+ {"version":3,"file":"shipping-methods.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/shipping-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAEL,2BAA2B,EAK5B,MAAM,iBAAiB,CAAA;AAIxB,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,gCAAgC,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,EACnH,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,cAAc,EAAE,CA6BjC;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,eAAe,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,EAClG,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GACjD,cAAc,CAAC,cAAc,EAAE,CA2HjC"}
@@ -29,13 +29,13 @@ function applyPromotionToShippingMethods(promotion, shippingMethods, methodIdPro
29
29
  continue;
30
30
  }
31
31
  const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0;
32
- let promotionValue = applicationMethod?.value ?? 0;
33
- const applicableTotal = method.subtotal - appliedPromoValue;
32
+ let promotionValue = utils_1.MathBN.convert(applicationMethod?.value ?? 0);
33
+ const applicableTotal = utils_1.MathBN.sub(method.subtotal, appliedPromoValue);
34
34
  if (applicationMethod?.type === utils_1.ApplicationMethodType.PERCENTAGE) {
35
- promotionValue = (promotionValue / 100) * applicableTotal;
35
+ promotionValue = utils_1.MathBN.mult(utils_1.MathBN.div(promotionValue, 100), applicableTotal);
36
36
  }
37
- const amount = Math.min(promotionValue, applicableTotal);
38
- if (amount <= 0) {
37
+ const amount = utils_1.MathBN.min(promotionValue, applicableTotal);
38
+ if (utils_1.MathBN.lte(amount, 0)) {
39
39
  continue;
40
40
  }
41
41
  const budgetExceededAction = (0, usage_1.computeActionForBudgetExceeded)(promotion, amount);
@@ -43,7 +43,7 @@ function applyPromotionToShippingMethods(promotion, shippingMethods, methodIdPro
43
43
  computedActions.push(budgetExceededAction);
44
44
  continue;
45
45
  }
46
- methodIdPromoValueMap.set(method.id, appliedPromoValue + amount);
46
+ methodIdPromoValueMap.set(method.id, utils_1.MathBN.add(appliedPromoValue, amount));
47
47
  computedActions.push({
48
48
  action: utils_1.ComputedActions.ADD_SHIPPING_METHOD_ADJUSTMENT,
49
49
  shipping_method_id: method.id,
@@ -55,9 +55,9 @@ function applyPromotionToShippingMethods(promotion, shippingMethods, methodIdPro
55
55
  if (allocation === utils_1.ApplicationMethodAllocation.ACROSS) {
56
56
  const totalApplicableValue = shippingMethods.reduce((acc, method) => {
57
57
  const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0;
58
- return acc + (method.subtotal ?? 0) - appliedPromoValue;
59
- }, 0);
60
- if (totalApplicableValue <= 0) {
58
+ return utils_1.MathBN.add(acc, utils_1.MathBN.sub(method.subtotal ?? 0, appliedPromoValue));
59
+ }, utils_1.MathBN.convert(0));
60
+ if (utils_1.MathBN.lte(totalApplicableValue, 0)) {
61
61
  return computedActions;
62
62
  }
63
63
  for (const method of shippingMethods) {
@@ -67,15 +67,12 @@ function applyPromotionToShippingMethods(promotion, shippingMethods, methodIdPro
67
67
  const promotionValue = applicationMethod?.value ?? 0;
68
68
  const applicableTotal = method.subtotal;
69
69
  const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0;
70
- // TODO: should we worry about precision here?
71
- let applicablePromotionValue = (applicableTotal / totalApplicableValue) * promotionValue -
72
- appliedPromoValue;
70
+ let applicablePromotionValue = utils_1.MathBN.sub(utils_1.MathBN.mult(utils_1.MathBN.div(applicableTotal, totalApplicableValue), promotionValue), appliedPromoValue);
73
71
  if (applicationMethod?.type === utils_1.ApplicationMethodType.PERCENTAGE) {
74
- applicablePromotionValue =
75
- (promotionValue / 100) * (applicableTotal - appliedPromoValue);
72
+ applicablePromotionValue = utils_1.MathBN.sub(utils_1.MathBN.mult(utils_1.MathBN.div(promotionValue, 100), applicableTotal), appliedPromoValue);
76
73
  }
77
- const amount = Math.min(applicablePromotionValue, applicableTotal);
78
- if (amount <= 0) {
74
+ const amount = utils_1.MathBN.min(applicablePromotionValue, applicableTotal);
75
+ if (utils_1.MathBN.lte(amount, 0)) {
79
76
  continue;
80
77
  }
81
78
  const budgetExceededAction = (0, usage_1.computeActionForBudgetExceeded)(promotion, amount);
@@ -83,7 +80,7 @@ function applyPromotionToShippingMethods(promotion, shippingMethods, methodIdPro
83
80
  computedActions.push(budgetExceededAction);
84
81
  continue;
85
82
  }
86
- methodIdPromoValueMap.set(method.id, appliedPromoValue + amount);
83
+ methodIdPromoValueMap.set(method.id, utils_1.MathBN.add(appliedPromoValue, amount));
87
84
  computedActions.push({
88
85
  action: utils_1.ComputedActions.ADD_SHIPPING_METHOD_ADJUSTMENT,
89
86
  shipping_method_id: method.id,
@@ -1,4 +1,4 @@
1
- import { CampaignBudgetExceededAction, ComputeActions, PromotionDTO } from "@medusajs/types";
1
+ import { BigNumberInput, CampaignBudgetExceededAction, ComputeActions, PromotionDTO } from "@medusajs/types";
2
2
  export declare function canRegisterUsage(computedAction: ComputeActions): boolean;
3
- export declare function computeActionForBudgetExceeded(promotion: PromotionDTO, amount: number): CampaignBudgetExceededAction | void;
3
+ export declare function computeActionForBudgetExceeded(promotion: PromotionDTO, amount: BigNumberInput): CampaignBudgetExceededAction | void;
4
4
  //# sourceMappingURL=usage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,cAAc,EACd,YAAY,EACb,MAAM,iBAAiB,CAAA;AAGxB,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAOxE;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,MAAM,GACb,4BAA4B,GAAG,IAAI,CAmBrC"}
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,cAAc,EACd,YAAY,EACb,MAAM,iBAAiB,CAAA;AAGxB,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAOxE;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,cAAc,GACrB,4BAA4B,GAAG,IAAI,CAmBrC"}
@@ -16,9 +16,9 @@ function computeActionForBudgetExceeded(promotion, amount) {
16
16
  }
17
17
  const campaignBudgetUsed = campaignBudget.used ?? 0;
18
18
  const totalUsed = campaignBudget.type === utils_1.CampaignBudgetType.SPEND
19
- ? campaignBudgetUsed + amount
20
- : campaignBudgetUsed + 1;
21
- if (campaignBudget.limit && totalUsed > campaignBudget.limit) {
19
+ ? utils_1.MathBN.add(campaignBudgetUsed, amount)
20
+ : utils_1.MathBN.add(campaignBudgetUsed, 1);
21
+ if (campaignBudget.limit && utils_1.MathBN.gt(totalUsed, campaignBudget.limit)) {
22
22
  return {
23
23
  action: utils_1.ComputedActions.CAMPAIGN_BUDGET_EXCEEDED,
24
24
  code: promotion.code,
@@ -1 +1 @@
1
- {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../../src/utils/validations/application-method.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAA;AAE/E,eAAO,MAAM,4BAA4B,EAAE,MAAM,EAGhD,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAG1C,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,MAAM,EAEhD,CAAA;AAED,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,0BAA0B,GAAG,0BAA0B,EAC7D,SAAS,EAAE,SAAS,QA4GrB"}
1
+ {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../../src/utils/validations/application-method.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAA;AAE/E,eAAO,MAAM,4BAA4B,EAAE,MAAM,EAGhD,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAG1C,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,MAAM,EAEhD,CAAA;AAED,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,0BAA0B,GAAG,0BAA0B,EAC7D,SAAS,EAAE,SAAS,QA4GrB"}
@@ -20,12 +20,12 @@ function validateApplicationMethodAttributes(data, promotion) {
20
20
  const targetType = data.target_type || applicationMethod?.target_type;
21
21
  const type = data.type || applicationMethod?.type;
22
22
  const applicationMethodType = data.type || applicationMethod?.type;
23
- const value = data.value || applicationMethod.value;
23
+ const value = new utils_1.BigNumber(data.value ?? applicationMethod.value ?? 0);
24
24
  const maxQuantity = data.max_quantity || applicationMethod.max_quantity;
25
25
  const allocation = data.allocation || applicationMethod.allocation;
26
26
  const allTargetTypes = Object.values(utils_1.ApplicationMethodTargetType);
27
27
  if (type === utils_1.ApplicationMethodType.PERCENTAGE &&
28
- (typeof value !== "number" || value <= 0 || value > 100)) {
28
+ (utils_1.MathBN.lte(value, 0) || utils_1.MathBN.gt(value, 100))) {
29
29
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Application Method value should be a percentage number between 0 and 100`);
30
30
  }
31
31
  if (promotion?.type === utils_1.PromotionType.BUYGET) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/promotion",
3
- "version": "0.0.5-snapshot-20240530075042",
3
+ "version": "0.0.5-snapshot-20240531083729",
4
4
  "description": "Medusa Promotion module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,11 +37,11 @@
37
37
  "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
38
38
  },
39
39
  "devDependencies": {
40
- "@medusajs/types": "1.12.0-snapshot-20240530075042",
40
+ "@medusajs/types": "1.12.0-snapshot-20240531083729",
41
41
  "@mikro-orm/cli": "5.9.7",
42
42
  "cross-env": "^5.2.1",
43
43
  "jest": "^29.6.3",
44
- "medusa-test-utils": "1.1.45-snapshot-20240530075042",
44
+ "medusa-test-utils": "1.1.45-snapshot-20240531083729",
45
45
  "rimraf": "^3.0.2",
46
46
  "ts-jest": "^29.1.1",
47
47
  "ts-node": "^10.9.1",
@@ -49,8 +49,8 @@
49
49
  "typescript": "^5.1.6"
50
50
  },
51
51
  "dependencies": {
52
- "@medusajs/modules-sdk": "1.13.0-snapshot-20240530075042",
53
- "@medusajs/utils": "1.12.0-snapshot-20240530075042",
52
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240531083729",
53
+ "@medusajs/utils": "1.12.0-snapshot-20240531083729",
54
54
  "@mikro-orm/core": "5.9.7",
55
55
  "@mikro-orm/migrations": "5.9.7",
56
56
  "@mikro-orm/postgresql": "5.9.7",