@adtrackify/at-service-common 3.18.17 → 3.18.19

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 (77) hide show
  1. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js +10 -0
  2. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  3. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.d.ts +1 -0
  4. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js +3320 -0
  5. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -0
  6. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.d.ts +1 -0
  7. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js +115 -0
  8. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js.map +1 -0
  9. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.d.ts +1 -0
  10. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js +469 -0
  11. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js.map +1 -0
  12. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts +1 -0
  13. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js +35 -0
  14. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +1 -0
  15. package/dist/cjs/clients/generic/sqs-bundled-client.d.ts +1 -1
  16. package/dist/cjs/clients/generic/sqs-bundled-client.js +4 -4
  17. package/dist/cjs/clients/generic/sqs-bundled-client.js.map +1 -1
  18. package/dist/cjs/services/cost/cost-calculation-types.d.ts +69 -0
  19. package/dist/cjs/services/cost/cost-calculation-types.js +20 -0
  20. package/dist/cjs/services/cost/cost-calculation-types.js.map +1 -0
  21. package/dist/cjs/services/cost/cost-calculator-service.d.ts +24 -0
  22. package/dist/cjs/services/cost/cost-calculator-service.js +457 -0
  23. package/dist/cjs/services/cost/cost-calculator-service.js.map +1 -0
  24. package/dist/cjs/services/cost/cost-currency-service.d.ts +6 -0
  25. package/dist/cjs/services/cost/cost-currency-service.js +88 -0
  26. package/dist/cjs/services/cost/cost-currency-service.js.map +1 -0
  27. package/dist/cjs/services/cost/cost-filter-service.d.ts +10 -0
  28. package/dist/cjs/services/cost/cost-filter-service.js +122 -0
  29. package/dist/cjs/services/cost/cost-filter-service.js.map +1 -0
  30. package/dist/cjs/services/cost/index.d.ts +4 -0
  31. package/dist/cjs/services/cost/index.js +21 -0
  32. package/dist/cjs/services/cost/index.js.map +1 -0
  33. package/dist/cjs/services/currency-exchange-rate-lookup-service.d.ts +2 -1
  34. package/dist/cjs/services/currency-exchange-rate-lookup-service.js +28 -0
  35. package/dist/cjs/services/currency-exchange-rate-lookup-service.js.map +1 -1
  36. package/dist/cjs/services/index.d.ts +1 -0
  37. package/dist/cjs/services/index.js +1 -0
  38. package/dist/cjs/services/index.js.map +1 -1
  39. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js +10 -0
  40. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  41. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.d.ts +1 -0
  42. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js +3318 -0
  43. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -0
  44. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.d.ts +1 -0
  45. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js +113 -0
  46. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js.map +1 -0
  47. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.d.ts +1 -0
  48. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js +467 -0
  49. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js.map +1 -0
  50. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts +1 -0
  51. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js +33 -0
  52. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +1 -0
  53. package/dist/esm/clients/generic/sqs-bundled-client.d.ts +1 -1
  54. package/dist/esm/clients/generic/sqs-bundled-client.js +4 -4
  55. package/dist/esm/clients/generic/sqs-bundled-client.js.map +1 -1
  56. package/dist/esm/services/cost/cost-calculation-types.d.ts +69 -0
  57. package/dist/esm/services/cost/cost-calculation-types.js +16 -0
  58. package/dist/esm/services/cost/cost-calculation-types.js.map +1 -0
  59. package/dist/esm/services/cost/cost-calculator-service.d.ts +24 -0
  60. package/dist/esm/services/cost/cost-calculator-service.js +451 -0
  61. package/dist/esm/services/cost/cost-calculator-service.js.map +1 -0
  62. package/dist/esm/services/cost/cost-currency-service.d.ts +6 -0
  63. package/dist/esm/services/cost/cost-currency-service.js +85 -0
  64. package/dist/esm/services/cost/cost-currency-service.js.map +1 -0
  65. package/dist/esm/services/cost/cost-filter-service.d.ts +10 -0
  66. package/dist/esm/services/cost/cost-filter-service.js +119 -0
  67. package/dist/esm/services/cost/cost-filter-service.js.map +1 -0
  68. package/dist/esm/services/cost/index.d.ts +4 -0
  69. package/dist/esm/services/cost/index.js +5 -0
  70. package/dist/esm/services/cost/index.js.map +1 -0
  71. package/dist/esm/services/currency-exchange-rate-lookup-service.d.ts +2 -1
  72. package/dist/esm/services/currency-exchange-rate-lookup-service.js +28 -0
  73. package/dist/esm/services/currency-exchange-rate-lookup-service.js.map +1 -1
  74. package/dist/esm/services/index.d.ts +1 -0
  75. package/dist/esm/services/index.js +1 -0
  76. package/dist/esm/services/index.js.map +1 -1
  77. package/package.json +1 -1
@@ -13,7 +13,7 @@ class BundledSQSClient {
13
13
  this.sqsClient = sqsClient;
14
14
  this.config = { ...sqs_bundled_client_types_js_1.DEFAULT_BUNDLE_CONFIG, ...config };
15
15
  }
16
- async sendBundled(messageType, items) {
16
+ async sendBundled(messageType, items, delaySeconds = 0) {
17
17
  if (items.length === 0) {
18
18
  return this.emptyResult();
19
19
  }
@@ -72,7 +72,7 @@ class BundledSQSClient {
72
72
  envelopes.push(envelope);
73
73
  }
74
74
  }
75
- const result = await this.sendBatched(messageType, envelopes);
75
+ const result = await this.sendBatched(messageType, envelopes, delaySeconds);
76
76
  const durationMs = Date.now() - startTime;
77
77
  const initialBundleCount = bundles.length;
78
78
  const messageCount = envelopes.length;
@@ -231,13 +231,13 @@ class BundledSQSClient {
231
231
  skippedItems: firstResult.skippedItems + secondResult.skippedItems,
232
232
  };
233
233
  }
234
- async sendBatched(messageType, envelopes, maxRetries = 2) {
234
+ async sendBatched(messageType, envelopes, delaySeconds = 0, maxRetries = 2) {
235
235
  let toSend = envelopes;
236
236
  let totalApiCalls = 0;
237
237
  let totalSuccessCount = 0;
238
238
  let retriesRemaining = maxRetries;
239
239
  while (toSend.length > 0 && retriesRemaining >= 0) {
240
- const result = await this.sqsClient.buildAndSendMessagesV2(messageType, toSend);
240
+ const result = await this.sqsClient.buildAndSendMessagesV2(messageType, toSend, delaySeconds);
241
241
  totalApiCalls += result.batchCount;
242
242
  totalSuccessCount += result.successCount;
243
243
  if (result.failedCount === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"sqs-bundled-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-bundled-client.ts"],"names":[],"mappings":";;;AACA,uEAAyD;AACzD,+DAA8D;AAC9D,iDAAoE;AACpE,mDAAoD;AACpD,+EASuC;AAEvC,MAAa,gBAAgB;IACnB,SAAS,CAAY;IACrB,MAAM,CAAe;IAE7B,YAAY,SAAoB,EAAE,SAAgC,EAAE;QAClE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,mDAAqB,EAAE,GAAG,MAAM,EAAE,CAAC;IACxD,CAAC;IAeD,KAAK,CAAC,WAAW,CAAC,WAAmB,EAAE,KAAU;QAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SA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YACd,YAAY,EAAE,CAAC;YACf,YAAY,EAAE,CAAC;YACf,gBAAgB,EAAE,CAAC;YACnB,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;YACf,OAAO,EAAE;gBACP,iBAAiB,EAAE,CAAC;gBACpB,cAAc,EAAE,CAAC;gBACjB,gBAAgB,EAAE,CAAC;gBACnB,iBAAiB,EAAE,CAAC;gBACpB,iBAAiB,EAAE,CAAC;gBACpB,cAAc,EAAE,KAAK;aACtB;SACF,CAAC;IACJ,CAAC;CACF;AA7ZD,4CA6ZC"}
1
+ {"version":3,"file":"sqs-bundled-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-bundled-client.ts"],"names":[],"mappings":";;;AACA,uEAAyD;AACzD,+DAA8D;AAC9D,iDAAoE;AACpE,mDAAoD;AACpD,+EASuC;AAEvC,MAAa,gBAAgB;IACnB,SAAS,CAAY;IACrB,MAAM,CAAe;IAE7B,YAAY,SAAoB,EAAE,SAAgC,EAAE;QAClE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,mDAAqB,EAAE,GAAG,MAAM,EAAE,CAAC;IACxD,CAAC;IAgBD,KAAK,CAAC,WAAW,CAAC,WAAmB,EAAE,KAAU,EAAE,YAAY,GAAG,CAAC;QACjE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3B;QAED,IAAI;YACF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,IAAI,cAAc,GAAG,KAAK,CAAC;YAC3B,IAAI,YAAY,GAAG,CAAC,CAAC;YAGrB,MAAM,OAAO,GAAG,IAAA,0BAAgB,EAC9B,KAAK,EACL,IAAI,CAAC,MAAM,CAAC,8BAA8B,EAC1C,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC9B,CAAC;YAGF,MAAM,SAAS,GAAgC,EAAE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C;gBACpB,cAAc,EAAE,KAAK;aACtB;SACF,CAAC;IACJ,CAAC;CACF;AA/ZD,4CA+ZC"}
@@ -0,0 +1,69 @@
1
+ import { type GlobalProductOverrideConfig, type OrderCostConfig, type GatewayCostConfig, type ShippingCostConfig, COST_CATEGORY } from '@adtrackify/at-tracking-event-types';
2
+ export interface CostConfigsBundle {
3
+ globalProductOverride: GlobalProductOverrideConfig | null;
4
+ order: OrderCostConfig | null;
5
+ gateway: GatewayCostConfig | null;
6
+ shipping: ShippingCostConfig | null;
7
+ }
8
+ export type CostConfigsByPixelId = Record<string, CostConfigsBundle>;
9
+ export interface OrderFilterContext {
10
+ tags: string[];
11
+ sourceName?: string;
12
+ paymentGateways: string[];
13
+ shippingTitles: string[];
14
+ shipCountryCode?: string;
15
+ }
16
+ export interface LineItemFilterContext {
17
+ vendor?: string;
18
+ productType?: string;
19
+ tags: string[];
20
+ category?: string;
21
+ productId: string;
22
+ variantId: string;
23
+ }
24
+ export interface LineItemCostContext {
25
+ lineItemId: string;
26
+ quantity: number;
27
+ refundedQuantity: number;
28
+ filterContext: LineItemFilterContext;
29
+ variantHandlingFee?: number;
30
+ }
31
+ export interface OrderCostContext {
32
+ orderCreatedAt: string;
33
+ totalPrice: number;
34
+ grossSalePrice: number;
35
+ netSalePrice: number;
36
+ totalProductCost: number;
37
+ totalShipping: number;
38
+ totalWeight: number;
39
+ totalQuantity: number;
40
+ hasRefund: boolean;
41
+ orderFilterContext: OrderFilterContext;
42
+ lineItems: LineItemCostContext[];
43
+ }
44
+ export interface LineItemCalculatedCosts {
45
+ totalLineItemHandlingCost: number;
46
+ totalLineItemOtherCost: number;
47
+ }
48
+ export interface OrderCostResult {
49
+ orderLevelHandlingCost: number;
50
+ lineItemLevelHandlingCost: number;
51
+ totalHandlingCost: number;
52
+ orderLevelOtherCost: number;
53
+ lineItemLevelOtherCost: number;
54
+ totalOtherCost: number;
55
+ totalGatewayCost: number;
56
+ totalShippingCost: number;
57
+ lineItemCosts: Record<string, LineItemCalculatedCosts>;
58
+ categoryCosts: CategoryCostResult;
59
+ }
60
+ export interface CategoryCostResult {
61
+ totalOtherCogs: number;
62
+ otherFulfillmentCost: number;
63
+ otherTransactionCost: number;
64
+ marketingCost: number;
65
+ agencyFeesCost: number;
66
+ opexCost: number;
67
+ totalOtherCost: number;
68
+ }
69
+ export declare function normalizeCategory(category: string | undefined): COST_CATEGORY;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeCategory = void 0;
4
+ const at_tracking_event_types_1 = require("@adtrackify/at-tracking-event-types");
5
+ function normalizeCategory(category) {
6
+ if (!category || typeof category !== 'string')
7
+ return at_tracking_event_types_1.COST_CATEGORY.OTHER;
8
+ const normalized = category.toLowerCase();
9
+ switch (normalized) {
10
+ case 'payment_fees':
11
+ return at_tracking_event_types_1.COST_CATEGORY.TRANSACTION;
12
+ case 'packaging':
13
+ return at_tracking_event_types_1.COST_CATEGORY.FULFILLMENT;
14
+ }
15
+ const enumValues = Object.values(at_tracking_event_types_1.COST_CATEGORY);
16
+ const matched = enumValues.find((v) => v.toLowerCase() === normalized);
17
+ return matched ?? at_tracking_event_types_1.COST_CATEGORY.OTHER;
18
+ }
19
+ exports.normalizeCategory = normalizeCategory;
20
+ //# sourceMappingURL=cost-calculation-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost-calculation-types.js","sourceRoot":"","sources":["../../../../src/services/cost/cost-calculation-types.ts"],"names":[],"mappings":";;;AAAA,iFAM6C;AAoH7C,SAAgB,iBAAiB,CAAC,QAA4B;IAC5D,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,uCAAa,CAAC,KAAK,CAAC;IAE1E,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAG1C,QAAQ,UAAU,EAAE;QAClB,KAAK,cAAc;YACjB,OAAO,uCAAa,CAAC,WAAW,CAAC;QACnC,KAAK,WAAW;YACd,OAAO,uCAAa,CAAC,WAAW,CAAC;KACpC;IAGD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,uCAAa,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,CAAC;IACvE,OAAO,OAAO,IAAI,uCAAa,CAAC,KAAK,CAAC;AACxC,CAAC;AAjBD,8CAiBC"}
@@ -0,0 +1,24 @@
1
+ import { WEIGHT_UNIT, type OrderCostEntry, type ShippingProfile, type WeightInterval, type QuantityInterval } from '@adtrackify/at-tracking-event-types';
2
+ import { type CostConfigsBundle, type OrderCostContext, type OrderCostResult, type LineItemCalculatedCosts, type LineItemCostContext, type OrderFilterContext, type CategoryCostResult } from './cost-calculation-types.js';
3
+ import { type ExchangeRatesMap } from './cost-currency-service.js';
4
+ export declare const CostCalculatorService: {
5
+ isDateInRange: (orderDate: string, effectiveFrom?: string, effectiveTo?: string) => boolean;
6
+ findMatchingWeightTierAmount: (tiers: WeightInterval[] | undefined, weightGrams: number, weightUnit: WEIGHT_UNIT | undefined) => number;
7
+ findQuantityTierAmount: (tiers: QuantityInterval[] | undefined, quantity: number) => number;
8
+ calculateHandlingCost: (configs: CostConfigsBundle, lineItems: LineItemCostContext[], lineItemCosts: Record<string, LineItemCalculatedCosts>, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap) => number;
9
+ calculateGatewayCost: (configs: CostConfigsBundle, orderGateways: string[], totalPrice: number, orderCreatedAt: string, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap) => number;
10
+ findMatchingShippingProfile: (profiles: ShippingProfile[] | undefined, shipCountryCode: string | undefined, orderCreatedAt: string, orderFilterContext?: OrderFilterContext) => ShippingProfile | null;
11
+ calculateShippingCost: (configs: CostConfigsBundle, shopifyShippingAmount: number, shipCountryCode: string | undefined, totalWeightGrams: number, orderCreatedAt: string, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap, orderFilterContext?: OrderFilterContext) => number;
12
+ calculateOtherCostEntry: (entry: OrderCostEntry, context: OrderCostContext, lineItemCosts: Record<string, LineItemCalculatedCosts>, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap) => {
13
+ orderLevel: number;
14
+ lineItemLevel: number;
15
+ };
16
+ calculateOtherCost: (configs: CostConfigsBundle, context: OrderCostContext, lineItemCosts: Record<string, LineItemCalculatedCosts>, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap) => {
17
+ orderLevel: number;
18
+ lineItemLevel: number;
19
+ total: number;
20
+ categoryCosts: CategoryCostResult;
21
+ };
22
+ calculateLineItemHandlingCosts: (lineItems: LineItemCostContext[]) => Record<string, number>;
23
+ calculateOrderCosts: (configs: CostConfigsBundle | null, context: OrderCostContext, orderCurrency: string, exchangeRatesMap: ExchangeRatesMap) => OrderCostResult;
24
+ };
@@ -0,0 +1,457 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CostCalculatorService = void 0;
7
+ const big_js_1 = __importDefault(require("big.js"));
8
+ const luxon_1 = require("luxon");
9
+ const logging_helper_js_1 = require("../../helpers/logging-helper.js");
10
+ const at_tracking_event_types_1 = require("@adtrackify/at-tracking-event-types");
11
+ const cost_calculation_types_js_1 = require("./cost-calculation-types.js");
12
+ const at_tracking_event_types_2 = require("@adtrackify/at-tracking-event-types");
13
+ const cost_filter_service_js_1 = require("./cost-filter-service.js");
14
+ const cost_currency_service_js_1 = require("./cost-currency-service.js");
15
+ const WEIGHT_CONVERSION = {
16
+ [at_tracking_event_types_1.WEIGHT_UNIT.GRAMS]: 1,
17
+ [at_tracking_event_types_1.WEIGHT_UNIT.KILOGRAMS]: 1000,
18
+ [at_tracking_event_types_1.WEIGHT_UNIT.OUNCES]: 28.3495,
19
+ [at_tracking_event_types_1.WEIGHT_UNIT.POUNDS]: 453.592,
20
+ };
21
+ exports.CostCalculatorService = {
22
+ isDateInRange: (orderDate, effectiveFrom, effectiveTo) => {
23
+ try {
24
+ const orderDt = luxon_1.DateTime.fromISO(orderDate);
25
+ if (!orderDt.isValid)
26
+ return true;
27
+ if (effectiveFrom) {
28
+ const fromDt = luxon_1.DateTime.fromISO(effectiveFrom);
29
+ if (fromDt.isValid && orderDt < fromDt)
30
+ return false;
31
+ }
32
+ if (effectiveTo) {
33
+ const toDt = luxon_1.DateTime.fromISO(effectiveTo);
34
+ if (toDt.isValid && orderDt > toDt)
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ catch (error) {
40
+ logging_helper_js_1.Logger.error('CostCalculatorService.isDateInRange: failed', { error, orderDate, effectiveFrom, effectiveTo });
41
+ return true;
42
+ }
43
+ },
44
+ findMatchingWeightTierAmount: (tiers, weightGrams, weightUnit) => {
45
+ try {
46
+ if (!tiers?.length)
47
+ return 0;
48
+ const targetWeight = weightUnit ? weightGrams / (WEIGHT_CONVERSION[weightUnit] ?? 1) : weightGrams;
49
+ for (const tier of tiers) {
50
+ const isAboveMin = targetWeight >= tier.weightMin;
51
+ const isBelowMax = tier.weightMax === null || targetWeight <= tier.weightMax;
52
+ if (isAboveMin && isBelowMax) {
53
+ return tier.flatAmount ?? 0;
54
+ }
55
+ }
56
+ return 0;
57
+ }
58
+ catch (error) {
59
+ logging_helper_js_1.Logger.error('CostCalculatorService.findMatchingWeightTierAmount: failed', { error, weightGrams, weightUnit, tierCount: tiers?.length });
60
+ return 0;
61
+ }
62
+ },
63
+ findQuantityTierAmount: (tiers, quantity) => {
64
+ try {
65
+ if (!tiers?.length)
66
+ return 0;
67
+ for (const tier of tiers) {
68
+ const isAboveMin = quantity >= tier.quantityMin;
69
+ const isBelowMax = tier.quantityMax === null || quantity <= tier.quantityMax;
70
+ if (isAboveMin && isBelowMax) {
71
+ return tier.flatAmount ?? 0;
72
+ }
73
+ }
74
+ return 0;
75
+ }
76
+ catch (error) {
77
+ logging_helper_js_1.Logger.error('CostCalculatorService.findQuantityTierAmount: failed', { error, quantity, tierCount: tiers?.length });
78
+ return 0;
79
+ }
80
+ },
81
+ calculateHandlingCost: (configs, lineItems, lineItemCosts, orderCurrency, exchangeRatesMap) => {
82
+ try {
83
+ const fee = configs.globalProductOverride?.globalHandlingFee ?? 0;
84
+ if (!fee)
85
+ return 0;
86
+ const configCurrency = configs.globalProductOverride?.currency;
87
+ const convertedFee = configCurrency
88
+ ? cost_currency_service_js_1.CostCurrencyService.convertAmount(fee, configCurrency, orderCurrency, exchangeRatesMap)
89
+ : fee;
90
+ let total = new big_js_1.default(0);
91
+ for (const li of lineItems) {
92
+ total = total.plus(convertedFee);
93
+ if (lineItemCosts[li.lineItemId]) {
94
+ lineItemCosts[li.lineItemId].totalLineItemHandlingCost = new big_js_1.default(lineItemCosts[li.lineItemId].totalLineItemHandlingCost)
95
+ .plus(convertedFee)
96
+ .toNumber();
97
+ }
98
+ }
99
+ return total.toNumber();
100
+ }
101
+ catch (error) {
102
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateHandlingCost: failed', { error, configs, orderCurrency, lineItemCount: lineItems.length });
103
+ return 0;
104
+ }
105
+ },
106
+ calculateGatewayCost: (configs, orderGateways, totalPrice, orderCreatedAt, orderCurrency, exchangeRatesMap) => {
107
+ try {
108
+ const gatewayConfig = configs.gateway;
109
+ if (!gatewayConfig?.entries?.length)
110
+ return 0;
111
+ const normalizedOrderGateways = orderGateways.map((g) => g.toLowerCase());
112
+ const matchingEntry = gatewayConfig.entries.find((entry) => {
113
+ const gatewayMatches = normalizedOrderGateways.includes(entry.gatewayName.toLowerCase());
114
+ const dateValid = exports.CostCalculatorService.isDateInRange(orderCreatedAt, entry.effectiveFrom, entry.effectiveTo);
115
+ return gatewayMatches && dateValid;
116
+ });
117
+ if (!matchingEntry)
118
+ return 0;
119
+ const rawFlatAmount = matchingEntry.flatAmount ?? 0;
120
+ const convertedFlatAmount = cost_currency_service_js_1.CostCurrencyService.convertAmount(rawFlatAmount, matchingEntry.currency, orderCurrency, exchangeRatesMap);
121
+ const flatAmount = new big_js_1.default(convertedFlatAmount);
122
+ const percentAmount = new big_js_1.default(totalPrice).times(matchingEntry.percentRate ?? 0).div(100);
123
+ return flatAmount.plus(percentAmount).toNumber();
124
+ }
125
+ catch (error) {
126
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateGatewayCost: failed', { error, configs, orderCurrency, orderGateways, totalPrice, orderCreatedAt });
127
+ return 0;
128
+ }
129
+ },
130
+ findMatchingShippingProfile: (profiles, shipCountryCode, orderCreatedAt, orderFilterContext) => {
131
+ try {
132
+ if (!profiles?.length)
133
+ return null;
134
+ let defaultProfile = null;
135
+ for (const profile of profiles) {
136
+ if (!exports.CostCalculatorService.isDateInRange(orderCreatedAt, profile.effectiveFrom, profile.effectiveTo)) {
137
+ continue;
138
+ }
139
+ if (profile.filters && orderFilterContext && !cost_filter_service_js_1.CostFilterService.matchesFilters(profile.filters, orderFilterContext, null)) {
140
+ continue;
141
+ }
142
+ if (profile.isDefault) {
143
+ defaultProfile = profile;
144
+ }
145
+ if (shipCountryCode && profile.countries?.length) {
146
+ const normalizedCountry = shipCountryCode.toLowerCase();
147
+ const countryMatches = profile.countries.some((c) => c.toLowerCase() === normalizedCountry);
148
+ if (countryMatches) {
149
+ return profile;
150
+ }
151
+ }
152
+ }
153
+ return defaultProfile;
154
+ }
155
+ catch (error) {
156
+ logging_helper_js_1.Logger.error('CostCalculatorService.findMatchingShippingProfile: failed', { error, shipCountryCode });
157
+ return null;
158
+ }
159
+ },
160
+ calculateShippingCost: (configs, shopifyShippingAmount, shipCountryCode, totalWeightGrams, orderCreatedAt, orderCurrency, exchangeRatesMap, orderFilterContext) => {
161
+ try {
162
+ const shippingConfig = configs.shipping;
163
+ if (!shippingConfig)
164
+ return 0;
165
+ switch (shippingConfig.method) {
166
+ case at_tracking_event_types_1.SHIPPING_METHOD.SHOPIFY_CHARGES:
167
+ return shopifyShippingAmount;
168
+ case at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE: {
169
+ const fixedAmount = shippingConfig.fixedRateAmount ?? 0;
170
+ return cost_currency_service_js_1.CostCurrencyService.convertAmount(fixedAmount, shippingConfig.currency, orderCurrency, exchangeRatesMap);
171
+ }
172
+ case at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES: {
173
+ const profile = exports.CostCalculatorService.findMatchingShippingProfile(shippingConfig.profiles, shipCountryCode, orderCreatedAt, orderFilterContext);
174
+ if (!profile)
175
+ return 0;
176
+ if (profile.rateType === at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT) {
177
+ const flatAmount = profile.flatAmount ?? 0;
178
+ return cost_currency_service_js_1.CostCurrencyService.convertAmount(flatAmount, profile.currency, orderCurrency, exchangeRatesMap);
179
+ }
180
+ if (profile.rateType === at_tracking_event_types_1.SHIPPING_RATE_TYPE.WEIGHT_TIERED) {
181
+ const tierAmount = exports.CostCalculatorService.findMatchingWeightTierAmount(profile.weightTiers, totalWeightGrams, profile.weightUnit);
182
+ return cost_currency_service_js_1.CostCurrencyService.convertAmount(tierAmount, profile.currency, orderCurrency, exchangeRatesMap);
183
+ }
184
+ return 0;
185
+ }
186
+ default:
187
+ return 0;
188
+ }
189
+ }
190
+ catch (error) {
191
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateShippingCost: failed', { error, configs, orderCurrency, shipCountryCode, totalWeightGrams });
192
+ return 0;
193
+ }
194
+ },
195
+ calculateOtherCostEntry: (entry, context, lineItemCosts, orderCurrency, exchangeRatesMap) => {
196
+ const defaultResult = { orderLevel: 0, lineItemLevel: 0 };
197
+ try {
198
+ let orderLevelCost = new big_js_1.default(0);
199
+ let lineItemLevelCost = new big_js_1.default(0);
200
+ const { orderFilterContext, lineItems, totalWeight, totalQuantity, hasRefund, totalProductCost, totalShipping, totalPrice, grossSalePrice, netSalePrice } = context;
201
+ if (!cost_filter_service_js_1.CostFilterService.matchesFilters(entry.filters, orderFilterContext, null, lineItems.map(li => li.filterContext))) {
202
+ return defaultResult;
203
+ }
204
+ const convertFlat = (amount) => cost_currency_service_js_1.CostCurrencyService.convertAmount(amount, entry.currency, orderCurrency, exchangeRatesMap);
205
+ switch (entry.type) {
206
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER:
207
+ orderLevelCost = new big_js_1.default(convertFlat(entry.flatAmount ?? 0));
208
+ break;
209
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM:
210
+ for (const li of lineItems) {
211
+ if (cost_filter_service_js_1.CostFilterService.matchesFilters(entry.filters, orderFilterContext, li.filterContext)) {
212
+ const amount = new big_js_1.default(convertFlat(entry.flatAmount ?? 0)).times(li.quantity);
213
+ lineItemLevelCost = lineItemLevelCost.plus(amount);
214
+ if (lineItemCosts[li.lineItemId]) {
215
+ lineItemCosts[li.lineItemId].totalLineItemOtherCost = new big_js_1.default(lineItemCosts[li.lineItemId].totalLineItemOtherCost)
216
+ .plus(amount)
217
+ .toNumber();
218
+ }
219
+ }
220
+ }
221
+ break;
222
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT: {
223
+ if (entry.weightIntervals?.length) {
224
+ const tierAmount = exports.CostCalculatorService.findMatchingWeightTierAmount(entry.weightIntervals, totalWeight, entry.weightUnit);
225
+ orderLevelCost = new big_js_1.default(convertFlat(tierAmount));
226
+ }
227
+ else {
228
+ const weightInUnit = entry.weightUnit
229
+ ? totalWeight / (WEIGHT_CONVERSION[entry.weightUnit] ?? 1)
230
+ : totalWeight;
231
+ orderLevelCost = new big_js_1.default(convertFlat(entry.flatAmount ?? 0)).times(weightInUnit);
232
+ }
233
+ break;
234
+ }
235
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY:
236
+ for (const li of lineItems) {
237
+ if (cost_filter_service_js_1.CostFilterService.matchesFilters(entry.filters, orderFilterContext, li.filterContext)) {
238
+ let amount;
239
+ if (entry.quantityIntervals?.length) {
240
+ const tierAmount = exports.CostCalculatorService.findQuantityTierAmount(entry.quantityIntervals, li.quantity);
241
+ amount = new big_js_1.default(convertFlat(tierAmount));
242
+ }
243
+ else {
244
+ amount = new big_js_1.default(convertFlat(entry.flatAmount ?? 0)).times(li.quantity);
245
+ }
246
+ lineItemLevelCost = lineItemLevelCost.plus(amount);
247
+ if (lineItemCosts[li.lineItemId]) {
248
+ lineItemCosts[li.lineItemId].totalLineItemOtherCost = new big_js_1.default(lineItemCosts[li.lineItemId].totalLineItemOtherCost)
249
+ .plus(amount)
250
+ .toNumber();
251
+ }
252
+ }
253
+ }
254
+ break;
255
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY:
256
+ if (entry.quantityIntervals?.length) {
257
+ const tierAmount = exports.CostCalculatorService.findQuantityTierAmount(entry.quantityIntervals, totalQuantity);
258
+ orderLevelCost = new big_js_1.default(convertFlat(tierAmount));
259
+ }
260
+ else {
261
+ orderLevelCost = new big_js_1.default(convertFlat(entry.flatAmount ?? 0)).times(totalQuantity);
262
+ }
263
+ break;
264
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER:
265
+ if (hasRefund) {
266
+ orderLevelCost = new big_js_1.default(convertFlat(entry.flatAmount ?? 0));
267
+ }
268
+ break;
269
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM:
270
+ for (const li of lineItems) {
271
+ if (li.refundedQuantity > 0 && cost_filter_service_js_1.CostFilterService.matchesFilters(entry.filters, orderFilterContext, li.filterContext)) {
272
+ const amount = new big_js_1.default(convertFlat(entry.flatAmount ?? 0)).times(li.refundedQuantity);
273
+ lineItemLevelCost = lineItemLevelCost.plus(amount);
274
+ if (lineItemCosts[li.lineItemId]) {
275
+ lineItemCosts[li.lineItemId].totalLineItemOtherCost = new big_js_1.default(lineItemCosts[li.lineItemId].totalLineItemOtherCost)
276
+ .plus(amount)
277
+ .toNumber();
278
+ }
279
+ }
280
+ }
281
+ break;
282
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS:
283
+ orderLevelCost = new big_js_1.default(totalProductCost).times(entry.percentRate ?? 0).div(100);
284
+ break;
285
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING:
286
+ orderLevelCost = new big_js_1.default(totalShipping).times(entry.percentRate ?? 0).div(100);
287
+ break;
288
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES:
289
+ orderLevelCost = new big_js_1.default(totalPrice).times(entry.percentRate ?? 0).div(100);
290
+ break;
291
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES:
292
+ orderLevelCost = new big_js_1.default(grossSalePrice).times(entry.percentRate ?? 0).div(100);
293
+ break;
294
+ case at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_NET_SALES:
295
+ orderLevelCost = new big_js_1.default(netSalePrice).times(entry.percentRate ?? 0).div(100);
296
+ break;
297
+ default:
298
+ break;
299
+ }
300
+ return { orderLevel: orderLevelCost.toNumber(), lineItemLevel: lineItemLevelCost.toNumber() };
301
+ }
302
+ catch (error) {
303
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateOtherCostEntry: failed', { error, entry, orderCurrency });
304
+ return defaultResult;
305
+ }
306
+ },
307
+ calculateOtherCost: (configs, context, lineItemCosts, orderCurrency, exchangeRatesMap) => {
308
+ const defaultCategoryCosts = {
309
+ totalOtherCogs: 0,
310
+ otherFulfillmentCost: 0,
311
+ otherTransactionCost: 0,
312
+ marketingCost: 0,
313
+ agencyFeesCost: 0,
314
+ opexCost: 0,
315
+ totalOtherCost: 0,
316
+ };
317
+ const defaultResult = { orderLevel: 0, lineItemLevel: 0, total: 0, categoryCosts: defaultCategoryCosts };
318
+ try {
319
+ const orderConfig = configs.order;
320
+ if (!orderConfig?.entries?.length)
321
+ return defaultResult;
322
+ let orderLevelTotal = new big_js_1.default(0);
323
+ let lineItemLevelTotal = new big_js_1.default(0);
324
+ const categoryCosts = { ...defaultCategoryCosts };
325
+ for (const entry of orderConfig.entries) {
326
+ if (!exports.CostCalculatorService.isDateInRange(context.orderCreatedAt, entry.effectiveFrom, entry.effectiveTo)) {
327
+ continue;
328
+ }
329
+ try {
330
+ const entryCost = exports.CostCalculatorService.calculateOtherCostEntry(entry, context, lineItemCosts, orderCurrency, exchangeRatesMap);
331
+ const entryTotal = entryCost.orderLevel + entryCost.lineItemLevel;
332
+ orderLevelTotal = orderLevelTotal.plus(entryCost.orderLevel);
333
+ lineItemLevelTotal = lineItemLevelTotal.plus(entryCost.lineItemLevel);
334
+ const category = (0, cost_calculation_types_js_1.normalizeCategory)(entry.category);
335
+ switch (category) {
336
+ case at_tracking_event_types_2.COST_CATEGORY.COGS:
337
+ categoryCosts.totalOtherCogs += entryTotal;
338
+ break;
339
+ case at_tracking_event_types_2.COST_CATEGORY.FULFILLMENT:
340
+ categoryCosts.otherFulfillmentCost += entryTotal;
341
+ break;
342
+ case at_tracking_event_types_2.COST_CATEGORY.TRANSACTION:
343
+ categoryCosts.otherTransactionCost += entryTotal;
344
+ break;
345
+ case at_tracking_event_types_2.COST_CATEGORY.MARKETING:
346
+ categoryCosts.marketingCost += entryTotal;
347
+ break;
348
+ case at_tracking_event_types_2.COST_CATEGORY.AGENCY_FEES:
349
+ categoryCosts.agencyFeesCost += entryTotal;
350
+ break;
351
+ case at_tracking_event_types_2.COST_CATEGORY.OPEX:
352
+ categoryCosts.opexCost += entryTotal;
353
+ break;
354
+ case at_tracking_event_types_2.COST_CATEGORY.OTHER:
355
+ default:
356
+ categoryCosts.totalOtherCost += entryTotal;
357
+ break;
358
+ }
359
+ }
360
+ catch (entryError) {
361
+ logging_helper_js_1.Logger.warn('CostCalculatorService.calculateOtherCost: entry failed', {
362
+ error: entryError,
363
+ entryId: entry.id,
364
+ category: entry.category,
365
+ });
366
+ }
367
+ }
368
+ return {
369
+ orderLevel: orderLevelTotal.toNumber(),
370
+ lineItemLevel: lineItemLevelTotal.toNumber(),
371
+ total: orderLevelTotal.plus(lineItemLevelTotal).toNumber(),
372
+ categoryCosts,
373
+ };
374
+ }
375
+ catch (error) {
376
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateOtherCost: failed', { error, configs, orderCurrency });
377
+ return defaultResult;
378
+ }
379
+ },
380
+ calculateLineItemHandlingCosts: (lineItems) => {
381
+ try {
382
+ const result = {};
383
+ for (const li of lineItems) {
384
+ const handlingFee = li.variantHandlingFee ?? 0;
385
+ result[li.lineItemId] = new big_js_1.default(handlingFee).times(li.quantity).toNumber();
386
+ }
387
+ return result;
388
+ }
389
+ catch (error) {
390
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateLineItemHandlingCosts: failed', { error, lineItemCount: lineItems.length });
391
+ return {};
392
+ }
393
+ },
394
+ calculateOrderCosts: (configs, context, orderCurrency, exchangeRatesMap) => {
395
+ const defaultCategoryCosts = {
396
+ totalOtherCogs: 0,
397
+ otherFulfillmentCost: 0,
398
+ otherTransactionCost: 0,
399
+ marketingCost: 0,
400
+ agencyFeesCost: 0,
401
+ opexCost: 0,
402
+ totalOtherCost: 0,
403
+ };
404
+ const defaultResult = {
405
+ orderLevelHandlingCost: 0,
406
+ lineItemLevelHandlingCost: 0,
407
+ totalHandlingCost: 0,
408
+ orderLevelOtherCost: 0,
409
+ lineItemLevelOtherCost: 0,
410
+ totalOtherCost: 0,
411
+ totalGatewayCost: 0,
412
+ totalShippingCost: 0,
413
+ lineItemCosts: {},
414
+ categoryCosts: defaultCategoryCosts,
415
+ };
416
+ if (!configs) {
417
+ return defaultResult;
418
+ }
419
+ try {
420
+ const lineItemCosts = {};
421
+ for (const li of context.lineItems) {
422
+ lineItemCosts[li.lineItemId] = { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 };
423
+ }
424
+ const lineItemHandlingCosts = exports.CostCalculatorService.calculateLineItemHandlingCosts(context.lineItems);
425
+ for (const [lineItemId, handlingCost] of Object.entries(lineItemHandlingCosts)) {
426
+ if (lineItemCosts[lineItemId]) {
427
+ lineItemCosts[lineItemId].totalLineItemHandlingCost = handlingCost;
428
+ }
429
+ }
430
+ exports.CostCalculatorService.calculateHandlingCost(configs, context.lineItems, lineItemCosts, orderCurrency, exchangeRatesMap);
431
+ const lineItemLevelHandlingCost = Object.values(lineItemCosts).reduce((sum, li) => new big_js_1.default(sum).plus(li.totalLineItemHandlingCost).toNumber(), 0);
432
+ const orderLevelHandlingCost = 0;
433
+ const totalHandlingCost = orderLevelHandlingCost + lineItemLevelHandlingCost;
434
+ const totalGatewayCost = exports.CostCalculatorService.calculateGatewayCost(configs, context.orderFilterContext.paymentGateways, context.totalPrice, context.orderCreatedAt, orderCurrency, exchangeRatesMap);
435
+ const shopifyShippingAmount = context.totalShipping;
436
+ const totalShippingCost = exports.CostCalculatorService.calculateShippingCost(configs, shopifyShippingAmount, context.orderFilterContext.shipCountryCode, context.totalWeight, context.orderCreatedAt, orderCurrency, exchangeRatesMap, context.orderFilterContext);
437
+ const otherCostResult = exports.CostCalculatorService.calculateOtherCost(configs, context, lineItemCosts, orderCurrency, exchangeRatesMap);
438
+ return {
439
+ orderLevelHandlingCost,
440
+ lineItemLevelHandlingCost,
441
+ totalHandlingCost,
442
+ orderLevelOtherCost: otherCostResult.orderLevel,
443
+ lineItemLevelOtherCost: otherCostResult.lineItemLevel,
444
+ totalOtherCost: otherCostResult.categoryCosts.totalOtherCost,
445
+ totalGatewayCost,
446
+ totalShippingCost,
447
+ lineItemCosts,
448
+ categoryCosts: otherCostResult.categoryCosts,
449
+ };
450
+ }
451
+ catch (error) {
452
+ logging_helper_js_1.Logger.error('CostCalculatorService.calculateOrderCosts: failed', { error, configs, orderCurrency });
453
+ return defaultResult;
454
+ }
455
+ },
456
+ };
457
+ //# sourceMappingURL=cost-calculator-service.js.map