@adtrackify/at-service-common 5.1.2 → 5.1.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 (621) hide show
  1. package/dist/cjs/__tests__/clients/acuity-client.spec.js +20 -21
  2. package/dist/cjs/__tests__/clients/acuity-client.spec.js.map +1 -1
  3. package/dist/cjs/__tests__/clients/cross-platform-compression.spec.js +86 -97
  4. package/dist/cjs/__tests__/clients/cross-platform-compression.spec.js.map +1 -1
  5. package/dist/cjs/__tests__/clients/dynamodb-client.spec.js +95 -94
  6. package/dist/cjs/__tests__/clients/dynamodb-client.spec.js.map +1 -1
  7. package/dist/cjs/__tests__/clients/event-collector-client.spec.js +58 -58
  8. package/dist/cjs/__tests__/clients/event-collector-client.spec.js.map +1 -1
  9. package/dist/cjs/__tests__/clients/liveintent-client.spec.js +37 -0
  10. package/dist/cjs/__tests__/clients/liveintent-client.spec.js.map +1 -0
  11. package/dist/cjs/__tests__/clients/open-exchange-rates-client.spec.js +17 -18
  12. package/dist/cjs/__tests__/clients/open-exchange-rates-client.spec.js.map +1 -1
  13. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js +255 -273
  14. package/dist/cjs/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  15. package/dist/cjs/__tests__/clients/sqs-bundling-contracts.spec.js +125 -137
  16. package/dist/cjs/__tests__/clients/sqs-bundling-contracts.spec.js.map +1 -1
  17. package/dist/cjs/__tests__/clients/sqs-client.spec.js +77 -78
  18. package/dist/cjs/__tests__/clients/sqs-client.spec.js.map +1 -1
  19. package/dist/cjs/__tests__/clients/sqs-unbundle.spec.js +430 -431
  20. package/dist/cjs/__tests__/clients/sqs-unbundle.spec.js.map +1 -1
  21. package/dist/cjs/__tests__/db/contact-enrichments-db-service.spec.js +29 -30
  22. package/dist/cjs/__tests__/db/contact-enrichments-db-service.spec.js.map +1 -1
  23. package/dist/cjs/__tests__/db/destinations-db-service.spec.js +47 -45
  24. package/dist/cjs/__tests__/db/destinations-db-service.spec.js.map +1 -1
  25. package/dist/cjs/__tests__/db/products-db-service.spec.js +40 -41
  26. package/dist/cjs/__tests__/db/products-db-service.spec.js.map +1 -1
  27. package/dist/cjs/__tests__/db/shared-read-db-services.spec.js +26 -27
  28. package/dist/cjs/__tests__/db/shared-read-db-services.spec.js.map +1 -1
  29. package/dist/cjs/__tests__/db/shopify-app-installs-db-service.spec.js +37 -38
  30. package/dist/cjs/__tests__/db/shopify-app-installs-db-service.spec.js.map +1 -1
  31. package/dist/cjs/__tests__/db/subscriptions-db-service.spec.js +35 -36
  32. package/dist/cjs/__tests__/db/subscriptions-db-service.spec.js.map +1 -1
  33. package/dist/cjs/__tests__/db/user-accounts-db-service.spec.js +27 -28
  34. package/dist/cjs/__tests__/db/user-accounts-db-service.spec.js.map +1 -1
  35. package/dist/cjs/__tests__/helpers/account-users-helper.spec.js +64 -65
  36. package/dist/cjs/__tests__/helpers/account-users-helper.spec.js.map +1 -1
  37. package/dist/cjs/__tests__/helpers/acuity-helper.spec.js +18 -19
  38. package/dist/cjs/__tests__/helpers/acuity-helper.spec.js.map +1 -1
  39. package/dist/cjs/__tests__/helpers/api-key-auth-helper.spec.js +23 -24
  40. package/dist/cjs/__tests__/helpers/api-key-auth-helper.spec.js.map +1 -1
  41. package/dist/cjs/__tests__/helpers/cognito-auth-helper.spec.js +16 -17
  42. package/dist/cjs/__tests__/helpers/cognito-auth-helper.spec.js.map +1 -1
  43. package/dist/cjs/__tests__/helpers/order-calculation-helper.spec.js +42 -43
  44. package/dist/cjs/__tests__/helpers/order-calculation-helper.spec.js.map +1 -1
  45. package/dist/cjs/__tests__/helpers/public-api-response-helper.spec.js +23 -24
  46. package/dist/cjs/__tests__/helpers/public-api-response-helper.spec.js.map +1 -1
  47. package/dist/cjs/__tests__/identity-cache/helpers.spec.js +114 -115
  48. package/dist/cjs/__tests__/identity-cache/helpers.spec.js.map +1 -1
  49. package/dist/cjs/__tests__/identity-cache/identity-cache-alias-write.spec.js +29 -30
  50. package/dist/cjs/__tests__/identity-cache/identity-cache-alias-write.spec.js.map +1 -1
  51. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.js +19 -20
  52. package/dist/cjs/__tests__/identity-cache/identity-cache-db-service.spec.js.map +1 -1
  53. package/dist/cjs/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js +200 -223
  54. package/dist/cjs/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js.map +1 -1
  55. package/dist/cjs/__tests__/identity-cache/identity-cache-tier-routing.spec.js +114 -123
  56. package/dist/cjs/__tests__/identity-cache/identity-cache-tier-routing.spec.js.map +1 -1
  57. package/dist/cjs/__tests__/identity-cache/identity-client.spec.js +107 -110
  58. package/dist/cjs/__tests__/identity-cache/identity-client.spec.js.map +1 -1
  59. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-hit.spec.js +31 -32
  60. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-hit.spec.js.map +1 -1
  61. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-miss.spec.js +47 -60
  62. package/dist/cjs/__tests__/identity-cache/identity-gateway-cache-miss.spec.js.map +1 -1
  63. package/dist/cjs/__tests__/identity-cache/identity-gateway-constructor.spec.js +15 -16
  64. package/dist/cjs/__tests__/identity-cache/identity-gateway-constructor.spec.js.map +1 -1
  65. package/dist/cjs/__tests__/identity-cache/identity-gateway-edge-cases.spec.js +28 -35
  66. package/dist/cjs/__tests__/identity-cache/identity-gateway-edge-cases.spec.js.map +1 -1
  67. package/dist/cjs/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js +27 -28
  68. package/dist/cjs/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js.map +1 -1
  69. package/dist/cjs/__tests__/identity-cache/identity-gateway-stale-cache.spec.js +52 -74
  70. package/dist/cjs/__tests__/identity-cache/identity-gateway-stale-cache.spec.js.map +1 -1
  71. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.d.ts +18 -14
  72. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.js +30 -37
  73. package/dist/cjs/__tests__/identity-cache/identity-gateway-test-setup.js.map +1 -1
  74. package/dist/cjs/__tests__/identity-cache/trait-merging-and-staleness.spec.js +424 -403
  75. package/dist/cjs/__tests__/identity-cache/trait-merging-and-staleness.spec.js.map +1 -1
  76. package/dist/cjs/__tests__/identity-cache/volatile-traits-optimization.spec.js +218 -219
  77. package/dist/cjs/__tests__/identity-cache/volatile-traits-optimization.spec.js.map +1 -1
  78. package/dist/cjs/__tests__/integration/sqs-bundling-roundtrip.spec.js +117 -118
  79. package/dist/cjs/__tests__/integration/sqs-bundling-roundtrip.spec.js.map +1 -1
  80. package/dist/cjs/__tests__/libs/compress-decompress.spec.js +7 -8
  81. package/dist/cjs/__tests__/libs/compress-decompress.spec.js.map +1 -1
  82. package/dist/cjs/__tests__/libs/contacts.spec.js +101 -102
  83. package/dist/cjs/__tests__/libs/contacts.spec.js.map +1 -1
  84. package/dist/cjs/__tests__/libs/currency.spec.js +56 -57
  85. package/dist/cjs/__tests__/libs/currency.spec.js.map +1 -1
  86. package/dist/cjs/__tests__/libs/dates.spec.js +94 -82
  87. package/dist/cjs/__tests__/libs/dates.spec.js.map +1 -1
  88. package/dist/cjs/__tests__/libs/domain.spec.js +68 -69
  89. package/dist/cjs/__tests__/libs/domain.spec.js.map +1 -1
  90. package/dist/cjs/__tests__/libs/numbers.spec.js +249 -250
  91. package/dist/cjs/__tests__/libs/numbers.spec.js.map +1 -1
  92. package/dist/cjs/__tests__/s3-client/s3-client.spec.js +16 -15
  93. package/dist/cjs/__tests__/s3-client/s3-client.spec.js.map +1 -1
  94. package/dist/cjs/__tests__/services/acuity-api-service.spec.js +32 -35
  95. package/dist/cjs/__tests__/services/acuity-api-service.spec.js.map +1 -1
  96. package/dist/cjs/__tests__/services/cost/cost-calculation-types.spec.js +14 -15
  97. package/dist/cjs/__tests__/services/cost/cost-calculation-types.spec.js.map +1 -1
  98. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js +949 -1187
  99. package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
  100. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js +39 -40
  101. package/dist/cjs/__tests__/services/cost/cost-currency-service.spec.js.map +1 -1
  102. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js +204 -201
  103. package/dist/cjs/__tests__/services/cost/cost-filter-service.spec.js.map +1 -1
  104. package/dist/cjs/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js +174 -299
  105. package/dist/cjs/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js.map +1 -1
  106. package/dist/cjs/__tests__/services/email-verification/contact-email-verification-service.spec.js +39 -41
  107. package/dist/cjs/__tests__/services/email-verification/contact-email-verification-service.spec.js.map +1 -1
  108. package/dist/cjs/__tests__/services/email-verification/email-verification-service.spec.js +22 -27
  109. package/dist/cjs/__tests__/services/email-verification/email-verification-service.spec.js.map +1 -1
  110. package/dist/cjs/__tests__/services/events/collect-queue-tracking-service.spec.js +64 -67
  111. package/dist/cjs/__tests__/services/events/collect-queue-tracking-service.spec.js.map +1 -1
  112. package/dist/cjs/__tests__/services/events/tracking-event-sqs-service.spec.js +51 -54
  113. package/dist/cjs/__tests__/services/events/tracking-event-sqs-service.spec.js.map +1 -1
  114. package/dist/cjs/__tests__/services/liveintent-api-service.spec.js +67 -0
  115. package/dist/cjs/__tests__/services/liveintent-api-service.spec.js.map +1 -0
  116. package/dist/cjs/__tests__/shopify/shopify-graphql-transformer.spec.js +9 -10
  117. package/dist/cjs/__tests__/shopify/shopify-graphql-transformer.spec.js.map +1 -1
  118. package/dist/cjs/__tests__/unit/libs/api-router/public-api-router.spec.js +58 -69
  119. package/dist/cjs/__tests__/unit/libs/api-router/public-api-router.spec.js.map +1 -1
  120. package/dist/cjs/__tests__/unit/libs/api-router/route-matcher.spec.js +31 -32
  121. package/dist/cjs/__tests__/unit/libs/api-router/route-matcher.spec.js.map +1 -1
  122. package/dist/cjs/__tests__/utils/custom-measure-formula-utils.spec.js +64 -65
  123. package/dist/cjs/__tests__/utils/custom-measure-formula-utils.spec.js.map +1 -1
  124. package/dist/cjs/clients/generic/cognito-client.js +14 -14
  125. package/dist/cjs/clients/generic/cognito-client.js.map +1 -1
  126. package/dist/cjs/clients/generic/dynamodb-client.js +9 -9
  127. package/dist/cjs/clients/generic/dynamodb-client.js.map +1 -1
  128. package/dist/cjs/clients/generic/eventbridge-client.js +2 -2
  129. package/dist/cjs/clients/generic/eventbridge-client.js.map +1 -1
  130. package/dist/cjs/clients/generic/http-client.js +5 -5
  131. package/dist/cjs/clients/generic/http-client.js.map +1 -1
  132. package/dist/cjs/clients/generic/lambda-invoke-client.js.map +1 -1
  133. package/dist/cjs/clients/generic/location-client.js +2 -2
  134. package/dist/cjs/clients/generic/location-client.js.map +1 -1
  135. package/dist/cjs/clients/generic/redis-client.js +2 -13
  136. package/dist/cjs/clients/generic/redis-client.js.map +1 -1
  137. package/dist/cjs/clients/generic/s3-client.d.ts +1 -0
  138. package/dist/cjs/clients/generic/s3-client.js +19 -19
  139. package/dist/cjs/clients/generic/s3-client.js.map +1 -1
  140. package/dist/cjs/clients/generic/singlestore-db-client.d.ts +2 -2
  141. package/dist/cjs/clients/generic/singlestore-db-client.js +8 -18
  142. package/dist/cjs/clients/generic/singlestore-db-client.js.map +1 -1
  143. package/dist/cjs/clients/generic/sqs-bundled-client.js +2 -2
  144. package/dist/cjs/clients/generic/sqs-bundled-client.js.map +1 -1
  145. package/dist/cjs/clients/generic/sqs-bundled-client.types.js +1 -1
  146. package/dist/cjs/clients/generic/sqs-bundled-client.types.js.map +1 -1
  147. package/dist/cjs/clients/generic/sqs-client.d.ts +1 -1
  148. package/dist/cjs/clients/generic/sqs-client.js +2 -2
  149. package/dist/cjs/clients/generic/sqs-client.js.map +1 -1
  150. package/dist/cjs/clients/generic/sqs-unbundle.js +7 -6
  151. package/dist/cjs/clients/generic/sqs-unbundle.js.map +1 -1
  152. package/dist/cjs/clients/internal-api/accounts-client.js +14 -14
  153. package/dist/cjs/clients/internal-api/accounts-client.js.map +1 -1
  154. package/dist/cjs/clients/internal-api/cache-lambda-client.js.map +1 -1
  155. package/dist/cjs/clients/internal-api/db-management-client.js.map +1 -1
  156. package/dist/cjs/clients/internal-api/destinations-client.js +8 -8
  157. package/dist/cjs/clients/internal-api/destinations-client.js.map +1 -1
  158. package/dist/cjs/clients/internal-api/event-collector-client.js.map +1 -1
  159. package/dist/cjs/clients/internal-api/identity-client.js.map +1 -1
  160. package/dist/cjs/clients/internal-api/shopify-app-install-client.js.map +1 -1
  161. package/dist/cjs/clients/internal-api/subscriptions-client.js.map +1 -1
  162. package/dist/cjs/clients/internal-api/users-auth-client.js +11 -11
  163. package/dist/cjs/clients/internal-api/users-auth-client.js.map +1 -1
  164. package/dist/cjs/clients/third-party/acuity-client.js.map +1 -1
  165. package/dist/cjs/clients/third-party/emailable-client.js.map +1 -1
  166. package/dist/cjs/clients/third-party/index.d.ts +1 -0
  167. package/dist/cjs/clients/third-party/index.js +1 -0
  168. package/dist/cjs/clients/third-party/index.js.map +1 -1
  169. package/dist/cjs/clients/third-party/liveintent-client.d.ts +11 -0
  170. package/dist/cjs/clients/third-party/liveintent-client.js +25 -0
  171. package/dist/cjs/clients/third-party/liveintent-client.js.map +1 -0
  172. package/dist/cjs/clients/third-party/loops-client.js.map +1 -1
  173. package/dist/cjs/clients/third-party/open-exchange-rates-client.js.map +1 -1
  174. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
  175. package/dist/cjs/clients/third-party/shopify-client.js +15 -15
  176. package/dist/cjs/clients/third-party/shopify-client.js.map +1 -1
  177. package/dist/cjs/constants/sqs.js +5 -5
  178. package/dist/cjs/constants/sqs.js.map +1 -1
  179. package/dist/cjs/helpers/account-users-helper.js.map +1 -1
  180. package/dist/cjs/helpers/acuity-helper.js.map +1 -1
  181. package/dist/cjs/helpers/api-key-auth-helper.d.ts +1 -2
  182. package/dist/cjs/helpers/api-key-auth-helper.js.map +1 -1
  183. package/dist/cjs/helpers/api-key-authorizer-helper.js.map +1 -1
  184. package/dist/cjs/helpers/cognito-auth-helper.d.ts +1 -2
  185. package/dist/cjs/helpers/cognito-auth-helper.js.map +1 -1
  186. package/dist/cjs/helpers/input-validation-helper.d.ts +1 -1
  187. package/dist/cjs/helpers/input-validation-helper.js.map +1 -1
  188. package/dist/cjs/helpers/logging-helper.d.ts +5 -5
  189. package/dist/cjs/helpers/logging-helper.js +7 -17
  190. package/dist/cjs/helpers/logging-helper.js.map +1 -1
  191. package/dist/cjs/helpers/order-calculation-helper.js.map +1 -1
  192. package/dist/cjs/helpers/public-api-response-helper.js.map +1 -1
  193. package/dist/cjs/helpers/response-helper.js.map +1 -1
  194. package/dist/cjs/helpers/shopify-helper.js.map +1 -1
  195. package/dist/cjs/helpers/sqs-utils.js +4 -8
  196. package/dist/cjs/helpers/sqs-utils.js.map +1 -1
  197. package/dist/cjs/libs/api-router/public-api-router.d.ts +2 -2
  198. package/dist/cjs/libs/api-router/public-api-router.js.map +1 -1
  199. package/dist/cjs/libs/api-router/route-matcher.js.map +1 -1
  200. package/dist/cjs/libs/click-id-parser.js +1 -1
  201. package/dist/cjs/libs/click-id-parser.js.map +1 -1
  202. package/dist/cjs/libs/compression.d.ts +1 -1
  203. package/dist/cjs/libs/compression.js.map +1 -1
  204. package/dist/cjs/libs/contacts.js.map +1 -1
  205. package/dist/cjs/libs/cookie.js +1 -1
  206. package/dist/cjs/libs/cookie.js.map +1 -1
  207. package/dist/cjs/libs/crypto.js.map +1 -1
  208. package/dist/cjs/libs/csv.js.map +1 -1
  209. package/dist/cjs/libs/currency.js.map +1 -1
  210. package/dist/cjs/libs/dates.d.ts +1 -0
  211. package/dist/cjs/libs/dates.js +18 -1
  212. package/dist/cjs/libs/dates.js.map +1 -1
  213. package/dist/cjs/libs/domain.js.map +1 -1
  214. package/dist/cjs/libs/emails.js.map +1 -1
  215. package/dist/cjs/libs/http-error.js.map +1 -1
  216. package/dist/cjs/libs/http-status-codes.js +1 -1
  217. package/dist/cjs/libs/http-status-codes.js.map +1 -1
  218. package/dist/cjs/libs/numbers.js.map +1 -1
  219. package/dist/cjs/libs/referrer-parser/referrer-parser-util.d.ts +1 -0
  220. package/dist/cjs/libs/referrer-parser/referrer-parser-util.js +2 -2
  221. package/dist/cjs/libs/referrer-parser/referrer-parser-util.js.map +1 -1
  222. package/dist/cjs/libs/strings.js.map +1 -1
  223. package/dist/cjs/libs/traits.js.map +1 -1
  224. package/dist/cjs/libs/url.js.map +1 -1
  225. package/dist/cjs/services/acuity-api-service.js.map +1 -1
  226. package/dist/cjs/services/cache/product-cache-service.js.map +1 -1
  227. package/dist/cjs/services/cost/cost-calculation-types.js +2 -1
  228. package/dist/cjs/services/cost/cost-calculation-types.js.map +1 -1
  229. package/dist/cjs/services/cost/cost-calculator-service.js +10 -43
  230. package/dist/cjs/services/cost/cost-calculator-service.js.map +1 -1
  231. package/dist/cjs/services/cost/cost-currency-service.js.map +1 -1
  232. package/dist/cjs/services/cost/cost-filter-service.js +7 -16
  233. package/dist/cjs/services/cost/cost-filter-service.js.map +1 -1
  234. package/dist/cjs/services/cost/order-cost/order-cost-resolution-service.js +9 -24
  235. package/dist/cjs/services/cost/order-cost/order-cost-resolution-service.js.map +1 -1
  236. package/dist/cjs/services/db/accounts-db-service.js.map +1 -1
  237. package/dist/cjs/services/db/api-keys-db-service.js.map +1 -1
  238. package/dist/cjs/services/db/contact-enrichments-db-service.js.map +1 -1
  239. package/dist/cjs/services/db/custom-measures-db-service.js.map +1 -1
  240. package/dist/cjs/services/db/destinations-db-service.js.map +1 -1
  241. package/dist/cjs/services/db/identity-cache-db-service.d.ts +1 -1
  242. package/dist/cjs/services/db/identity-cache-db-service.js.map +1 -1
  243. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js +1 -5
  244. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js.map +1 -1
  245. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-gateway-service.js +7 -21
  246. package/dist/cjs/services/db/identity-cache-dynamodb-service/identity-gateway-service.js.map +1 -1
  247. package/dist/cjs/services/db/identity-cache-dynamodb-service/key-builders.js +7 -7
  248. package/dist/cjs/services/db/identity-cache-dynamodb-service/key-builders.js.map +1 -1
  249. package/dist/cjs/services/db/identity-cache-dynamodb-service/types.js +3 -3
  250. package/dist/cjs/services/db/identity-cache-dynamodb-service/types.js.map +1 -1
  251. package/dist/cjs/services/db/index.d.ts +0 -1
  252. package/dist/cjs/services/db/index.js +0 -1
  253. package/dist/cjs/services/db/index.js.map +1 -1
  254. package/dist/cjs/services/db/log-events-db-service.js.map +1 -1
  255. package/dist/cjs/services/db/pixels-db-service.js.map +1 -1
  256. package/dist/cjs/services/db/products-db-service.js +16 -45
  257. package/dist/cjs/services/db/products-db-service.js.map +1 -1
  258. package/dist/cjs/services/db/purchasable-contacts-db-service.js.map +1 -1
  259. package/dist/cjs/services/db/purchased-contacts/purchased-contacts-db-service.js.map +1 -1
  260. package/dist/cjs/services/db/shopify-app-installs-db-service.js.map +1 -1
  261. package/dist/cjs/services/db/shopify-products-cache-db-service.js.map +1 -1
  262. package/dist/cjs/services/db/subscriptions-db-service.js.map +1 -1
  263. package/dist/cjs/services/db/tracking-events-db-service.js.map +1 -1
  264. package/dist/cjs/services/db/user-accounts-db-service.js.map +1 -1
  265. package/dist/cjs/services/email-verification/contact-email-verification-service.js.map +1 -1
  266. package/dist/cjs/services/email-verification/email-verification-service.js.map +1 -1
  267. package/dist/cjs/services/eventbridge-integration-service.js.map +1 -1
  268. package/dist/cjs/services/events/build-collect-queue-tracking-event.js +2 -2
  269. package/dist/cjs/services/events/build-collect-queue-tracking-event.js.map +1 -1
  270. package/dist/cjs/services/events/collect-queue-tracking-service.js.map +1 -1
  271. package/dist/cjs/services/events/log-event-service.js.map +1 -1
  272. package/dist/cjs/services/events/metric-event-service.js.map +1 -1
  273. package/dist/cjs/services/events/tracking-event-sqs-service.js.map +1 -1
  274. package/dist/cjs/services/generic-cache-service.js.map +1 -1
  275. package/dist/cjs/services/index.d.ts +1 -1
  276. package/dist/cjs/services/index.js +1 -1
  277. package/dist/cjs/services/index.js.map +1 -1
  278. package/dist/cjs/services/ipdata-lookup-service.d.ts +1 -1
  279. package/dist/cjs/services/ipdata-lookup-service.js.map +1 -1
  280. package/dist/cjs/services/liveintent-api-service.d.ts +15 -0
  281. package/dist/cjs/services/liveintent-api-service.js +59 -0
  282. package/dist/cjs/services/liveintent-api-service.js.map +1 -0
  283. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  284. package/dist/cjs/services/shopify/shopify-graphql-transformer.js +1 -1
  285. package/dist/cjs/services/shopify/shopify-graphql-transformer.js.map +1 -1
  286. package/dist/cjs/types/index.d.ts +1 -0
  287. package/dist/cjs/types/index.js +8 -17
  288. package/dist/cjs/types/index.js.map +1 -1
  289. package/dist/cjs/types/internal-events/event-detail-types.js +4 -4
  290. package/dist/cjs/types/internal-events/event-detail-types.js.map +1 -1
  291. package/dist/cjs/types/liveintent-types.d.ts +8 -0
  292. package/dist/cjs/types/liveintent-types.js +3 -0
  293. package/dist/cjs/types/liveintent-types.js.map +1 -0
  294. package/dist/cjs/types/public-api-types.js +1 -1
  295. package/dist/cjs/types/public-api-types.js.map +1 -1
  296. package/dist/cjs/types/shopify-graphql-types/admin.types.js +491 -491
  297. package/dist/cjs/types/shopify-graphql-types/admin.types.js.map +1 -1
  298. package/dist/cjs/types/shopify-rest-types.d.ts +1 -1
  299. package/dist/cjs/utils/compression.d.ts +2 -0
  300. package/dist/cjs/utils/compression.js +11 -11
  301. package/dist/cjs/utils/compression.js.map +1 -1
  302. package/dist/cjs/utils/custom-measure-formula-utils.js.map +1 -1
  303. package/dist/cjs/utils/retry-envelope.js +4 -3
  304. package/dist/cjs/utils/retry-envelope.js.map +1 -1
  305. package/dist/cjs/utils/size.js +3 -2
  306. package/dist/cjs/utils/size.js.map +1 -1
  307. package/dist/esm/__tests__/clients/acuity-client.spec.js +5 -6
  308. package/dist/esm/__tests__/clients/acuity-client.spec.js.map +1 -1
  309. package/dist/esm/__tests__/clients/cross-platform-compression.spec.js +0 -1
  310. package/dist/esm/__tests__/clients/cross-platform-compression.spec.js.map +1 -1
  311. package/dist/esm/__tests__/clients/dynamodb-client.spec.js +42 -41
  312. package/dist/esm/__tests__/clients/dynamodb-client.spec.js.map +1 -1
  313. package/dist/esm/__tests__/clients/event-collector-client.spec.js +18 -18
  314. package/dist/esm/__tests__/clients/event-collector-client.spec.js.map +1 -1
  315. package/dist/esm/__tests__/clients/liveintent-client.spec.js +35 -0
  316. package/dist/esm/__tests__/clients/liveintent-client.spec.js.map +1 -0
  317. package/dist/esm/__tests__/clients/open-exchange-rates-client.spec.js +3 -4
  318. package/dist/esm/__tests__/clients/open-exchange-rates-client.spec.js.map +1 -1
  319. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js +47 -55
  320. package/dist/esm/__tests__/clients/sqs-bundled-client.spec.js.map +1 -1
  321. package/dist/esm/__tests__/clients/sqs-bundling-contracts.spec.js +1 -3
  322. package/dist/esm/__tests__/clients/sqs-bundling-contracts.spec.js.map +1 -1
  323. package/dist/esm/__tests__/clients/sqs-client.spec.js +21 -22
  324. package/dist/esm/__tests__/clients/sqs-client.spec.js.map +1 -1
  325. package/dist/esm/__tests__/clients/sqs-unbundle.spec.js +8 -9
  326. package/dist/esm/__tests__/clients/sqs-unbundle.spec.js.map +1 -1
  327. package/dist/esm/__tests__/db/contact-enrichments-db-service.spec.js +5 -6
  328. package/dist/esm/__tests__/db/contact-enrichments-db-service.spec.js.map +1 -1
  329. package/dist/esm/__tests__/db/destinations-db-service.spec.js +11 -9
  330. package/dist/esm/__tests__/db/destinations-db-service.spec.js.map +1 -1
  331. package/dist/esm/__tests__/db/products-db-service.spec.js +8 -9
  332. package/dist/esm/__tests__/db/products-db-service.spec.js.map +1 -1
  333. package/dist/esm/__tests__/db/shared-read-db-services.spec.js +6 -7
  334. package/dist/esm/__tests__/db/shared-read-db-services.spec.js.map +1 -1
  335. package/dist/esm/__tests__/db/shopify-app-installs-db-service.spec.js +12 -13
  336. package/dist/esm/__tests__/db/shopify-app-installs-db-service.spec.js.map +1 -1
  337. package/dist/esm/__tests__/db/subscriptions-db-service.spec.js +11 -12
  338. package/dist/esm/__tests__/db/subscriptions-db-service.spec.js.map +1 -1
  339. package/dist/esm/__tests__/db/user-accounts-db-service.spec.js +6 -7
  340. package/dist/esm/__tests__/db/user-accounts-db-service.spec.js.map +1 -1
  341. package/dist/esm/__tests__/helpers/account-users-helper.spec.js +3 -4
  342. package/dist/esm/__tests__/helpers/account-users-helper.spec.js.map +1 -1
  343. package/dist/esm/__tests__/helpers/acuity-helper.spec.js +0 -1
  344. package/dist/esm/__tests__/helpers/acuity-helper.spec.js.map +1 -1
  345. package/dist/esm/__tests__/helpers/api-key-auth-helper.spec.js +3 -4
  346. package/dist/esm/__tests__/helpers/api-key-auth-helper.spec.js.map +1 -1
  347. package/dist/esm/__tests__/helpers/cognito-auth-helper.spec.js +1 -2
  348. package/dist/esm/__tests__/helpers/cognito-auth-helper.spec.js.map +1 -1
  349. package/dist/esm/__tests__/helpers/order-calculation-helper.spec.js +4 -5
  350. package/dist/esm/__tests__/helpers/order-calculation-helper.spec.js.map +1 -1
  351. package/dist/esm/__tests__/helpers/public-api-response-helper.spec.js +1 -2
  352. package/dist/esm/__tests__/helpers/public-api-response-helper.spec.js.map +1 -1
  353. package/dist/esm/__tests__/identity-cache/helpers.spec.js +1 -2
  354. package/dist/esm/__tests__/identity-cache/helpers.spec.js.map +1 -1
  355. package/dist/esm/__tests__/identity-cache/identity-cache-alias-write.spec.js +15 -16
  356. package/dist/esm/__tests__/identity-cache/identity-cache-alias-write.spec.js.map +1 -1
  357. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.js +1 -2
  358. package/dist/esm/__tests__/identity-cache/identity-cache-db-service.spec.js.map +1 -1
  359. package/dist/esm/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js +29 -52
  360. package/dist/esm/__tests__/identity-cache/identity-cache-dynamodb-db-service.spec.js.map +1 -1
  361. package/dist/esm/__tests__/identity-cache/identity-cache-tier-routing.spec.js +31 -40
  362. package/dist/esm/__tests__/identity-cache/identity-cache-tier-routing.spec.js.map +1 -1
  363. package/dist/esm/__tests__/identity-cache/identity-client.spec.js +21 -24
  364. package/dist/esm/__tests__/identity-cache/identity-client.spec.js.map +1 -1
  365. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-hit.spec.js +0 -1
  366. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-hit.spec.js.map +1 -1
  367. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-miss.spec.js +4 -17
  368. package/dist/esm/__tests__/identity-cache/identity-gateway-cache-miss.spec.js.map +1 -1
  369. package/dist/esm/__tests__/identity-cache/identity-gateway-constructor.spec.js +0 -1
  370. package/dist/esm/__tests__/identity-cache/identity-gateway-constructor.spec.js.map +1 -1
  371. package/dist/esm/__tests__/identity-cache/identity-gateway-edge-cases.spec.js +2 -9
  372. package/dist/esm/__tests__/identity-cache/identity-gateway-edge-cases.spec.js.map +1 -1
  373. package/dist/esm/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js +0 -1
  374. package/dist/esm/__tests__/identity-cache/identity-gateway-enqueue-async.spec.js.map +1 -1
  375. package/dist/esm/__tests__/identity-cache/identity-gateway-stale-cache.spec.js +7 -29
  376. package/dist/esm/__tests__/identity-cache/identity-gateway-stale-cache.spec.js.map +1 -1
  377. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.d.ts +18 -14
  378. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.js +30 -37
  379. package/dist/esm/__tests__/identity-cache/identity-gateway-test-setup.js.map +1 -1
  380. package/dist/esm/__tests__/identity-cache/trait-merging-and-staleness.spec.js +37 -16
  381. package/dist/esm/__tests__/identity-cache/trait-merging-and-staleness.spec.js.map +1 -1
  382. package/dist/esm/__tests__/identity-cache/volatile-traits-optimization.spec.js +5 -6
  383. package/dist/esm/__tests__/identity-cache/volatile-traits-optimization.spec.js.map +1 -1
  384. package/dist/esm/__tests__/integration/sqs-bundling-roundtrip.spec.js +9 -10
  385. package/dist/esm/__tests__/integration/sqs-bundling-roundtrip.spec.js.map +1 -1
  386. package/dist/esm/__tests__/libs/compress-decompress.spec.js +1 -2
  387. package/dist/esm/__tests__/libs/compress-decompress.spec.js.map +1 -1
  388. package/dist/esm/__tests__/libs/contacts.spec.js +0 -1
  389. package/dist/esm/__tests__/libs/contacts.spec.js.map +1 -1
  390. package/dist/esm/__tests__/libs/currency.spec.js +3 -4
  391. package/dist/esm/__tests__/libs/currency.spec.js.map +1 -1
  392. package/dist/esm/__tests__/libs/dates.spec.js +23 -11
  393. package/dist/esm/__tests__/libs/dates.spec.js.map +1 -1
  394. package/dist/esm/__tests__/libs/domain.spec.js +0 -1
  395. package/dist/esm/__tests__/libs/domain.spec.js.map +1 -1
  396. package/dist/esm/__tests__/libs/numbers.spec.js +0 -1
  397. package/dist/esm/__tests__/libs/numbers.spec.js.map +1 -1
  398. package/dist/esm/__tests__/s3-client/s3-client.spec.js +7 -6
  399. package/dist/esm/__tests__/s3-client/s3-client.spec.js.map +1 -1
  400. package/dist/esm/__tests__/services/acuity-api-service.spec.js +10 -13
  401. package/dist/esm/__tests__/services/acuity-api-service.spec.js.map +1 -1
  402. package/dist/esm/__tests__/services/cost/cost-calculation-types.spec.js +0 -1
  403. package/dist/esm/__tests__/services/cost/cost-calculation-types.spec.js.map +1 -1
  404. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js +280 -518
  405. package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
  406. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js +3 -4
  407. package/dist/esm/__tests__/services/cost/cost-currency-service.spec.js.map +1 -1
  408. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js +22 -19
  409. package/dist/esm/__tests__/services/cost/cost-filter-service.spec.js.map +1 -1
  410. package/dist/esm/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js +41 -133
  411. package/dist/esm/__tests__/services/cost/order-cost/order-cost-resolution-service.spec.js.map +1 -1
  412. package/dist/esm/__tests__/services/email-verification/contact-email-verification-service.spec.js +6 -8
  413. package/dist/esm/__tests__/services/email-verification/contact-email-verification-service.spec.js.map +1 -1
  414. package/dist/esm/__tests__/services/email-verification/email-verification-service.spec.js +5 -10
  415. package/dist/esm/__tests__/services/email-verification/email-verification-service.spec.js.map +1 -1
  416. package/dist/esm/__tests__/services/events/collect-queue-tracking-service.spec.js +14 -17
  417. package/dist/esm/__tests__/services/events/collect-queue-tracking-service.spec.js.map +1 -1
  418. package/dist/esm/__tests__/services/events/tracking-event-sqs-service.spec.js +16 -19
  419. package/dist/esm/__tests__/services/events/tracking-event-sqs-service.spec.js.map +1 -1
  420. package/dist/esm/__tests__/services/liveintent-api-service.spec.js +65 -0
  421. package/dist/esm/__tests__/services/liveintent-api-service.spec.js.map +1 -0
  422. package/dist/esm/__tests__/shopify/shopify-graphql-transformer.spec.js +1 -2
  423. package/dist/esm/__tests__/shopify/shopify-graphql-transformer.spec.js.map +1 -1
  424. package/dist/esm/__tests__/unit/libs/api-router/public-api-router.spec.js +14 -15
  425. package/dist/esm/__tests__/unit/libs/api-router/public-api-router.spec.js.map +1 -1
  426. package/dist/esm/__tests__/unit/libs/api-router/route-matcher.spec.js +1 -2
  427. package/dist/esm/__tests__/unit/libs/api-router/route-matcher.spec.js.map +1 -1
  428. package/dist/esm/__tests__/utils/custom-measure-formula-utils.spec.js +0 -1
  429. package/dist/esm/__tests__/utils/custom-measure-formula-utils.spec.js.map +1 -1
  430. package/dist/esm/clients/generic/cognito-client.js +2 -2
  431. package/dist/esm/clients/generic/cognito-client.js.map +1 -1
  432. package/dist/esm/clients/generic/dynamodb-client.js +9 -9
  433. package/dist/esm/clients/generic/dynamodb-client.js.map +1 -1
  434. package/dist/esm/clients/generic/eventbridge-client.js +1 -1
  435. package/dist/esm/clients/generic/eventbridge-client.js.map +1 -1
  436. package/dist/esm/clients/generic/http-client.js +5 -5
  437. package/dist/esm/clients/generic/http-client.js.map +1 -1
  438. package/dist/esm/clients/generic/lambda-invoke-client.js.map +1 -1
  439. package/dist/esm/clients/generic/location-client.js +1 -1
  440. package/dist/esm/clients/generic/location-client.js.map +1 -1
  441. package/dist/esm/clients/generic/redis-client.js +2 -13
  442. package/dist/esm/clients/generic/redis-client.js.map +1 -1
  443. package/dist/esm/clients/generic/s3-client.d.ts +1 -0
  444. package/dist/esm/clients/generic/s3-client.js +1 -1
  445. package/dist/esm/clients/generic/s3-client.js.map +1 -1
  446. package/dist/esm/clients/generic/singlestore-db-client.d.ts +2 -2
  447. package/dist/esm/clients/generic/singlestore-db-client.js +1 -1
  448. package/dist/esm/clients/generic/singlestore-db-client.js.map +1 -1
  449. package/dist/esm/clients/generic/sqs-bundled-client.js +2 -2
  450. package/dist/esm/clients/generic/sqs-bundled-client.js.map +1 -1
  451. package/dist/esm/clients/generic/sqs-client.d.ts +1 -1
  452. package/dist/esm/clients/generic/sqs-client.js +2 -2
  453. package/dist/esm/clients/generic/sqs-client.js.map +1 -1
  454. package/dist/esm/clients/generic/sqs-unbundle.js +2 -2
  455. package/dist/esm/clients/generic/sqs-unbundle.js.map +1 -1
  456. package/dist/esm/clients/internal-api/accounts-client.js +1 -1
  457. package/dist/esm/clients/internal-api/accounts-client.js.map +1 -1
  458. package/dist/esm/clients/internal-api/cache-lambda-client.js.map +1 -1
  459. package/dist/esm/clients/internal-api/destinations-client.js +1 -1
  460. package/dist/esm/clients/internal-api/destinations-client.js.map +1 -1
  461. package/dist/esm/clients/internal-api/event-collector-client.js.map +1 -1
  462. package/dist/esm/clients/internal-api/identity-client.js.map +1 -1
  463. package/dist/esm/clients/internal-api/users-auth-client.js +1 -1
  464. package/dist/esm/clients/internal-api/users-auth-client.js.map +1 -1
  465. package/dist/esm/clients/third-party/emailable-client.js.map +1 -1
  466. package/dist/esm/clients/third-party/index.d.ts +1 -0
  467. package/dist/esm/clients/third-party/index.js +1 -0
  468. package/dist/esm/clients/third-party/index.js.map +1 -1
  469. package/dist/esm/clients/third-party/liveintent-client.d.ts +11 -0
  470. package/dist/esm/clients/third-party/liveintent-client.js +21 -0
  471. package/dist/esm/clients/third-party/liveintent-client.js.map +1 -0
  472. package/dist/esm/clients/third-party/loops-client.js.map +1 -1
  473. package/dist/esm/clients/third-party/open-exchange-rates-client.js.map +1 -1
  474. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js +1 -1
  475. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
  476. package/dist/esm/clients/third-party/shopify-client.js +1 -1
  477. package/dist/esm/clients/third-party/shopify-client.js.map +1 -1
  478. package/dist/esm/constants/sqs.js +3 -3
  479. package/dist/esm/constants/sqs.js.map +1 -1
  480. package/dist/esm/helpers/account-users-helper.js.map +1 -1
  481. package/dist/esm/helpers/acuity-helper.js.map +1 -1
  482. package/dist/esm/helpers/api-key-auth-helper.d.ts +1 -2
  483. package/dist/esm/helpers/api-key-auth-helper.js.map +1 -1
  484. package/dist/esm/helpers/api-key-authorizer-helper.js.map +1 -1
  485. package/dist/esm/helpers/cognito-auth-helper.d.ts +1 -2
  486. package/dist/esm/helpers/cognito-auth-helper.js.map +1 -1
  487. package/dist/esm/helpers/input-validation-helper.d.ts +1 -1
  488. package/dist/esm/helpers/input-validation-helper.js.map +1 -1
  489. package/dist/esm/helpers/logging-helper.d.ts +5 -5
  490. package/dist/esm/helpers/logging-helper.js.map +1 -1
  491. package/dist/esm/helpers/order-calculation-helper.js.map +1 -1
  492. package/dist/esm/helpers/public-api-response-helper.js.map +1 -1
  493. package/dist/esm/helpers/response-helper.js.map +1 -1
  494. package/dist/esm/helpers/shopify-helper.js.map +1 -1
  495. package/dist/esm/helpers/sqs-utils.js +1 -6
  496. package/dist/esm/helpers/sqs-utils.js.map +1 -1
  497. package/dist/esm/libs/api-router/public-api-router.d.ts +2 -2
  498. package/dist/esm/libs/api-router/public-api-router.js.map +1 -1
  499. package/dist/esm/libs/api-router/route-matcher.js.map +1 -1
  500. package/dist/esm/libs/click-id-parser.js.map +1 -1
  501. package/dist/esm/libs/compression.d.ts +1 -1
  502. package/dist/esm/libs/compression.js.map +1 -1
  503. package/dist/esm/libs/contacts.js.map +1 -1
  504. package/dist/esm/libs/cookie.js.map +1 -1
  505. package/dist/esm/libs/csv.js.map +1 -1
  506. package/dist/esm/libs/currency.js.map +1 -1
  507. package/dist/esm/libs/dates.d.ts +1 -0
  508. package/dist/esm/libs/dates.js +16 -0
  509. package/dist/esm/libs/dates.js.map +1 -1
  510. package/dist/esm/libs/domain.js.map +1 -1
  511. package/dist/esm/libs/emails.js.map +1 -1
  512. package/dist/esm/libs/http-error.js.map +1 -1
  513. package/dist/esm/libs/numbers.js.map +1 -1
  514. package/dist/esm/libs/referrer-parser/referrer-parser-util.d.ts +1 -0
  515. package/dist/esm/libs/referrer-parser/referrer-parser-util.js +2 -2
  516. package/dist/esm/libs/referrer-parser/referrer-parser-util.js.map +1 -1
  517. package/dist/esm/libs/strings.js.map +1 -1
  518. package/dist/esm/libs/traits.js.map +1 -1
  519. package/dist/esm/services/acuity-api-service.js.map +1 -1
  520. package/dist/esm/services/cache/product-cache-service.js.map +1 -1
  521. package/dist/esm/services/cost/cost-calculation-types.js.map +1 -1
  522. package/dist/esm/services/cost/cost-calculator-service.js +10 -43
  523. package/dist/esm/services/cost/cost-calculator-service.js.map +1 -1
  524. package/dist/esm/services/cost/cost-currency-service.js.map +1 -1
  525. package/dist/esm/services/cost/cost-filter-service.js +7 -16
  526. package/dist/esm/services/cost/cost-filter-service.js.map +1 -1
  527. package/dist/esm/services/cost/order-cost/order-cost-resolution-service.js +9 -24
  528. package/dist/esm/services/cost/order-cost/order-cost-resolution-service.js.map +1 -1
  529. package/dist/esm/services/db/accounts-db-service.js.map +1 -1
  530. package/dist/esm/services/db/api-keys-db-service.js.map +1 -1
  531. package/dist/esm/services/db/contact-enrichments-db-service.js.map +1 -1
  532. package/dist/esm/services/db/custom-measures-db-service.js.map +1 -1
  533. package/dist/esm/services/db/identity-cache-db-service.d.ts +1 -1
  534. package/dist/esm/services/db/identity-cache-db-service.js.map +1 -1
  535. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js +2 -6
  536. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-cache-dynamodb-db-service.js.map +1 -1
  537. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-gateway-service.js +8 -22
  538. package/dist/esm/services/db/identity-cache-dynamodb-service/identity-gateway-service.js.map +1 -1
  539. package/dist/esm/services/db/identity-cache-dynamodb-service/types.js.map +1 -1
  540. package/dist/esm/services/db/index.d.ts +0 -1
  541. package/dist/esm/services/db/index.js +0 -1
  542. package/dist/esm/services/db/index.js.map +1 -1
  543. package/dist/esm/services/db/log-events-db-service.js.map +1 -1
  544. package/dist/esm/services/db/products-db-service.js +16 -45
  545. package/dist/esm/services/db/products-db-service.js.map +1 -1
  546. package/dist/esm/services/db/purchasable-contacts-db-service.js.map +1 -1
  547. package/dist/esm/services/db/purchased-contacts/purchased-contacts-db-service.js.map +1 -1
  548. package/dist/esm/services/db/shopify-app-installs-db-service.js.map +1 -1
  549. package/dist/esm/services/db/shopify-products-cache-db-service.js.map +1 -1
  550. package/dist/esm/services/db/subscriptions-db-service.js.map +1 -1
  551. package/dist/esm/services/db/tracking-events-db-service.js.map +1 -1
  552. package/dist/esm/services/email-verification/contact-email-verification-service.js.map +1 -1
  553. package/dist/esm/services/email-verification/email-verification-service.js.map +1 -1
  554. package/dist/esm/services/events/build-collect-queue-tracking-event.js.map +1 -1
  555. package/dist/esm/services/events/collect-queue-tracking-service.js +1 -1
  556. package/dist/esm/services/events/collect-queue-tracking-service.js.map +1 -1
  557. package/dist/esm/services/events/log-event-service.js.map +1 -1
  558. package/dist/esm/services/events/metric-event-service.js.map +1 -1
  559. package/dist/esm/services/events/tracking-event-sqs-service.js.map +1 -1
  560. package/dist/esm/services/generic-cache-service.js.map +1 -1
  561. package/dist/esm/services/index.d.ts +1 -1
  562. package/dist/esm/services/index.js +1 -1
  563. package/dist/esm/services/index.js.map +1 -1
  564. package/dist/esm/services/ipdata-lookup-service.d.ts +1 -1
  565. package/dist/esm/services/ipdata-lookup-service.js.map +1 -1
  566. package/dist/esm/services/liveintent-api-service.d.ts +15 -0
  567. package/dist/esm/services/liveintent-api-service.js +55 -0
  568. package/dist/esm/services/liveintent-api-service.js.map +1 -0
  569. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
  570. package/dist/esm/services/shopify/shopify-graphql-transformer.js +1 -1
  571. package/dist/esm/services/shopify/shopify-graphql-transformer.js.map +1 -1
  572. package/dist/esm/types/index.d.ts +1 -0
  573. package/dist/esm/types/index.js +1 -0
  574. package/dist/esm/types/index.js.map +1 -1
  575. package/dist/esm/types/liveintent-types.d.ts +8 -0
  576. package/dist/esm/types/liveintent-types.js +2 -0
  577. package/dist/esm/types/liveintent-types.js.map +1 -0
  578. package/dist/esm/types/shopify-rest-types.d.ts +1 -1
  579. package/dist/esm/utils/compression.d.ts +2 -0
  580. package/dist/esm/utils/compression.js +3 -3
  581. package/dist/esm/utils/compression.js.map +1 -1
  582. package/dist/esm/utils/custom-measure-formula-utils.js.map +1 -1
  583. package/dist/esm/utils/retry-envelope.js.map +1 -1
  584. package/dist/esm/utils/size.js.map +1 -1
  585. package/package.json +136 -139
  586. package/dist/cjs/__tests__/clients/client-timeout-inventory.spec.js +0 -21
  587. package/dist/cjs/__tests__/clients/client-timeout-inventory.spec.js.map +0 -1
  588. package/dist/cjs/__tests__/clients/redis-client.spec.js +0 -79
  589. package/dist/cjs/__tests__/clients/redis-client.spec.js.map +0 -1
  590. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js +0 -40
  591. package/dist/cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +0 -1
  592. package/dist/cjs/clients/third-party/exchange-rate-api-client.d.ts +0 -17
  593. package/dist/cjs/clients/third-party/exchange-rate-api-client.js +0 -20
  594. package/dist/cjs/clients/third-party/exchange-rate-api-client.js.map +0 -1
  595. package/dist/cjs/services/currency-exchange-rate-lookup-service.d.ts +0 -12
  596. package/dist/cjs/services/currency-exchange-rate-lookup-service.js +0 -98
  597. package/dist/cjs/services/currency-exchange-rate-lookup-service.js.map +0 -1
  598. package/dist/cjs/services/db/currency-exchange-rates-db-service.d.ts +0 -21
  599. package/dist/cjs/services/db/currency-exchange-rates-db-service.js +0 -40
  600. package/dist/cjs/services/db/currency-exchange-rates-db-service.js.map +0 -1
  601. package/dist/esm/__tests__/clients/client-timeout-inventory.spec.js +0 -19
  602. package/dist/esm/__tests__/clients/client-timeout-inventory.spec.js.map +0 -1
  603. package/dist/esm/__tests__/clients/redis-client.spec.d.ts +0 -1
  604. package/dist/esm/__tests__/clients/redis-client.spec.js +0 -77
  605. package/dist/esm/__tests__/clients/redis-client.spec.js.map +0 -1
  606. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts +0 -1
  607. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js +0 -38
  608. package/dist/esm/__tests__/services/currency-exchange-rate-lookup-service.spec.js.map +0 -1
  609. package/dist/esm/clients/third-party/exchange-rate-api-client.d.ts +0 -17
  610. package/dist/esm/clients/third-party/exchange-rate-api-client.js +0 -16
  611. package/dist/esm/clients/third-party/exchange-rate-api-client.js.map +0 -1
  612. package/dist/esm/services/currency-exchange-rate-lookup-service.d.ts +0 -12
  613. package/dist/esm/services/currency-exchange-rate-lookup-service.js +0 -94
  614. package/dist/esm/services/currency-exchange-rate-lookup-service.js.map +0 -1
  615. package/dist/esm/services/db/currency-exchange-rates-db-service.d.ts +0 -21
  616. package/dist/esm/services/db/currency-exchange-rates-db-service.js +0 -36
  617. package/dist/esm/services/db/currency-exchange-rates-db-service.js.map +0 -1
  618. /package/dist/cjs/__tests__/clients/{client-timeout-inventory.spec.d.ts → liveintent-client.spec.d.ts} +0 -0
  619. /package/dist/cjs/__tests__/{clients/redis-client.spec.d.ts → services/liveintent-api-service.spec.d.ts} +0 -0
  620. /package/dist/{cjs/__tests__/services/currency-exchange-rate-lookup-service.spec.d.ts → esm/__tests__/clients/liveintent-client.spec.d.ts} +0 -0
  621. /package/dist/esm/__tests__/{clients/client-timeout-inventory.spec.d.ts → services/liveintent-api-service.spec.d.ts} +0 -0
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const at_tracking_event_types_1 = require("@adtrackify/at-tracking-event-types");
5
4
  const cost_calculator_service_1 = require("../../../services/cost/cost-calculator-service");
6
- vitest_1.vi.mock('../../../helpers/logging-helper', () => ({
7
- Logger: { debug: vitest_1.vi.fn(), info: vitest_1.vi.fn(), warn: vitest_1.vi.fn(), error: vitest_1.vi.fn() },
5
+ jest.mock('../../../helpers/logging-helper', () => ({
6
+ Logger: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() },
8
7
  }));
9
8
  const emptyRatesMap = {};
10
9
  const createLineItem = (overrides = {}) => ({
@@ -56,82 +55,82 @@ const createConfigs = (overrides = {}) => ({
56
55
  shipping: null,
57
56
  ...overrides,
58
57
  });
59
- (0, vitest_1.describe)('CostCalculatorService', () => {
60
- (0, vitest_1.describe)('isDateInRange', () => {
61
- (0, vitest_1.it)('should return true when no date bounds', () => {
62
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.isDateInRange('2024-06-15T10:00:00Z')).toBe(true);
58
+ describe('CostCalculatorService', () => {
59
+ describe('isDateInRange', () => {
60
+ it('should return true when no date bounds', () => {
61
+ expect(cost_calculator_service_1.CostCalculatorService.isDateInRange('2024-06-15T10:00:00Z')).toBe(true);
63
62
  });
64
- (0, vitest_1.it)('should return true when order date is within range', () => {
65
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.isDateInRange('2024-06-15T10:00:00Z', '2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z')).toBe(true);
63
+ it('should return true when order date is within range', () => {
64
+ expect(cost_calculator_service_1.CostCalculatorService.isDateInRange('2024-06-15T10:00:00Z', '2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z')).toBe(true);
66
65
  });
67
- (0, vitest_1.it)('should return false when order date is before effectiveFrom', () => {
68
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.isDateInRange('2023-06-15T10:00:00Z', '2024-01-01T00:00:00Z')).toBe(false);
66
+ it('should return false when order date is before effectiveFrom', () => {
67
+ expect(cost_calculator_service_1.CostCalculatorService.isDateInRange('2023-06-15T10:00:00Z', '2024-01-01T00:00:00Z')).toBe(false);
69
68
  });
70
- (0, vitest_1.it)('should return false when order date is after effectiveTo', () => {
71
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.isDateInRange('2025-06-15T10:00:00Z', undefined, '2024-12-31T23:59:59Z')).toBe(false);
69
+ it('should return false when order date is after effectiveTo', () => {
70
+ expect(cost_calculator_service_1.CostCalculatorService.isDateInRange('2025-06-15T10:00:00Z', undefined, '2024-12-31T23:59:59Z')).toBe(false);
72
71
  });
73
- (0, vitest_1.it)('should return true for invalid order date', () => {
74
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.isDateInRange('invalid-date', '2024-01-01T00:00:00Z')).toBe(true);
72
+ it('should return true for invalid order date', () => {
73
+ expect(cost_calculator_service_1.CostCalculatorService.isDateInRange('invalid-date', '2024-01-01T00:00:00Z')).toBe(true);
75
74
  });
76
75
  });
77
- (0, vitest_1.describe)('findMatchingWeightTierAmount', () => {
78
- (0, vitest_1.it)('should return 0 for empty tiers', () => {
79
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount([], 500, undefined)).toBe(0);
80
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(undefined, 500, undefined)).toBe(0);
76
+ describe('findMatchingWeightTierAmount', () => {
77
+ it('should return 0 for empty tiers', () => {
78
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount([], 500, undefined)).toBe(0);
79
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(undefined, 500, undefined)).toBe(0);
81
80
  });
82
- (0, vitest_1.it)('should find correct tier', () => {
81
+ it('should find correct tier', () => {
83
82
  const tiers = [
84
83
  { weightMin: 0, weightMax: 500, flatAmount: 5 },
85
84
  { weightMin: 501, weightMax: 1000, flatAmount: 10 },
86
85
  { weightMin: 1001, weightMax: null, flatAmount: 15 },
87
86
  ];
88
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 250, undefined)).toBe(5);
89
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 750, undefined)).toBe(10);
90
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 2000, undefined)).toBe(15);
87
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 250, undefined)).toBe(5);
88
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 750, undefined)).toBe(10);
89
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 2000, undefined)).toBe(15);
91
90
  });
92
- (0, vitest_1.it)('should return 0 when no tier matches', () => {
91
+ it('should return 0 when no tier matches', () => {
93
92
  const tiers = [{ weightMin: 100, weightMax: 200, flatAmount: 5 }];
94
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 50, undefined)).toBe(0);
93
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 50, undefined)).toBe(0);
95
94
  });
96
- (0, vitest_1.it)('should convert weight from grams to OUNCES before matching', () => {
95
+ it('should convert weight from grams to OUNCES before matching', () => {
97
96
  const tiers = [
98
97
  { weightMin: 0, weightMax: 5, flatAmount: 2 },
99
98
  { weightMin: 5.01, weightMax: null, flatAmount: 8 },
100
99
  ];
101
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 100, at_tracking_event_types_1.WEIGHT_UNIT.OUNCES)).toBe(2);
102
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 500, at_tracking_event_types_1.WEIGHT_UNIT.OUNCES)).toBe(8);
100
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 100, at_tracking_event_types_1.WEIGHT_UNIT.OUNCES)).toBe(2);
101
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 500, at_tracking_event_types_1.WEIGHT_UNIT.OUNCES)).toBe(8);
103
102
  });
104
- (0, vitest_1.it)('should return 0 when tier has null flatAmount', () => {
103
+ it('should return 0 when tier has null flatAmount', () => {
105
104
  const tiers = [{ weightMin: 0, weightMax: 1000, flatAmount: null }];
106
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 500, undefined)).toBe(0);
105
+ expect(cost_calculator_service_1.CostCalculatorService.findMatchingWeightTierAmount(tiers, 500, undefined)).toBe(0);
107
106
  });
108
107
  });
109
- (0, vitest_1.describe)('findQuantityTierAmount', () => {
110
- (0, vitest_1.it)('should return 0 for empty tiers', () => {
111
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount([], 5)).toBe(0);
112
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(undefined, 5)).toBe(0);
108
+ describe('findQuantityTierAmount', () => {
109
+ it('should return 0 for empty tiers', () => {
110
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount([], 5)).toBe(0);
111
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(undefined, 5)).toBe(0);
113
112
  });
114
- (0, vitest_1.it)('should find correct tier', () => {
113
+ it('should find correct tier', () => {
115
114
  const tiers = [
116
115
  { quantityMin: 1, quantityMax: 10, flatAmount: 2 },
117
116
  { quantityMin: 11, quantityMax: null, flatAmount: 1 },
118
117
  ];
119
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 5)).toBe(2);
120
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 20)).toBe(1);
118
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 5)).toBe(2);
119
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 20)).toBe(1);
121
120
  });
122
- (0, vitest_1.it)('should return 0 when quantity is below all tiers', () => {
121
+ it('should return 0 when quantity is below all tiers', () => {
123
122
  const tiers = [
124
123
  { quantityMin: 5, quantityMax: 10, flatAmount: 2 },
125
124
  { quantityMin: 11, quantityMax: null, flatAmount: 1 },
126
125
  ];
127
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 2)).toBe(0);
126
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 2)).toBe(0);
128
127
  });
129
- (0, vitest_1.it)('should return 0 when tier has null flatAmount', () => {
128
+ it('should return 0 when tier has null flatAmount', () => {
130
129
  const tiers = [{ quantityMin: 1, quantityMax: 10, flatAmount: null }];
131
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 5)).toBe(0);
130
+ expect(cost_calculator_service_1.CostCalculatorService.findQuantityTierAmount(tiers, 5)).toBe(0);
132
131
  });
133
132
  });
134
- (0, vitest_1.describe)('calculateHandlingCost', () => {
133
+ describe('calculateHandlingCost', () => {
135
134
  const initLineItemCosts = (lineItemIds = ['1']) => {
136
135
  const result = {};
137
136
  for (const id of lineItemIds) {
@@ -139,23 +138,23 @@ const createConfigs = (overrides = {}) => ({
139
138
  }
140
139
  return result;
141
140
  };
142
- (0, vitest_1.it)('should return 0 when no globalProductOverride', () => {
141
+ it('should return 0 when no globalProductOverride', () => {
143
142
  const configs = createConfigs();
144
143
  const lineItems = [createLineItem({ quantity: 1 })];
145
144
  const liCosts = initLineItemCosts();
146
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap)).toBe(0);
145
+ expect(cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap)).toBe(0);
147
146
  });
148
- (0, vitest_1.it)('should apply the fee per unit, multiplied by quantity', () => {
147
+ it('should apply the fee per unit, multiplied by quantity', () => {
149
148
  const configs = createConfigs({
150
149
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
151
150
  });
152
151
  const lineItems = [createLineItem({ lineItemId: '1', quantity: 3 })];
153
152
  const liCosts = initLineItemCosts();
154
153
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
155
- (0, vitest_1.expect)(result).toBe(6);
156
- (0, vitest_1.expect)(liCosts['1'].totalLineItemHandlingCost).toBe(6);
154
+ expect(result).toBe(6);
155
+ expect(liCosts['1'].totalLineItemHandlingCost).toBe(6);
157
156
  });
158
- (0, vitest_1.it)('should sum across multiple line items using each quantity', () => {
157
+ it('should sum across multiple line items using each quantity', () => {
159
158
  const configs = createConfigs({
160
159
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
161
160
  });
@@ -165,11 +164,11 @@ const createConfigs = (overrides = {}) => ({
165
164
  ];
166
165
  const liCosts = initLineItemCosts(['1', '2']);
167
166
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
168
- (0, vitest_1.expect)(result).toBe(10);
169
- (0, vitest_1.expect)(liCosts['1'].totalLineItemHandlingCost).toBe(4);
170
- (0, vitest_1.expect)(liCosts['2'].totalLineItemHandlingCost).toBe(6);
167
+ expect(result).toBe(10);
168
+ expect(liCosts['1'].totalLineItemHandlingCost).toBe(4);
169
+ expect(liCosts['2'].totalLineItemHandlingCost).toBe(6);
171
170
  });
172
- (0, vitest_1.it)('should match the variant-level fee when both are the same amount', () => {
171
+ it('should match the variant-level fee when both are the same amount', () => {
173
172
  const configs = createConfigs({
174
173
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
175
174
  });
@@ -179,9 +178,9 @@ const createConfigs = (overrides = {}) => ({
179
178
  const variantTotal = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([
180
179
  createLineItem({ lineItemId: '1', quantity, variantHandlingFee: 2 }),
181
180
  ]);
182
- (0, vitest_1.expect)(globalTotal).toBe(variantTotal['1']);
181
+ expect(globalTotal).toBe(variantTotal['1']);
183
182
  });
184
- (0, vitest_1.it)('should convert currency when config currency differs from order currency', () => {
183
+ it('should convert currency when config currency differs from order currency', () => {
185
184
  const configs = createConfigs({
186
185
  globalProductOverride: { globalHandlingFee: 10, currency: 'EUR' },
187
186
  });
@@ -189,17 +188,17 @@ const createConfigs = (overrides = {}) => ({
189
188
  const lineItems = [createLineItem({ quantity: 1 })];
190
189
  const liCosts = initLineItemCosts();
191
190
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', rates);
192
- (0, vitest_1.expect)(result).toBeCloseTo(11);
191
+ expect(result).toBeCloseTo(11);
193
192
  });
194
- (0, vitest_1.it)('should return fee without conversion when config has no currency', () => {
193
+ it('should return fee without conversion when config has no currency', () => {
195
194
  const configs = createConfigs({
196
195
  globalProductOverride: { globalHandlingFee: 5 },
197
196
  });
198
197
  const lineItems = [createLineItem({ quantity: 1 })];
199
198
  const liCosts = initLineItemCosts();
200
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap)).toBe(5);
199
+ expect(cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap)).toBe(5);
201
200
  });
202
- (0, vitest_1.it)('should skip line items that have a per-variant handling fee override', () => {
201
+ it('should skip line items that have a per-variant handling fee override', () => {
203
202
  const configs = createConfigs({
204
203
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
205
204
  });
@@ -207,20 +206,20 @@ const createConfigs = (overrides = {}) => ({
207
206
  const liCosts = initLineItemCosts();
208
207
  liCosts['1'].totalLineItemHandlingCost = 4.5;
209
208
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
210
- (0, vitest_1.expect)(result).toBe(0);
211
- (0, vitest_1.expect)(liCosts['1'].totalLineItemHandlingCost).toBe(4.5);
209
+ expect(result).toBe(0);
210
+ expect(liCosts['1'].totalLineItemHandlingCost).toBe(4.5);
212
211
  });
213
- (0, vitest_1.it)('should treat an explicit 0 override as an override and suppress the global fee', () => {
212
+ it('should treat an explicit 0 override as an override and suppress the global fee', () => {
214
213
  const configs = createConfigs({
215
214
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
216
215
  });
217
216
  const lineItems = [createLineItem({ lineItemId: '1', quantity: 3, variantHandlingFee: 0 })];
218
217
  const liCosts = initLineItemCosts();
219
218
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
220
- (0, vitest_1.expect)(result).toBe(0);
221
- (0, vitest_1.expect)(liCosts['1'].totalLineItemHandlingCost).toBe(0);
219
+ expect(result).toBe(0);
220
+ expect(liCosts['1'].totalLineItemHandlingCost).toBe(0);
222
221
  });
223
- (0, vitest_1.it)('should apply the global fee only to line items without an override', () => {
222
+ it('should apply the global fee only to line items without an override', () => {
224
223
  const configs = createConfigs({
225
224
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
226
225
  });
@@ -230,363 +229,273 @@ const createConfigs = (overrides = {}) => ({
230
229
  ];
231
230
  const liCosts = initLineItemCosts(['1', '2']);
232
231
  const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
233
- (0, vitest_1.expect)(result).toBe(2);
234
- (0, vitest_1.expect)(liCosts['1'].totalLineItemHandlingCost).toBe(0);
235
- (0, vitest_1.expect)(liCosts['2'].totalLineItemHandlingCost).toBe(2);
232
+ expect(result).toBe(2);
233
+ expect(liCosts['1'].totalLineItemHandlingCost).toBe(0);
234
+ expect(liCosts['2'].totalLineItemHandlingCost).toBe(2);
236
235
  });
237
236
  });
238
- (0, vitest_1.describe)('calculateGatewayCost', () => {
239
- (0, vitest_1.it)('should return 0 when no gateway config', () => {
237
+ describe('calculateGatewayCost', () => {
238
+ it('should return 0 when no gateway config', () => {
240
239
  const configs = createConfigs();
241
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
240
+ expect(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
242
241
  });
243
- (0, vitest_1.it)('should return 0 when no matching gateway', () => {
242
+ it('should return 0 when no matching gateway', () => {
244
243
  const configs = createConfigs({
245
244
  gateway: {
246
- entries: [
247
- { gatewayName: 'paypal', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
248
- ],
245
+ entries: [{ gatewayName: 'paypal', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' }],
249
246
  },
250
247
  });
251
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
248
+ expect(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
252
249
  });
253
- (0, vitest_1.it)('should calculate flat + percent for matching gateway', () => {
250
+ it('should calculate flat + percent for matching gateway', () => {
254
251
  const configs = createConfigs({
255
252
  gateway: {
256
- entries: [
257
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
258
- ],
253
+ entries: [{ gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' }],
259
254
  },
260
255
  });
261
256
  const result = cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap);
262
- (0, vitest_1.expect)(result).toBeCloseTo(3.2);
257
+ expect(result).toBeCloseTo(3.20);
263
258
  });
264
- (0, vitest_1.it)('should be case-insensitive for gateway name', () => {
259
+ it('should be case-insensitive for gateway name', () => {
265
260
  const configs = createConfigs({
266
261
  gateway: {
267
- entries: [
268
- { gatewayName: 'Stripe', flatAmount: 1, percentRate: 0, currency: 'USD', createdAt: '', updatedAt: '' },
269
- ],
262
+ entries: [{ gatewayName: 'Stripe', flatAmount: 1, percentRate: 0, currency: 'USD', createdAt: '', updatedAt: '' }],
270
263
  },
271
264
  });
272
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(1);
265
+ expect(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(1);
273
266
  });
274
- (0, vitest_1.it)('should respect date range', () => {
267
+ it('should respect date range', () => {
275
268
  const configs = createConfigs({
276
269
  gateway: {
277
- entries: [
278
- {
279
- gatewayName: 'stripe',
280
- flatAmount: 1,
281
- percentRate: 0,
282
- currency: 'USD',
283
- effectiveFrom: '2025-01-01T00:00:00Z',
284
- createdAt: '',
285
- updatedAt: '',
286
- },
287
- ],
270
+ entries: [{
271
+ gatewayName: 'stripe', flatAmount: 1, percentRate: 0, currency: 'USD',
272
+ effectiveFrom: '2025-01-01T00:00:00Z', createdAt: '', updatedAt: '',
273
+ }],
288
274
  },
289
275
  });
290
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
276
+ expect(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
291
277
  });
292
- (0, vitest_1.it)('should convert flat amount from entry currency', () => {
278
+ it('should convert flat amount from entry currency', () => {
293
279
  const configs = createConfigs({
294
280
  gateway: {
295
- entries: [
296
- { gatewayName: 'stripe', flatAmount: 1, percentRate: 0, currency: 'EUR', createdAt: '', updatedAt: '' },
297
- ],
281
+ entries: [{ gatewayName: 'stripe', flatAmount: 1, percentRate: 0, currency: 'EUR', createdAt: '', updatedAt: '' }],
298
282
  },
299
283
  });
300
284
  const rates = { EUR: { USD: 1.1 } };
301
285
  const result = cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', rates);
302
- (0, vitest_1.expect)(result).toBeCloseTo(1.1);
286
+ expect(result).toBeCloseTo(1.1);
303
287
  });
304
- (0, vitest_1.it)('should pick first matching gateway when multiple entries exist', () => {
288
+ it('should pick first matching gateway when multiple entries exist', () => {
305
289
  const configs = createConfigs({
306
290
  gateway: {
307
291
  entries: [
308
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
309
- { gatewayName: 'stripe', flatAmount: 0.5, percentRate: 3.5, currency: 'USD', createdAt: '', updatedAt: '' },
292
+ { gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
293
+ { gatewayName: 'stripe', flatAmount: 0.50, percentRate: 3.5, currency: 'USD', createdAt: '', updatedAt: '' },
310
294
  ],
311
295
  },
312
296
  });
313
297
  const result = cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap);
314
- (0, vitest_1.expect)(result).toBeCloseTo(3.2);
298
+ expect(result).toBeCloseTo(3.20);
315
299
  });
316
- (0, vitest_1.it)('should respect effectiveTo date on gateway entry', () => {
300
+ it('should respect effectiveTo date on gateway entry', () => {
317
301
  const configs = createConfigs({
318
302
  gateway: {
319
- entries: [
320
- {
321
- gatewayName: 'stripe',
322
- flatAmount: 1,
323
- percentRate: 0,
324
- currency: 'USD',
325
- effectiveTo: '2024-01-01T00:00:00Z',
326
- createdAt: '',
327
- updatedAt: '',
328
- },
329
- ],
303
+ entries: [{
304
+ gatewayName: 'stripe', flatAmount: 1, percentRate: 0, currency: 'USD',
305
+ effectiveTo: '2024-01-01T00:00:00Z', createdAt: '', updatedAt: '',
306
+ }],
330
307
  },
331
308
  });
332
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
309
+ expect(cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
333
310
  });
334
- (0, vitest_1.it)('should match gateway when order has multiple gateways', () => {
311
+ it('should match gateway when order has multiple gateways', () => {
335
312
  const configs = createConfigs({
336
313
  gateway: {
337
- entries: [
338
- { gatewayName: 'paypal', flatAmount: 0.5, percentRate: 3.0, currency: 'USD', createdAt: '', updatedAt: '' },
339
- ],
314
+ entries: [{ gatewayName: 'paypal', flatAmount: 0.50, percentRate: 3.0, currency: 'USD', createdAt: '', updatedAt: '' }],
340
315
  },
341
316
  });
342
317
  const result = cost_calculator_service_1.CostCalculatorService.calculateGatewayCost(configs, ['stripe', 'paypal'], 100, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap);
343
- (0, vitest_1.expect)(result).toBeCloseTo(3.5);
318
+ expect(result).toBeCloseTo(3.50);
344
319
  });
345
320
  });
346
- (0, vitest_1.describe)('calculateShippingCost', () => {
347
- (0, vitest_1.it)('should return 0 when no shipping config', () => {
321
+ describe('calculateShippingCost', () => {
322
+ it('should return 0 when no shipping config', () => {
348
323
  const configs = createConfigs();
349
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 10, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
324
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 10, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
350
325
  });
351
- (0, vitest_1.it)('should return shopify amount for SHOPIFY_CHARGES method', () => {
326
+ it('should return shopify amount for SHOPIFY_CHARGES method', () => {
352
327
  const configs = createConfigs({
353
328
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.SHOPIFY_CHARGES, currency: 'USD' },
354
329
  });
355
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 15.5, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(15.5);
330
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 15.50, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(15.50);
356
331
  });
357
- (0, vitest_1.it)('should return fixed rate for FIXED_RATE method', () => {
332
+ it('should return fixed rate for FIXED_RATE method', () => {
358
333
  const configs = createConfigs({
359
334
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE, fixedRateAmount: 8.99, currency: 'USD' },
360
335
  });
361
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 10, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(8.99);
336
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 10, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(8.99);
362
337
  });
363
- (0, vitest_1.it)('should convert fixed rate from shipping currency', () => {
338
+ it('should convert fixed rate from shipping currency', () => {
364
339
  const configs = createConfigs({
365
340
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE, fixedRateAmount: 10, currency: 'GBP' },
366
341
  });
367
342
  const rates = { GBP: { USD: 1.27 } };
368
343
  const result = cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', rates);
369
- (0, vitest_1.expect)(result).toBeCloseTo(12.7);
344
+ expect(result).toBeCloseTo(12.7);
370
345
  });
371
- (0, vitest_1.it)('should match shipping profile by country', () => {
346
+ it('should match shipping profile by country', () => {
372
347
  const configs = createConfigs({
373
348
  shipping: {
374
349
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
375
350
  currency: 'USD',
376
351
  profiles: [
377
352
  {
378
- id: 'p1',
379
- name: 'US Profile',
380
- countries: ['US'],
381
- isDefault: false,
382
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
383
- flatAmount: 5,
384
- currency: 'USD',
385
- createdAt: '',
386
- updatedAt: '',
353
+ id: 'p1', name: 'US Profile', countries: ['US'], isDefault: false,
354
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 5, currency: 'USD',
355
+ createdAt: '', updatedAt: '',
387
356
  },
388
357
  {
389
- id: 'p2',
390
- name: 'Default',
391
- countries: [],
392
- isDefault: true,
393
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
394
- flatAmount: 15,
395
- currency: 'USD',
396
- createdAt: '',
397
- updatedAt: '',
358
+ id: 'p2', name: 'Default', countries: [], isDefault: true,
359
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 15, currency: 'USD',
360
+ createdAt: '', updatedAt: '',
398
361
  },
399
362
  ],
400
363
  },
401
364
  });
402
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(5);
365
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(5);
403
366
  });
404
- (0, vitest_1.it)('should fall back to default profile', () => {
367
+ it('should fall back to default profile', () => {
405
368
  const configs = createConfigs({
406
369
  shipping: {
407
370
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
408
371
  currency: 'USD',
409
372
  profiles: [
410
373
  {
411
- id: 'p1',
412
- name: 'US Profile',
413
- countries: ['US'],
414
- isDefault: false,
415
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
416
- flatAmount: 5,
417
- currency: 'USD',
418
- createdAt: '',
419
- updatedAt: '',
374
+ id: 'p1', name: 'US Profile', countries: ['US'], isDefault: false,
375
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 5, currency: 'USD',
376
+ createdAt: '', updatedAt: '',
420
377
  },
421
378
  {
422
- id: 'p2',
423
- name: 'Default',
424
- countries: [],
425
- isDefault: true,
426
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
427
- flatAmount: 15,
428
- currency: 'USD',
429
- createdAt: '',
430
- updatedAt: '',
379
+ id: 'p2', name: 'Default', countries: [], isDefault: true,
380
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 15, currency: 'USD',
381
+ createdAt: '', updatedAt: '',
431
382
  },
432
383
  ],
433
384
  },
434
385
  });
435
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'CA', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(15);
386
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'CA', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(15);
436
387
  });
437
- (0, vitest_1.it)('should handle weight-tiered profile', () => {
388
+ it('should handle weight-tiered profile', () => {
438
389
  const configs = createConfigs({
439
390
  shipping: {
440
391
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
441
392
  currency: 'USD',
442
- profiles: [
443
- {
444
- id: 'p1',
445
- name: 'Weight',
446
- countries: ['US'],
447
- isDefault: false,
448
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.WEIGHT_TIERED,
449
- currency: 'USD',
393
+ profiles: [{
394
+ id: 'p1', name: 'Weight', countries: ['US'], isDefault: false,
395
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.WEIGHT_TIERED, currency: 'USD',
450
396
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.GRAMS,
451
397
  weightTiers: [
452
398
  { weightMin: 0, weightMax: 500, flatAmount: 5 },
453
399
  { weightMin: 501, weightMax: null, flatAmount: 10 },
454
400
  ],
455
- createdAt: '',
456
- updatedAt: '',
457
- },
458
- ],
401
+ createdAt: '', updatedAt: '',
402
+ }],
459
403
  },
460
404
  });
461
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 300, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(5);
462
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 700, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(10);
405
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 300, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(5);
406
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 700, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(10);
463
407
  });
464
- (0, vitest_1.it)('should return 0 when no shipping profile matches (no country match, no default)', () => {
408
+ it('should return 0 when no shipping profile matches (no country match, no default)', () => {
465
409
  const configs = createConfigs({
466
410
  shipping: {
467
411
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
468
412
  currency: 'USD',
469
- profiles: [
470
- {
471
- id: 'p1',
472
- name: 'US Only',
473
- countries: ['US'],
474
- isDefault: false,
475
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
476
- flatAmount: 5,
477
- currency: 'USD',
478
- createdAt: '',
479
- updatedAt: '',
480
- },
481
- ],
413
+ profiles: [{
414
+ id: 'p1', name: 'US Only', countries: ['US'], isDefault: false,
415
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 5, currency: 'USD',
416
+ createdAt: '', updatedAt: '',
417
+ }],
482
418
  },
483
419
  });
484
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'CA', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
420
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'CA', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(0);
485
421
  });
486
- (0, vitest_1.it)('should skip expired shipping profile and fall back to default', () => {
422
+ it('should skip expired shipping profile and fall back to default', () => {
487
423
  const configs = createConfigs({
488
424
  shipping: {
489
425
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
490
426
  currency: 'USD',
491
427
  profiles: [
492
428
  {
493
- id: 'p1',
494
- name: 'US Expired',
495
- countries: ['US'],
496
- isDefault: false,
497
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
498
- flatAmount: 5,
499
- currency: 'USD',
429
+ id: 'p1', name: 'US Expired', countries: ['US'], isDefault: false,
430
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 5, currency: 'USD',
500
431
  effectiveTo: '2024-01-01T00:00:00Z',
501
- createdAt: '',
502
- updatedAt: '',
432
+ createdAt: '', updatedAt: '',
503
433
  },
504
434
  {
505
- id: 'p2',
506
- name: 'Default',
507
- countries: [],
508
- isDefault: true,
509
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
510
- flatAmount: 12,
511
- currency: 'USD',
512
- createdAt: '',
513
- updatedAt: '',
435
+ id: 'p2', name: 'Default', countries: [], isDefault: true,
436
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 12, currency: 'USD',
437
+ createdAt: '', updatedAt: '',
514
438
  },
515
439
  ],
516
440
  },
517
441
  });
518
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(12);
442
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(12);
519
443
  });
520
- (0, vitest_1.it)('should convert weight-tiered shipping profile amount from profile currency', () => {
444
+ it('should convert weight-tiered shipping profile amount from profile currency', () => {
521
445
  const configs = createConfigs({
522
446
  shipping: {
523
447
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
524
448
  currency: 'EUR',
525
- profiles: [
526
- {
527
- id: 'p1',
528
- name: 'EU Weight',
529
- countries: ['DE'],
530
- isDefault: false,
531
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.WEIGHT_TIERED,
532
- currency: 'EUR',
449
+ profiles: [{
450
+ id: 'p1', name: 'EU Weight', countries: ['DE'], isDefault: false,
451
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.WEIGHT_TIERED, currency: 'EUR',
533
452
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.GRAMS,
534
453
  weightTiers: [
535
454
  { weightMin: 0, weightMax: 500, flatAmount: 5 },
536
455
  { weightMin: 501, weightMax: null, flatAmount: 10 },
537
456
  ],
538
- createdAt: '',
539
- updatedAt: '',
540
- },
541
- ],
457
+ createdAt: '', updatedAt: '',
458
+ }],
542
459
  },
543
460
  });
544
461
  const rates = { EUR: { USD: 1.1 } };
545
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'DE', 300, '2024-06-15T10:00:00Z', 'USD', rates)).toBeCloseTo(5.5);
462
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'DE', 300, '2024-06-15T10:00:00Z', 'USD', rates)).toBeCloseTo(5.5);
546
463
  });
547
- (0, vitest_1.it)('should be case-insensitive for shipping profile country matching', () => {
464
+ it('should be case-insensitive for shipping profile country matching', () => {
548
465
  const configs = createConfigs({
549
466
  shipping: {
550
467
  method: at_tracking_event_types_1.SHIPPING_METHOD.SHIPPING_PROFILES,
551
468
  currency: 'USD',
552
- profiles: [
553
- {
554
- id: 'p1',
555
- name: 'US',
556
- countries: ['us'],
557
- isDefault: false,
558
- rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
559
- flatAmount: 7,
560
- currency: 'USD',
561
- createdAt: '',
562
- updatedAt: '',
563
- },
564
- ],
469
+ profiles: [{
470
+ id: 'p1', name: 'US', countries: ['us'], isDefault: false,
471
+ rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT, flatAmount: 7, currency: 'USD',
472
+ createdAt: '', updatedAt: '',
473
+ }],
565
474
  },
566
475
  });
567
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(7);
476
+ expect(cost_calculator_service_1.CostCalculatorService.calculateShippingCost(configs, 0, 'US', 500, '2024-06-15T10:00:00Z', 'USD', emptyRatesMap)).toBe(7);
568
477
  });
569
478
  });
570
- (0, vitest_1.describe)('calculateOtherCostEntry', () => {
479
+ describe('calculateOtherCostEntry', () => {
571
480
  const initLineItemCosts = () => ({
572
481
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
573
482
  });
574
- (0, vitest_1.it)('should calculate PER_ORDER flat amount as order-level cost', () => {
483
+ it('should calculate PER_ORDER flat amount as order-level cost', () => {
575
484
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 3 });
576
485
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext(), initLineItemCosts(), 'USD', emptyRatesMap);
577
- (0, vitest_1.expect)(result.orderLevel).toBe(3);
578
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
486
+ expect(result.orderLevel).toBe(3);
487
+ expect(result.lineItemLevel).toBe(0);
579
488
  });
580
- (0, vitest_1.it)('should calculate PER_LINE_ITEM with quantity as line-item-level cost', () => {
489
+ it('should calculate PER_LINE_ITEM with quantity as line-item-level cost', () => {
581
490
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 2 });
582
491
  const liCosts = initLineItemCosts();
583
492
  const context = createContext({ lineItems: [createLineItem({ quantity: 3 })] });
584
493
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
585
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
586
- (0, vitest_1.expect)(result.lineItemLevel).toBe(6);
587
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
494
+ expect(result.orderLevel).toBe(0);
495
+ expect(result.lineItemLevel).toBe(6);
496
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
588
497
  });
589
- (0, vitest_1.it)('should accumulate PER_LINE_ITEM costs across multiple line items as line-item-level', () => {
498
+ it('should accumulate PER_LINE_ITEM costs across multiple line items as line-item-level', () => {
590
499
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 2 });
591
500
  const liCosts = {
592
501
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
@@ -601,19 +510,19 @@ const createConfigs = (overrides = {}) => ({
601
510
  ],
602
511
  });
603
512
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
604
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
605
- (0, vitest_1.expect)(result.lineItemLevel).toBe(18);
606
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
607
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(2);
608
- (0, vitest_1.expect)(liCosts['3'].totalLineItemOtherCost).toBe(10);
513
+ expect(result.orderLevel).toBe(0);
514
+ expect(result.lineItemLevel).toBe(18);
515
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
516
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(2);
517
+ expect(liCosts['3'].totalLineItemOtherCost).toBe(10);
609
518
  });
610
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with flat amount as order-level cost', () => {
519
+ it('should calculate BY_ORDER_WEIGHT with flat amount as order-level cost', () => {
611
520
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, { flatAmount: 0.01 });
612
521
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', emptyRatesMap);
613
- (0, vitest_1.expect)(result.orderLevel).toBe(5);
614
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
522
+ expect(result.orderLevel).toBe(5);
523
+ expect(result.lineItemLevel).toBe(0);
615
524
  });
616
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with weight tiers in KILOGRAMS (totalWeight is grams from Shopify)', () => {
525
+ it('should calculate BY_ORDER_WEIGHT with weight tiers in KILOGRAMS (totalWeight is grams from Shopify)', () => {
617
526
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
618
527
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.KILOGRAMS,
619
528
  weightIntervals: [
@@ -622,11 +531,11 @@ const createConfigs = (overrides = {}) => ({
622
531
  { weightMin: 20.01, weightMax: null, flatAmount: 15 },
623
532
  ],
624
533
  });
625
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 2000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
626
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 10000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(8);
627
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 25000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(15);
534
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 2000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
535
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 10000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(8);
536
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 25000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(15);
628
537
  });
629
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with weight tiers in POUNDS', () => {
538
+ it('should calculate BY_ORDER_WEIGHT with weight tiers in POUNDS', () => {
630
539
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
631
540
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.POUNDS,
632
541
  weightIntervals: [
@@ -634,10 +543,10 @@ const createConfigs = (overrides = {}) => ({
634
543
  { weightMin: 10.01, weightMax: null, flatAmount: 12 },
635
544
  ],
636
545
  });
637
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 2000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
638
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 10000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(12);
546
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 2000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
547
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 10000 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(12);
639
548
  });
640
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with weight tiers in GRAMS (no conversion needed)', () => {
549
+ it('should calculate BY_ORDER_WEIGHT with weight tiers in GRAMS (no conversion needed)', () => {
641
550
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
642
551
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.GRAMS,
643
552
  weightIntervals: [
@@ -645,10 +554,10 @@ const createConfigs = (overrides = {}) => ({
645
554
  { weightMin: 1001, weightMax: null, flatAmount: 7 },
646
555
  ],
647
556
  });
648
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(2);
649
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 1500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(7);
557
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(2);
558
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 1500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(7);
650
559
  });
651
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with weight tiers and no weightUnit (treats as grams)', () => {
560
+ it('should calculate BY_ORDER_WEIGHT with weight tiers and no weightUnit (treats as grams)', () => {
652
561
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
653
562
  weightUnit: undefined,
654
563
  weightIntervals: [
@@ -656,35 +565,35 @@ const createConfigs = (overrides = {}) => ({
656
565
  { weightMin: 1001, weightMax: null, flatAmount: 9 },
657
566
  ],
658
567
  });
659
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(4);
568
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(4);
660
569
  });
661
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with flat amount and KILOGRAMS unit (converts weight before multiplying)', () => {
570
+ it('should calculate BY_ORDER_WEIGHT with flat amount and KILOGRAMS unit (converts weight before multiplying)', () => {
662
571
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
663
- flatAmount: 0.5,
572
+ flatAmount: 0.50,
664
573
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.KILOGRAMS,
665
574
  });
666
575
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 2000 }), initLineItemCosts(), 'USD', emptyRatesMap);
667
- (0, vitest_1.expect)(result.orderLevel).toBe(1);
668
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
576
+ expect(result.orderLevel).toBe(1);
577
+ expect(result.lineItemLevel).toBe(0);
669
578
  });
670
- (0, vitest_1.it)('should calculate BY_ORDER_WEIGHT with flat amount and POUNDS unit (converts weight before multiplying)', () => {
579
+ it('should calculate BY_ORDER_WEIGHT with flat amount and POUNDS unit (converts weight before multiplying)', () => {
671
580
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
672
- flatAmount: 2.0,
581
+ flatAmount: 2.00,
673
582
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.POUNDS,
674
583
  });
675
584
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 453.592 }), initLineItemCosts(), 'USD', emptyRatesMap);
676
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(2);
677
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
585
+ expect(result.orderLevel).toBeCloseTo(2);
586
+ expect(result.lineItemLevel).toBe(0);
678
587
  });
679
- (0, vitest_1.it)('should calculate BY_LINE_ITEM_QUANTITY with flat amount as line-item-level cost', () => {
680
- const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, { flatAmount: 0.5 });
588
+ it('should calculate BY_LINE_ITEM_QUANTITY with flat amount as line-item-level cost', () => {
589
+ const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, { flatAmount: 0.50 });
681
590
  const liCosts = initLineItemCosts();
682
591
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ lineItems: [createLineItem({ quantity: 10 })] }), liCosts, 'USD', emptyRatesMap);
683
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
684
- (0, vitest_1.expect)(result.lineItemLevel).toBe(5);
685
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(5);
592
+ expect(result.orderLevel).toBe(0);
593
+ expect(result.lineItemLevel).toBe(5);
594
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(5);
686
595
  });
687
- (0, vitest_1.it)('should calculate BY_LINE_ITEM_QUANTITY with tiers per line item quantity', () => {
596
+ it('should calculate BY_LINE_ITEM_QUANTITY with tiers per line item quantity', () => {
688
597
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
689
598
  quantityIntervals: [
690
599
  { quantityMin: 1, quantityMax: 5, flatAmount: 3 },
@@ -693,14 +602,14 @@ const createConfigs = (overrides = {}) => ({
693
602
  });
694
603
  const liCosts1 = initLineItemCosts();
695
604
  const result1 = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ lineItems: [createLineItem({ quantity: 3 })] }), liCosts1, 'USD', emptyRatesMap);
696
- (0, vitest_1.expect)(result1.lineItemLevel).toBe(3);
697
- (0, vitest_1.expect)(result1.orderLevel).toBe(0);
605
+ expect(result1.lineItemLevel).toBe(3);
606
+ expect(result1.orderLevel).toBe(0);
698
607
  const liCosts2 = initLineItemCosts();
699
608
  const result2 = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ lineItems: [createLineItem({ quantity: 10 })] }), liCosts2, 'USD', emptyRatesMap);
700
- (0, vitest_1.expect)(result2.lineItemLevel).toBe(2);
701
- (0, vitest_1.expect)(result2.orderLevel).toBe(0);
609
+ expect(result2.lineItemLevel).toBe(2);
610
+ expect(result2.orderLevel).toBe(0);
702
611
  });
703
- (0, vitest_1.it)('should calculate BY_LINE_ITEM_QUANTITY with multiple line items at different tiers', () => {
612
+ it('should calculate BY_LINE_ITEM_QUANTITY with multiple line items at different tiers', () => {
704
613
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
705
614
  quantityIntervals: [
706
615
  { quantityMin: 1, quantityMax: 5, flatAmount: 3 },
@@ -718,28 +627,28 @@ const createConfigs = (overrides = {}) => ({
718
627
  ],
719
628
  });
720
629
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
721
- (0, vitest_1.expect)(result.lineItemLevel).toBe(5);
722
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
723
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(3);
724
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(2);
630
+ expect(result.lineItemLevel).toBe(5);
631
+ expect(result.orderLevel).toBe(0);
632
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(3);
633
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(2);
725
634
  });
726
- (0, vitest_1.it)('should calculate BY_ORDER_QUANTITY with flat amount as order-level cost', () => {
727
- const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, { flatAmount: 0.5 });
635
+ it('should calculate BY_ORDER_QUANTITY with flat amount as order-level cost', () => {
636
+ const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, { flatAmount: 0.50 });
728
637
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', emptyRatesMap);
729
- (0, vitest_1.expect)(result.orderLevel).toBe(5);
730
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
638
+ expect(result.orderLevel).toBe(5);
639
+ expect(result.lineItemLevel).toBe(0);
731
640
  });
732
- (0, vitest_1.it)('should calculate BY_ORDER_QUANTITY with tiers as order-level cost', () => {
641
+ it('should calculate BY_ORDER_QUANTITY with tiers as order-level cost', () => {
733
642
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, {
734
643
  quantityIntervals: [
735
644
  { quantityMin: 1, quantityMax: 5, flatAmount: 3 },
736
645
  { quantityMin: 6, quantityMax: null, flatAmount: 2 },
737
646
  ],
738
647
  });
739
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 3 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
740
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(2);
648
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 3 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
649
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(2);
741
650
  });
742
- (0, vitest_1.it)('should calculate BY_ORDER_QUANTITY with multiple tiers correctly', () => {
651
+ it('should calculate BY_ORDER_QUANTITY with multiple tiers correctly', () => {
743
652
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, {
744
653
  quantityIntervals: [
745
654
  { quantityMin: 1, quantityMax: 10, flatAmount: 5 },
@@ -747,31 +656,33 @@ const createConfigs = (overrides = {}) => ({
747
656
  { quantityMin: 51, quantityMax: null, flatAmount: 1 },
748
657
  ],
749
658
  });
750
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 1 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
751
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
752
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 25 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
753
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 100 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(1);
659
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 1 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
660
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
661
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 25 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
662
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 100 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(1);
754
663
  });
755
- (0, vitest_1.it)('should return 0 for BY_ORDER_QUANTITY when quantity does not match any tier', () => {
664
+ it('should return 0 for BY_ORDER_QUANTITY when quantity does not match any tier', () => {
756
665
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, {
757
- quantityIntervals: [{ quantityMin: 5, quantityMax: 10, flatAmount: 3 }],
666
+ quantityIntervals: [
667
+ { quantityMin: 5, quantityMax: 10, flatAmount: 3 },
668
+ ],
758
669
  });
759
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 2 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
670
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 2 }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
760
671
  });
761
- (0, vitest_1.it)('should calculate BY_ORDER_QUANTITY with empty quantityIntervals using flat amount', () => {
672
+ it('should calculate BY_ORDER_QUANTITY with empty quantityIntervals using flat amount', () => {
762
673
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, { flatAmount: 2, quantityIntervals: [] });
763
674
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 7 }), initLineItemCosts(), 'USD', emptyRatesMap);
764
- (0, vitest_1.expect)(result.orderLevel).toBe(14);
675
+ expect(result.orderLevel).toBe(14);
765
676
  });
766
- (0, vitest_1.it)('should return 0 for BY_LINE_ITEM_QUANTITY when line item quantity is below all tiers', () => {
677
+ it('should return 0 for BY_LINE_ITEM_QUANTITY when line item quantity is below all tiers', () => {
767
678
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
768
679
  quantityIntervals: [{ quantityMin: 5, quantityMax: 10, flatAmount: 3 }],
769
680
  });
770
681
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ lineItems: [createLineItem({ quantity: 2 })] }), initLineItemCosts(), 'USD', emptyRatesMap);
771
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
772
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
682
+ expect(result.lineItemLevel).toBe(0);
683
+ expect(result.orderLevel).toBe(0);
773
684
  });
774
- (0, vitest_1.it)('should apply BY_LINE_ITEM_QUANTITY filters per line item, skipping non-matching ones', () => {
685
+ it('should apply BY_LINE_ITEM_QUANTITY filters per line item, skipping non-matching ones', () => {
775
686
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
776
687
  flatAmount: 1,
777
688
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
@@ -782,40 +693,32 @@ const createConfigs = (overrides = {}) => ({
782
693
  };
783
694
  const context = createContext({
784
695
  lineItems: [
785
- createLineItem({
786
- lineItemId: '1',
787
- quantity: 4,
788
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
789
- }),
790
- createLineItem({
791
- lineItemId: '2',
792
- quantity: 6,
793
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' },
794
- }),
696
+ createLineItem({ lineItemId: '1', quantity: 4, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } }),
697
+ createLineItem({ lineItemId: '2', quantity: 6, filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' } }),
795
698
  ],
796
699
  });
797
700
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
798
- (0, vitest_1.expect)(result.lineItemLevel).toBe(4);
799
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(4);
800
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
701
+ expect(result.lineItemLevel).toBe(4);
702
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(4);
703
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
801
704
  });
802
- (0, vitest_1.it)('should convert flat amount for BY_ORDER_QUANTITY', () => {
705
+ it('should convert flat amount for BY_ORDER_QUANTITY', () => {
803
706
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, { flatAmount: 5, currency: 'GBP' });
804
707
  const rates = { GBP: { USD: 1.27 } };
805
708
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 10 }), initLineItemCosts(), 'USD', rates);
806
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(63.5);
807
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
709
+ expect(result.orderLevel).toBeCloseTo(63.5);
710
+ expect(result.lineItemLevel).toBe(0);
808
711
  });
809
- (0, vitest_1.it)('should convert tier amount currency for BY_ORDER_QUANTITY', () => {
712
+ it('should convert tier amount currency for BY_ORDER_QUANTITY', () => {
810
713
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, {
811
714
  currency: 'EUR',
812
715
  quantityIntervals: [{ quantityMin: 1, quantityMax: null, flatAmount: 10 }],
813
716
  });
814
717
  const rates = { EUR: { USD: 1.1 } };
815
718
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalQuantity: 5 }), initLineItemCosts(), 'USD', rates);
816
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(11);
719
+ expect(result.orderLevel).toBeCloseTo(11);
817
720
  });
818
- (0, vitest_1.it)('should return 0 for BY_ORDER_QUANTITY when order filters do not match', () => {
721
+ it('should return 0 for BY_ORDER_QUANTITY when order filters do not match', () => {
819
722
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_QUANTITY, {
820
723
  flatAmount: 5,
821
724
  filters: { orderTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['wholesale'] } },
@@ -824,15 +727,14 @@ const createConfigs = (overrides = {}) => ({
824
727
  totalQuantity: 10,
825
728
  orderFilterContext: { tags: ['retail'], paymentGateways: [], shippingTitles: [] },
826
729
  });
827
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
828
- .orderLevel).toBe(0);
730
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
829
731
  });
830
- (0, vitest_1.it)('should calculate PER_REFUND_ORDER when hasRefund as order-level cost', () => {
732
+ it('should calculate PER_REFUND_ORDER when hasRefund as order-level cost', () => {
831
733
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER, { flatAmount: 5 });
832
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ hasRefund: true }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
833
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ hasRefund: false }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
734
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ hasRefund: true }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
735
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ hasRefund: false }), initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
834
736
  });
835
- (0, vitest_1.it)('should calculate PER_REFUND_LINE_ITEM as line-item-level cost', () => {
737
+ it('should calculate PER_REFUND_LINE_ITEM as line-item-level cost', () => {
836
738
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, { flatAmount: 2 });
837
739
  const liCosts = initLineItemCosts();
838
740
  const context = createContext({
@@ -840,17 +742,17 @@ const createConfigs = (overrides = {}) => ({
840
742
  lineItems: [createLineItem({ refundedQuantity: 2 })],
841
743
  });
842
744
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
843
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
844
- (0, vitest_1.expect)(result.lineItemLevel).toBe(4);
845
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(4);
745
+ expect(result.orderLevel).toBe(0);
746
+ expect(result.lineItemLevel).toBe(4);
747
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(4);
846
748
  });
847
- (0, vitest_1.it)('should skip PER_REFUND_LINE_ITEM when refundedQuantity is 0', () => {
749
+ it('should skip PER_REFUND_LINE_ITEM when refundedQuantity is 0', () => {
848
750
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, { flatAmount: 2 });
849
751
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext(), initLineItemCosts(), 'USD', emptyRatesMap);
850
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
851
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
752
+ expect(result.orderLevel).toBe(0);
753
+ expect(result.lineItemLevel).toBe(0);
852
754
  });
853
- (0, vitest_1.it)('should only count refunded line items for PER_REFUND_LINE_ITEM with mixed refund/non-refund', () => {
755
+ it('should only count refunded line items for PER_REFUND_LINE_ITEM with mixed refund/non-refund', () => {
854
756
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, { flatAmount: 3 });
855
757
  const liCosts = {
856
758
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
@@ -866,70 +768,70 @@ const createConfigs = (overrides = {}) => ({
866
768
  ],
867
769
  });
868
770
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
869
- (0, vitest_1.expect)(result.lineItemLevel).toBe(9);
870
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
871
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
872
- (0, vitest_1.expect)(liCosts['3'].totalLineItemOtherCost).toBe(3);
771
+ expect(result.lineItemLevel).toBe(9);
772
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
773
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
774
+ expect(liCosts['3'].totalLineItemOtherCost).toBe(3);
873
775
  });
874
- (0, vitest_1.it)('should calculate PCT_COGS as order-level cost', () => {
776
+ it('should calculate PCT_COGS as order-level cost', () => {
875
777
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { percentRate: 10 });
876
778
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalProductCost: 50 }), initLineItemCosts(), 'USD', emptyRatesMap);
877
- (0, vitest_1.expect)(result.orderLevel).toBe(5);
779
+ expect(result.orderLevel).toBe(5);
878
780
  });
879
- (0, vitest_1.it)('should calculate PCT_SHIPPING as order-level cost', () => {
781
+ it('should calculate PCT_SHIPPING as order-level cost', () => {
880
782
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING, { percentRate: 5 });
881
783
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalShipping: 20 }), initLineItemCosts(), 'USD', emptyRatesMap);
882
- (0, vitest_1.expect)(result.orderLevel).toBe(1);
784
+ expect(result.orderLevel).toBe(1);
883
785
  });
884
- (0, vitest_1.it)('should calculate PCT_TOTAL_SALES as order-level cost', () => {
786
+ it('should calculate PCT_TOTAL_SALES as order-level cost', () => {
885
787
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 2 });
886
788
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalPrice: 200 }), initLineItemCosts(), 'USD', emptyRatesMap);
887
- (0, vitest_1.expect)(result.orderLevel).toBe(4);
789
+ expect(result.orderLevel).toBe(4);
888
790
  });
889
- (0, vitest_1.it)('should calculate PCT_GROSS_SALES as order-level cost', () => {
791
+ it('should calculate PCT_GROSS_SALES as order-level cost', () => {
890
792
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, { percentRate: 3 });
891
793
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ grossSalePrice: 150 }), initLineItemCosts(), 'USD', emptyRatesMap);
892
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(4.5);
794
+ expect(result.orderLevel).toBeCloseTo(4.5);
893
795
  });
894
- (0, vitest_1.it)('should calculate PCT_NET_SALES as order-level cost', () => {
796
+ it('should calculate PCT_NET_SALES as order-level cost', () => {
895
797
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_NET_SALES, { percentRate: 4 });
896
798
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ netSalePrice: 80 }), initLineItemCosts(), 'USD', emptyRatesMap);
897
- (0, vitest_1.expect)(result.orderLevel).toBe(3.2);
799
+ expect(result.orderLevel).toBe(3.2);
898
800
  });
899
- (0, vitest_1.it)('should return 0 for PCT_COGS when totalProductCost is 0', () => {
801
+ it('should return 0 for PCT_COGS when totalProductCost is 0', () => {
900
802
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { percentRate: 10 });
901
803
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalProductCost: 0 }), initLineItemCosts(), 'USD', emptyRatesMap);
902
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
804
+ expect(result.orderLevel).toBe(0);
903
805
  });
904
- (0, vitest_1.it)('should return 0 for PCT_SHIPPING when totalShipping is 0', () => {
806
+ it('should return 0 for PCT_SHIPPING when totalShipping is 0', () => {
905
807
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING, { percentRate: 5 });
906
808
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalShipping: 0 }), initLineItemCosts(), 'USD', emptyRatesMap);
907
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
809
+ expect(result.orderLevel).toBe(0);
908
810
  });
909
- (0, vitest_1.it)('should return 0 for PER_ORDER when flatAmount is 0', () => {
811
+ it('should return 0 for PER_ORDER when flatAmount is 0', () => {
910
812
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 0 });
911
813
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext(), initLineItemCosts(), 'USD', emptyRatesMap);
912
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
814
+ expect(result.orderLevel).toBe(0);
913
815
  });
914
- (0, vitest_1.it)('should return 0 for PER_LINE_ITEM when quantity is 0', () => {
816
+ it('should return 0 for PER_LINE_ITEM when quantity is 0', () => {
915
817
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 2 });
916
818
  const context = createContext({ lineItems: [createLineItem({ quantity: 0 })] });
917
819
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap);
918
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
820
+ expect(result.lineItemLevel).toBe(0);
919
821
  });
920
- (0, vitest_1.it)('should return 0 for unknown entry type', () => {
822
+ it('should return 0 for unknown entry type', () => {
921
823
  const entry = createEntry('UNKNOWN_TYPE', { flatAmount: 5 });
922
824
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext(), initLineItemCosts(), 'USD', emptyRatesMap);
923
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
924
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
825
+ expect(result.orderLevel).toBe(0);
826
+ expect(result.lineItemLevel).toBe(0);
925
827
  });
926
- (0, vitest_1.it)('should convert flat amount for BY_ORDER_WEIGHT (flat * weight mode)', () => {
828
+ it('should convert flat amount for BY_ORDER_WEIGHT (flat * weight mode)', () => {
927
829
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, { flatAmount: 2, currency: 'EUR' });
928
830
  const rates = { EUR: { USD: 1.1 } };
929
831
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 500 }), initLineItemCosts(), 'USD', rates);
930
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(1100);
832
+ expect(result.orderLevel).toBeCloseTo(1100);
931
833
  });
932
- (0, vitest_1.it)('should convert tier amount for BY_ORDER_WEIGHT with tiers + currency', () => {
834
+ it('should convert tier amount for BY_ORDER_WEIGHT with tiers + currency', () => {
933
835
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
934
836
  currency: 'EUR',
935
837
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.GRAMS,
@@ -939,34 +841,32 @@ const createConfigs = (overrides = {}) => ({
939
841
  ],
940
842
  });
941
843
  const rates = { EUR: { USD: 1.1 } };
942
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 300 }), initLineItemCosts(), 'USD', rates).orderLevel).toBeCloseTo(5.5);
844
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ totalWeight: 300 }), initLineItemCosts(), 'USD', rates).orderLevel).toBeCloseTo(5.5);
943
845
  });
944
- (0, vitest_1.it)('should convert flat amount for BY_LINE_ITEM_QUANTITY', () => {
846
+ it('should convert flat amount for BY_LINE_ITEM_QUANTITY', () => {
945
847
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, { flatAmount: 5, currency: 'GBP' });
946
848
  const rates = { GBP: { USD: 1.27 } };
947
849
  const liCosts = initLineItemCosts();
948
850
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext({ lineItems: [createLineItem({ quantity: 10 })] }), liCosts, 'USD', rates);
949
- (0, vitest_1.expect)(result.lineItemLevel).toBeCloseTo(63.5);
950
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
851
+ expect(result.lineItemLevel).toBeCloseTo(63.5);
852
+ expect(result.orderLevel).toBe(0);
951
853
  });
952
- (0, vitest_1.it)('should return 0 when order-level filters do not match', () => {
854
+ it('should return 0 when order-level filters do not match', () => {
953
855
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
954
856
  flatAmount: 5,
955
857
  filters: { countries: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['US'] } },
956
858
  });
957
- const context = createContext({
958
- orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'CA' },
959
- });
859
+ const context = createContext({ orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'CA' } });
960
860
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap);
961
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
861
+ expect(result.orderLevel).toBe(0);
962
862
  });
963
- (0, vitest_1.it)('should convert flat amount from entry currency', () => {
863
+ it('should convert flat amount from entry currency', () => {
964
864
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, currency: 'EUR' });
965
865
  const rates = { EUR: { USD: 1.1 } };
966
866
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, createContext(), initLineItemCosts(), 'USD', rates);
967
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(11);
867
+ expect(result.orderLevel).toBeCloseTo(11);
968
868
  });
969
- (0, vitest_1.it)('should return 0 for PER_ORDER when product filter does not match any line item', () => {
869
+ it('should return 0 for PER_ORDER when product filter does not match any line item', () => {
970
870
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
971
871
  flatAmount: 5,
972
872
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P999'] } },
@@ -974,10 +874,9 @@ const createConfigs = (overrides = {}) => ({
974
874
  const context = createContext({
975
875
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [] } })],
976
876
  });
977
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
978
- .orderLevel).toBe(0);
877
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
979
878
  });
980
- (0, vitest_1.it)('should apply PER_ORDER when product filter matches a line item', () => {
879
+ it('should apply PER_ORDER when product filter matches a line item', () => {
981
880
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
982
881
  flatAmount: 5,
983
882
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P100'] } },
@@ -985,33 +884,26 @@ const createConfigs = (overrides = {}) => ({
985
884
  const context = createContext({
986
885
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [] } })],
987
886
  });
988
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
989
- .orderLevel).toBe(5);
887
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
990
888
  });
991
- (0, vitest_1.it)('should apply PER_ORDER when at least one of multiple line items matches product filter', () => {
889
+ it('should apply PER_ORDER when at least one of multiple line items matches product filter', () => {
992
890
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
993
891
  flatAmount: 5,
994
892
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
995
893
  });
996
894
  const context = createContext({
997
895
  lineItems: [
998
- createLineItem({
999
- lineItemId: '1',
1000
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' },
1001
- }),
1002
- createLineItem({
1003
- lineItemId: '2',
1004
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike' },
1005
- }),
896
+ createLineItem({ lineItemId: '1', filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
897
+ createLineItem({ lineItemId: '2', filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike' } }),
1006
898
  ],
1007
899
  });
1008
900
  const liCosts = {
1009
901
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1010
902
  '2': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1011
903
  };
1012
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(5);
904
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(5);
1013
905
  });
1014
- (0, vitest_1.it)('should return 0 for BY_ORDER_WEIGHT when productTags filter does not match any line item', () => {
906
+ it('should return 0 for BY_ORDER_WEIGHT when productTags filter does not match any line item', () => {
1015
907
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
1016
908
  flatAmount: 0.01,
1017
909
  filters: { productTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['fragile'] } },
@@ -1020,10 +912,9 @@ const createConfigs = (overrides = {}) => ({
1020
912
  totalWeight: 500,
1021
913
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: ['lightweight'] } })],
1022
914
  });
1023
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1024
- .orderLevel).toBe(0);
915
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1025
916
  });
1026
- (0, vitest_1.it)('should apply BY_ORDER_WEIGHT when productTags filter matches a line item', () => {
917
+ it('should apply BY_ORDER_WEIGHT when productTags filter matches a line item', () => {
1027
918
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
1028
919
  flatAmount: 0.01,
1029
920
  filters: { productTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['fragile'] } },
@@ -1032,84 +923,62 @@ const createConfigs = (overrides = {}) => ({
1032
923
  totalWeight: 500,
1033
924
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: ['fragile'] } })],
1034
925
  });
1035
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1036
- .orderLevel).toBe(5);
926
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1037
927
  });
1038
- (0, vitest_1.it)('should return 0 for BY_LINE_ITEM_QUANTITY when productVendors filter does not match', () => {
928
+ it('should return 0 for BY_LINE_ITEM_QUANTITY when productVendors filter does not match', () => {
1039
929
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
1040
930
  flatAmount: 0.5,
1041
931
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1042
932
  });
1043
933
  const context = createContext({
1044
- lineItems: [
1045
- createLineItem({
1046
- quantity: 10,
1047
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' },
1048
- }),
1049
- ],
934
+ lineItems: [createLineItem({ quantity: 10, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } })],
1050
935
  });
1051
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1052
- .lineItemLevel).toBe(0);
936
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(0);
1053
937
  });
1054
- (0, vitest_1.it)('should apply BY_LINE_ITEM_QUANTITY when productVendors filter matches', () => {
938
+ it('should apply BY_LINE_ITEM_QUANTITY when productVendors filter matches', () => {
1055
939
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
1056
940
  flatAmount: 0.5,
1057
941
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1058
942
  });
1059
943
  const context = createContext({
1060
- lineItems: [
1061
- createLineItem({
1062
- quantity: 10,
1063
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
1064
- }),
1065
- ],
944
+ lineItems: [createLineItem({ quantity: 10, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1066
945
  });
1067
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1068
- .lineItemLevel).toBe(5);
946
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(5);
1069
947
  });
1070
- (0, vitest_1.it)('should return 0 for PCT_GROSS_SALES when productTypes filter does not match', () => {
948
+ it('should return 0 for PCT_GROSS_SALES when productTypes filter does not match', () => {
1071
949
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
1072
950
  percentRate: 3,
1073
951
  filters: { productTypes: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Electronics'] } },
1074
952
  });
1075
953
  const context = createContext({
1076
954
  grossSalePrice: 150,
1077
- lineItems: [
1078
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], productType: 'Clothing' } }),
1079
- ],
955
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], productType: 'Clothing' } })],
1080
956
  });
1081
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1082
- .orderLevel).toBe(0);
957
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1083
958
  });
1084
- (0, vitest_1.it)('should apply PCT_GROSS_SALES when productTypes filter matches', () => {
959
+ it('should apply PCT_GROSS_SALES when productTypes filter matches', () => {
1085
960
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
1086
961
  percentRate: 3,
1087
962
  filters: { productTypes: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Electronics'] } },
1088
963
  });
1089
964
  const context = createContext({
1090
965
  grossSalePrice: 150,
1091
- lineItems: [
1092
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], productType: 'Electronics' } }),
1093
- ],
966
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], productType: 'Electronics' } })],
1094
967
  });
1095
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1096
- .orderLevel).toBeCloseTo(4.5);
968
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBeCloseTo(4.5);
1097
969
  });
1098
- (0, vitest_1.it)('should return 0 for PCT_NET_SALES when productCategories filter does not match', () => {
970
+ it('should return 0 for PCT_NET_SALES when productCategories filter does not match', () => {
1099
971
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_NET_SALES, {
1100
972
  percentRate: 5,
1101
973
  filters: { productCategories: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Home > Kitchen'] } },
1102
974
  });
1103
975
  const context = createContext({
1104
976
  netSalePrice: 80,
1105
- lineItems: [
1106
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Sports' } }),
1107
- ],
977
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Sports' } })],
1108
978
  });
1109
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1110
- .orderLevel).toBe(0);
979
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1111
980
  });
1112
- (0, vitest_1.it)('should return 0 for PCT_TOTAL_SALES when products filter does not match', () => {
981
+ it('should return 0 for PCT_TOTAL_SALES when products filter does not match', () => {
1113
982
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, {
1114
983
  percentRate: 2,
1115
984
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P999'] } },
@@ -1118,24 +987,20 @@ const createConfigs = (overrides = {}) => ({
1118
987
  totalPrice: 200,
1119
988
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [] } })],
1120
989
  });
1121
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1122
- .orderLevel).toBe(0);
990
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1123
991
  });
1124
- (0, vitest_1.it)('should return 0 for PCT_COGS when product filter does not match', () => {
992
+ it('should return 0 for PCT_COGS when product filter does not match', () => {
1125
993
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, {
1126
994
  percentRate: 10,
1127
995
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Apple'] } },
1128
996
  });
1129
997
  const context = createContext({
1130
998
  totalProductCost: 50,
1131
- lineItems: [
1132
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Samsung' } }),
1133
- ],
999
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Samsung' } })],
1134
1000
  });
1135
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1136
- .orderLevel).toBe(0);
1001
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1137
1002
  });
1138
- (0, vitest_1.it)('should return 0 for PCT_SHIPPING when product filter does not match', () => {
1003
+ it('should return 0 for PCT_SHIPPING when product filter does not match', () => {
1139
1004
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING, {
1140
1005
  percentRate: 5,
1141
1006
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P500'] } },
@@ -1144,24 +1009,20 @@ const createConfigs = (overrides = {}) => ({
1144
1009
  totalShipping: 20,
1145
1010
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [] } })],
1146
1011
  });
1147
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1148
- .orderLevel).toBe(0);
1012
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1149
1013
  });
1150
- (0, vitest_1.it)('should return 0 for PER_REFUND_ORDER when product filter does not match', () => {
1014
+ it('should return 0 for PER_REFUND_ORDER when product filter does not match', () => {
1151
1015
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER, {
1152
1016
  flatAmount: 5,
1153
1017
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1154
1018
  });
1155
1019
  const context = createContext({
1156
1020
  hasRefund: true,
1157
- lineItems: [
1158
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
1159
- ],
1021
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } })],
1160
1022
  });
1161
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1162
- .orderLevel).toBe(0);
1023
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1163
1024
  });
1164
- (0, vitest_1.it)('should apply PER_REFUND_ORDER when product filter matches and hasRefund', () => {
1025
+ it('should apply PER_REFUND_ORDER when product filter matches and hasRefund', () => {
1165
1026
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER, {
1166
1027
  flatAmount: 5,
1167
1028
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
@@ -1170,10 +1031,9 @@ const createConfigs = (overrides = {}) => ({
1170
1031
  hasRefund: true,
1171
1032
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1172
1033
  });
1173
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1174
- .orderLevel).toBe(5);
1034
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1175
1035
  });
1176
- (0, vitest_1.it)('should only apply PER_LINE_ITEM cost to line items matching product filter', () => {
1036
+ it('should only apply PER_LINE_ITEM cost to line items matching product filter', () => {
1177
1037
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1178
1038
  flatAmount: 2,
1179
1039
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
@@ -1184,41 +1044,28 @@ const createConfigs = (overrides = {}) => ({
1184
1044
  };
1185
1045
  const context = createContext({
1186
1046
  lineItems: [
1187
- createLineItem({
1188
- lineItemId: '1',
1189
- quantity: 3,
1190
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
1191
- }),
1192
- createLineItem({
1193
- lineItemId: '2',
1194
- quantity: 2,
1195
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' },
1196
- }),
1047
+ createLineItem({ lineItemId: '1', quantity: 3, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } }),
1048
+ createLineItem({ lineItemId: '2', quantity: 2, filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' } }),
1197
1049
  ],
1198
1050
  });
1199
1051
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1200
- (0, vitest_1.expect)(result.lineItemLevel).toBe(6);
1201
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
1202
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
1052
+ expect(result.lineItemLevel).toBe(6);
1053
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
1054
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
1203
1055
  });
1204
- (0, vitest_1.it)('should return 0 for PER_LINE_ITEM when no line items match product filter', () => {
1056
+ it('should return 0 for PER_LINE_ITEM when no line items match product filter', () => {
1205
1057
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1206
1058
  flatAmount: 2,
1207
1059
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1208
1060
  });
1209
1061
  const context = createContext({
1210
1062
  lineItems: [
1211
- createLineItem({
1212
- lineItemId: '1',
1213
- quantity: 3,
1214
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' },
1215
- }),
1063
+ createLineItem({ lineItemId: '1', quantity: 3, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
1216
1064
  ],
1217
1065
  });
1218
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1219
- .lineItemLevel).toBe(0);
1066
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(0);
1220
1067
  });
1221
- (0, vitest_1.it)('should only apply PER_REFUND_LINE_ITEM cost to refunded line items matching product filter', () => {
1068
+ it('should only apply PER_REFUND_LINE_ITEM cost to refunded line items matching product filter', () => {
1222
1069
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, {
1223
1070
  flatAmount: 3,
1224
1071
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P1'] } },
@@ -1230,24 +1077,16 @@ const createConfigs = (overrides = {}) => ({
1230
1077
  const context = createContext({
1231
1078
  hasRefund: true,
1232
1079
  lineItems: [
1233
- createLineItem({
1234
- lineItemId: '1',
1235
- refundedQuantity: 2,
1236
- filterContext: { productId: 'P1', variantId: 'V1', tags: [] },
1237
- }),
1238
- createLineItem({
1239
- lineItemId: '2',
1240
- refundedQuantity: 1,
1241
- filterContext: { productId: 'P2', variantId: 'V2', tags: [] },
1242
- }),
1080
+ createLineItem({ lineItemId: '1', refundedQuantity: 2, filterContext: { productId: 'P1', variantId: 'V1', tags: [] } }),
1081
+ createLineItem({ lineItemId: '2', refundedQuantity: 1, filterContext: { productId: 'P2', variantId: 'V2', tags: [] } }),
1243
1082
  ],
1244
1083
  });
1245
1084
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1246
- (0, vitest_1.expect)(result.lineItemLevel).toBe(6);
1247
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
1248
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
1085
+ expect(result.lineItemLevel).toBe(6);
1086
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
1087
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
1249
1088
  });
1250
- (0, vitest_1.it)('should check both order and product filters for PER_ORDER (both must pass)', () => {
1089
+ it('should check both order and product filters for PER_ORDER (both must pass)', () => {
1251
1090
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1252
1091
  flatAmount: 5,
1253
1092
  filters: {
@@ -1259,22 +1098,19 @@ const createConfigs = (overrides = {}) => ({
1259
1098
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'US' },
1260
1099
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1261
1100
  });
1262
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextPass, initLineItemCosts(), 'USD', emptyRatesMap)
1263
- .orderLevel).toBe(5);
1101
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextPass, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1264
1102
  const contextProductFail = createContext({
1265
1103
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'US' },
1266
- lineItems: [
1267
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
1268
- ],
1104
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } })],
1269
1105
  });
1270
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextProductFail, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1106
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextProductFail, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1271
1107
  const contextOrderFail = createContext({
1272
1108
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'CA' },
1273
1109
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1274
1110
  });
1275
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextOrderFail, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1111
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, contextOrderFail, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1276
1112
  });
1277
- (0, vitest_1.it)('should return 0 for BY_ORDER_WEIGHT when order-level country filter does not match', () => {
1113
+ it('should return 0 for BY_ORDER_WEIGHT when order-level country filter does not match', () => {
1278
1114
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
1279
1115
  flatAmount: 0.01,
1280
1116
  filters: { countries: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['US'] } },
@@ -1283,10 +1119,9 @@ const createConfigs = (overrides = {}) => ({
1283
1119
  totalWeight: 500,
1284
1120
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'CA' },
1285
1121
  });
1286
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1287
- .orderLevel).toBe(0);
1122
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1288
1123
  });
1289
- (0, vitest_1.it)('should return 0 for BY_LINE_ITEM_QUANTITY when orderTags filter does not match', () => {
1124
+ it('should return 0 for BY_LINE_ITEM_QUANTITY when orderTags filter does not match', () => {
1290
1125
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
1291
1126
  flatAmount: 0.5,
1292
1127
  filters: { orderTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['wholesale'] } },
@@ -1295,10 +1130,9 @@ const createConfigs = (overrides = {}) => ({
1295
1130
  lineItems: [createLineItem({ quantity: 10 })],
1296
1131
  orderFilterContext: { tags: ['retail'], paymentGateways: [], shippingTitles: [] },
1297
1132
  });
1298
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1299
- .lineItemLevel).toBe(0);
1133
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(0);
1300
1134
  });
1301
- (0, vitest_1.it)('should return 0 for PCT_GROSS_SALES when orderPaymentGateways filter does not match', () => {
1135
+ it('should return 0 for PCT_GROSS_SALES when orderPaymentGateways filter does not match', () => {
1302
1136
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
1303
1137
  percentRate: 3,
1304
1138
  filters: { orderPaymentGateways: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['stripe'] } },
@@ -1307,10 +1141,9 @@ const createConfigs = (overrides = {}) => ({
1307
1141
  grossSalePrice: 150,
1308
1142
  orderFilterContext: { tags: [], paymentGateways: ['paypal'], shippingTitles: [] },
1309
1143
  });
1310
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1311
- .orderLevel).toBe(0);
1144
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1312
1145
  });
1313
- (0, vitest_1.it)('should apply PCT_GROSS_SALES when orderPaymentGateways filter matches', () => {
1146
+ it('should apply PCT_GROSS_SALES when orderPaymentGateways filter matches', () => {
1314
1147
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
1315
1148
  percentRate: 3,
1316
1149
  filters: { orderPaymentGateways: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['stripe'] } },
@@ -1319,10 +1152,9 @@ const createConfigs = (overrides = {}) => ({
1319
1152
  grossSalePrice: 150,
1320
1153
  orderFilterContext: { tags: [], paymentGateways: ['stripe'], shippingTitles: [] },
1321
1154
  });
1322
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1323
- .orderLevel).toBeCloseTo(4.5);
1155
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBeCloseTo(4.5);
1324
1156
  });
1325
- (0, vitest_1.it)('should return 0 for PER_LINE_ITEM when orderShippingTitles filter does not match', () => {
1157
+ it('should return 0 for PER_LINE_ITEM when orderShippingTitles filter does not match', () => {
1326
1158
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1327
1159
  flatAmount: 2,
1328
1160
  filters: { orderShippingTitles: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Express'] } },
@@ -1331,10 +1163,9 @@ const createConfigs = (overrides = {}) => ({
1331
1163
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: ['Standard'] },
1332
1164
  lineItems: [createLineItem({ quantity: 3 })],
1333
1165
  });
1334
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1335
- .lineItemLevel).toBe(0);
1166
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(0);
1336
1167
  });
1337
- (0, vitest_1.it)('should return 0 for PCT_COGS when orderSourceNames filter does not match', () => {
1168
+ it('should return 0 for PCT_COGS when orderSourceNames filter does not match', () => {
1338
1169
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, {
1339
1170
  percentRate: 10,
1340
1171
  filters: { orderSourceNames: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['web'] } },
@@ -1343,52 +1174,41 @@ const createConfigs = (overrides = {}) => ({
1343
1174
  totalProductCost: 50,
1344
1175
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], sourceName: 'pos' },
1345
1176
  });
1346
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1347
- .orderLevel).toBe(0);
1177
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1348
1178
  });
1349
- (0, vitest_1.it)('should apply PER_ORDER when EXCLUDE product filter does not match any line item vendor', () => {
1179
+ it('should apply PER_ORDER when EXCLUDE product filter does not match any line item vendor', () => {
1350
1180
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1351
1181
  flatAmount: 5,
1352
1182
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['Nike'] } },
1353
1183
  });
1354
1184
  const context = createContext({
1355
- lineItems: [
1356
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
1357
- ],
1185
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } })],
1358
1186
  });
1359
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1360
- .orderLevel).toBe(5);
1187
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1361
1188
  });
1362
- (0, vitest_1.it)('should return 0 for PER_ORDER when EXCLUDE product filter matches all line items', () => {
1189
+ it('should return 0 for PER_ORDER when EXCLUDE product filter matches all line items', () => {
1363
1190
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1364
1191
  flatAmount: 5,
1365
1192
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['Nike'] } },
1366
1193
  });
1367
1194
  const context = createContext({
1368
1195
  lineItems: [
1369
- createLineItem({
1370
- lineItemId: '1',
1371
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
1372
- }),
1196
+ createLineItem({ lineItemId: '1', filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } }),
1373
1197
  ],
1374
1198
  });
1375
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1376
- .orderLevel).toBe(0);
1199
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1377
1200
  });
1378
- (0, vitest_1.it)('should apply PER_ORDER when product filter mode is ALL', () => {
1201
+ it('should apply PER_ORDER when product filter mode is ALL', () => {
1379
1202
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1380
1203
  flatAmount: 5,
1381
1204
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.ALL, values: [] } },
1382
1205
  });
1383
1206
  const context = createContext({
1384
- lineItems: [
1385
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'anything' } }),
1386
- ],
1207
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'anything' } })],
1387
1208
  });
1388
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1389
- .orderLevel).toBe(5);
1209
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1390
1210
  });
1391
- (0, vitest_1.it)('should return 0 for PER_ORDER when multiple product filters set and no single line item satisfies all', () => {
1211
+ it('should return 0 for PER_ORDER when multiple product filters set and no single line item satisfies all', () => {
1392
1212
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1393
1213
  flatAmount: 5,
1394
1214
  filters: {
@@ -1398,23 +1218,17 @@ const createConfigs = (overrides = {}) => ({
1398
1218
  });
1399
1219
  const context = createContext({
1400
1220
  lineItems: [
1401
- createLineItem({
1402
- lineItemId: '1',
1403
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike', productType: 'Hats' },
1404
- }),
1405
- createLineItem({
1406
- lineItemId: '2',
1407
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas', productType: 'Shoes' },
1408
- }),
1221
+ createLineItem({ lineItemId: '1', filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike', productType: 'Hats' } }),
1222
+ createLineItem({ lineItemId: '2', filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas', productType: 'Shoes' } }),
1409
1223
  ],
1410
1224
  });
1411
1225
  const liCosts = {
1412
1226
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1413
1227
  '2': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1414
1228
  };
1415
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(0);
1229
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(0);
1416
1230
  });
1417
- (0, vitest_1.it)('should apply PER_ORDER when one line item satisfies all product filters', () => {
1231
+ it('should apply PER_ORDER when one line item satisfies all product filters', () => {
1418
1232
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1419
1233
  flatAmount: 5,
1420
1234
  filters: {
@@ -1424,23 +1238,17 @@ const createConfigs = (overrides = {}) => ({
1424
1238
  });
1425
1239
  const context = createContext({
1426
1240
  lineItems: [
1427
- createLineItem({
1428
- lineItemId: '1',
1429
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas', productType: 'Hats' },
1430
- }),
1431
- createLineItem({
1432
- lineItemId: '2',
1433
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike', productType: 'Shoes' },
1434
- }),
1241
+ createLineItem({ lineItemId: '1', filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas', productType: 'Hats' } }),
1242
+ createLineItem({ lineItemId: '2', filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike', productType: 'Shoes' } }),
1435
1243
  ],
1436
1244
  });
1437
1245
  const liCosts = {
1438
1246
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1439
1247
  '2': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1440
1248
  };
1441
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(5);
1249
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap).orderLevel).toBe(5);
1442
1250
  });
1443
- (0, vitest_1.it)('should match PER_ORDER with productId_variantId composite filter', () => {
1251
+ it('should match PER_ORDER with productId_variantId composite filter', () => {
1444
1252
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1445
1253
  flatAmount: 5,
1446
1254
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P100_V200'] } },
@@ -1448,15 +1256,13 @@ const createConfigs = (overrides = {}) => ({
1448
1256
  const matchContext = createContext({
1449
1257
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V200', tags: [] } })],
1450
1258
  });
1451
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1452
- .orderLevel).toBe(5);
1259
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1453
1260
  const noMatchContext = createContext({
1454
1261
  lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V999', tags: [] } })],
1455
1262
  });
1456
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1457
- .orderLevel).toBe(0);
1263
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1458
1264
  });
1459
- (0, vitest_1.it)('should convert currency AND evaluate product filters for PER_ORDER', () => {
1265
+ it('should convert currency AND evaluate product filters for PER_ORDER', () => {
1460
1266
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1461
1267
  flatAmount: 10,
1462
1268
  currency: 'EUR',
@@ -1466,16 +1272,13 @@ const createConfigs = (overrides = {}) => ({
1466
1272
  const matchContext = createContext({
1467
1273
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1468
1274
  });
1469
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', rates).orderLevel).toBeCloseTo(11);
1275
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', rates).orderLevel).toBeCloseTo(11);
1470
1276
  const noMatchContext = createContext({
1471
- lineItems: [
1472
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } }),
1473
- ],
1277
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Adidas' } })],
1474
1278
  });
1475
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', rates)
1476
- .orderLevel).toBe(0);
1279
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', rates).orderLevel).toBe(0);
1477
1280
  });
1478
- (0, vitest_1.it)('should evaluate weight tiers AND product filters for BY_ORDER_WEIGHT', () => {
1281
+ it('should evaluate weight tiers AND product filters for BY_ORDER_WEIGHT', () => {
1479
1282
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_ORDER_WEIGHT, {
1480
1283
  weightUnit: at_tracking_event_types_1.WEIGHT_UNIT.KILOGRAMS,
1481
1284
  weightIntervals: [
@@ -1486,22 +1289,16 @@ const createConfigs = (overrides = {}) => ({
1486
1289
  });
1487
1290
  const matchContext = createContext({
1488
1291
  totalWeight: 2000,
1489
- lineItems: [
1490
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Heavy Items' } }),
1491
- ],
1292
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Heavy Items' } })],
1492
1293
  });
1493
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1494
- .orderLevel).toBe(3);
1294
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(3);
1495
1295
  const noMatchContext = createContext({
1496
1296
  totalWeight: 2000,
1497
- lineItems: [
1498
- createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Light Items' } }),
1499
- ],
1297
+ lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], category: 'Light Items' } })],
1500
1298
  });
1501
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1502
- .orderLevel).toBe(0);
1299
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1503
1300
  });
1504
- (0, vitest_1.it)('should evaluate quantity tiers AND product filters for BY_LINE_ITEM_QUANTITY', () => {
1301
+ it('should evaluate quantity tiers AND product filters for BY_LINE_ITEM_QUANTITY', () => {
1505
1302
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
1506
1303
  quantityIntervals: [
1507
1304
  { quantityMin: 1, quantityMax: 10, flatAmount: 2 },
@@ -1510,21 +1307,15 @@ const createConfigs = (overrides = {}) => ({
1510
1307
  filters: { productTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['bulk'] } },
1511
1308
  });
1512
1309
  const matchContext = createContext({
1513
- lineItems: [
1514
- createLineItem({ quantity: 5, filterContext: { productId: 'P1', variantId: 'V1', tags: ['bulk'] } }),
1515
- ],
1310
+ lineItems: [createLineItem({ quantity: 5, filterContext: { productId: 'P1', variantId: 'V1', tags: ['bulk'] } })],
1516
1311
  });
1517
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1518
- .lineItemLevel).toBe(2);
1312
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, matchContext, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(2);
1519
1313
  const noMatchContext = createContext({
1520
- lineItems: [
1521
- createLineItem({ quantity: 5, filterContext: { productId: 'P1', variantId: 'V1', tags: ['single'] } }),
1522
- ],
1314
+ lineItems: [createLineItem({ quantity: 5, filterContext: { productId: 'P1', variantId: 'V1', tags: ['single'] } })],
1523
1315
  });
1524
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap)
1525
- .lineItemLevel).toBe(0);
1316
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, noMatchContext, initLineItemCosts(), 'USD', emptyRatesMap).lineItemLevel).toBe(0);
1526
1317
  });
1527
- (0, vitest_1.it)('should apply PER_LINE_ITEM to line items NOT matching EXCLUDE product filter', () => {
1318
+ it('should apply PER_LINE_ITEM to line items NOT matching EXCLUDE product filter', () => {
1528
1319
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1529
1320
  flatAmount: 2,
1530
1321
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['Nike'] } },
@@ -1535,24 +1326,16 @@ const createConfigs = (overrides = {}) => ({
1535
1326
  };
1536
1327
  const context = createContext({
1537
1328
  lineItems: [
1538
- createLineItem({
1539
- lineItemId: '1',
1540
- quantity: 3,
1541
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
1542
- }),
1543
- createLineItem({
1544
- lineItemId: '2',
1545
- quantity: 2,
1546
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' },
1547
- }),
1329
+ createLineItem({ lineItemId: '1', quantity: 3, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } }),
1330
+ createLineItem({ lineItemId: '2', quantity: 2, filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' } }),
1548
1331
  ],
1549
1332
  });
1550
1333
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1551
- (0, vitest_1.expect)(result.lineItemLevel).toBe(4);
1552
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(0);
1553
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(4);
1334
+ expect(result.lineItemLevel).toBe(4);
1335
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(0);
1336
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(4);
1554
1337
  });
1555
- (0, vitest_1.it)('should apply PER_LINE_ITEM selectively when multiple product filters used', () => {
1338
+ it('should apply PER_LINE_ITEM selectively when multiple product filters used', () => {
1556
1339
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1557
1340
  flatAmount: 1,
1558
1341
  filters: {
@@ -1567,30 +1350,18 @@ const createConfigs = (overrides = {}) => ({
1567
1350
  };
1568
1351
  const context = createContext({
1569
1352
  lineItems: [
1570
- createLineItem({
1571
- lineItemId: '1',
1572
- quantity: 2,
1573
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike', productType: 'Shoes' },
1574
- }),
1575
- createLineItem({
1576
- lineItemId: '2',
1577
- quantity: 3,
1578
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike', productType: 'Hats' },
1579
- }),
1580
- createLineItem({
1581
- lineItemId: '3',
1582
- quantity: 1,
1583
- filterContext: { productId: 'P3', variantId: 'V3', tags: [], vendor: 'Adidas', productType: 'Shoes' },
1584
- }),
1353
+ createLineItem({ lineItemId: '1', quantity: 2, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike', productType: 'Shoes' } }),
1354
+ createLineItem({ lineItemId: '2', quantity: 3, filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Nike', productType: 'Hats' } }),
1355
+ createLineItem({ lineItemId: '3', quantity: 1, filterContext: { productId: 'P3', variantId: 'V3', tags: [], vendor: 'Adidas', productType: 'Shoes' } }),
1585
1356
  ],
1586
1357
  });
1587
1358
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1588
- (0, vitest_1.expect)(result.lineItemLevel).toBe(2);
1589
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(2);
1590
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
1591
- (0, vitest_1.expect)(liCosts['3'].totalLineItemOtherCost).toBe(0);
1359
+ expect(result.lineItemLevel).toBe(2);
1360
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(2);
1361
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
1362
+ expect(liCosts['3'].totalLineItemOtherCost).toBe(0);
1592
1363
  });
1593
- (0, vitest_1.it)('should return 0 for PER_REFUND_ORDER when product filter matches but hasRefund is false', () => {
1364
+ it('should return 0 for PER_REFUND_ORDER when product filter matches but hasRefund is false', () => {
1594
1365
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER, {
1595
1366
  flatAmount: 5,
1596
1367
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
@@ -1599,10 +1370,9 @@ const createConfigs = (overrides = {}) => ({
1599
1370
  hasRefund: false,
1600
1371
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1601
1372
  });
1602
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1603
- .orderLevel).toBe(0);
1373
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1604
1374
  });
1605
- (0, vitest_1.it)('should apply PER_REFUND_LINE_ITEM only to refunded line items NOT matching EXCLUDE filter', () => {
1375
+ it('should apply PER_REFUND_LINE_ITEM only to refunded line items NOT matching EXCLUDE filter', () => {
1606
1376
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, {
1607
1377
  flatAmount: 3,
1608
1378
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['P1'] } },
@@ -1614,24 +1384,16 @@ const createConfigs = (overrides = {}) => ({
1614
1384
  const context = createContext({
1615
1385
  hasRefund: true,
1616
1386
  lineItems: [
1617
- createLineItem({
1618
- lineItemId: '1',
1619
- refundedQuantity: 2,
1620
- filterContext: { productId: 'P1', variantId: 'V1', tags: [] },
1621
- }),
1622
- createLineItem({
1623
- lineItemId: '2',
1624
- refundedQuantity: 1,
1625
- filterContext: { productId: 'P2', variantId: 'V2', tags: [] },
1626
- }),
1387
+ createLineItem({ lineItemId: '1', refundedQuantity: 2, filterContext: { productId: 'P1', variantId: 'V1', tags: [] } }),
1388
+ createLineItem({ lineItemId: '2', refundedQuantity: 1, filterContext: { productId: 'P2', variantId: 'V2', tags: [] } }),
1627
1389
  ],
1628
1390
  });
1629
1391
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1630
- (0, vitest_1.expect)(result.lineItemLevel).toBe(3);
1631
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(0);
1632
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(3);
1392
+ expect(result.lineItemLevel).toBe(3);
1393
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(0);
1394
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(3);
1633
1395
  });
1634
- (0, vitest_1.it)('should apply PER_ORDER when EXCLUDE order filter does not match', () => {
1396
+ it('should apply PER_ORDER when EXCLUDE order filter does not match', () => {
1635
1397
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1636
1398
  flatAmount: 5,
1637
1399
  filters: { orderTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['test'] } },
@@ -1639,10 +1401,9 @@ const createConfigs = (overrides = {}) => ({
1639
1401
  const context = createContext({
1640
1402
  orderFilterContext: { tags: ['vip'], paymentGateways: [], shippingTitles: [] },
1641
1403
  });
1642
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1643
- .orderLevel).toBe(5);
1404
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1644
1405
  });
1645
- (0, vitest_1.it)('should return 0 for PER_ORDER when EXCLUDE order filter matches', () => {
1406
+ it('should return 0 for PER_ORDER when EXCLUDE order filter matches', () => {
1646
1407
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1647
1408
  flatAmount: 5,
1648
1409
  filters: { orderTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['test'] } },
@@ -1650,10 +1411,9 @@ const createConfigs = (overrides = {}) => ({
1650
1411
  const context = createContext({
1651
1412
  orderFilterContext: { tags: ['test'], paymentGateways: [], shippingTitles: [] },
1652
1413
  });
1653
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1654
- .orderLevel).toBe(0);
1414
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1655
1415
  });
1656
- (0, vitest_1.it)('should handle undefined filter context fields (missing vendor, productType, category)', () => {
1416
+ it('should handle undefined filter context fields (missing vendor, productType, category)', () => {
1657
1417
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1658
1418
  flatAmount: 5,
1659
1419
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
@@ -1661,10 +1421,9 @@ const createConfigs = (overrides = {}) => ({
1661
1421
  const context = createContext({
1662
1422
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [] } })],
1663
1423
  });
1664
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1665
- .orderLevel).toBe(0);
1424
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1666
1425
  });
1667
- (0, vitest_1.it)('should handle EXCLUDE filter with undefined filter context field (undefined treated as not matching)', () => {
1426
+ it('should handle EXCLUDE filter with undefined filter context field (undefined treated as not matching)', () => {
1668
1427
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1669
1428
  flatAmount: 5,
1670
1429
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['Nike'] } },
@@ -1672,10 +1431,9 @@ const createConfigs = (overrides = {}) => ({
1672
1431
  const context = createContext({
1673
1432
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [] } })],
1674
1433
  });
1675
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1676
- .orderLevel).toBe(5);
1434
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1677
1435
  });
1678
- (0, vitest_1.it)('should return 0 for PER_ORDER when INCLUDE productTags filter and line item has empty tags', () => {
1436
+ it('should return 0 for PER_ORDER when INCLUDE productTags filter and line item has empty tags', () => {
1679
1437
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1680
1438
  flatAmount: 5,
1681
1439
  filters: { productTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['sale'] } },
@@ -1683,10 +1441,9 @@ const createConfigs = (overrides = {}) => ({
1683
1441
  const context = createContext({
1684
1442
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [] } })],
1685
1443
  });
1686
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1687
- .orderLevel).toBe(0);
1444
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(0);
1688
1445
  });
1689
- (0, vitest_1.it)('should apply PER_ORDER when EXCLUDE productTags filter and line item has empty tags', () => {
1446
+ it('should apply PER_ORDER when EXCLUDE productTags filter and line item has empty tags', () => {
1690
1447
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1691
1448
  flatAmount: 5,
1692
1449
  filters: { productTags: { mode: at_tracking_event_types_1.COST_FILTER_MODE.EXCLUDE, values: ['sale'] } },
@@ -1694,10 +1451,9 @@ const createConfigs = (overrides = {}) => ({
1694
1451
  const context = createContext({
1695
1452
  lineItems: [createLineItem({ filterContext: { productId: 'P1', variantId: 'V1', tags: [] } })],
1696
1453
  });
1697
- (0, vitest_1.expect)(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap)
1698
- .orderLevel).toBe(5);
1454
+ expect(cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, initLineItemCosts(), 'USD', emptyRatesMap).orderLevel).toBe(5);
1699
1455
  });
1700
- (0, vitest_1.it)('should apply PER_LINE_ITEM only to line items matching product filter when order filter also passes', () => {
1456
+ it('should apply PER_LINE_ITEM only to line items matching product filter when order filter also passes', () => {
1701
1457
  const entry = createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
1702
1458
  flatAmount: 2,
1703
1459
  filters: {
@@ -1712,33 +1468,25 @@ const createConfigs = (overrides = {}) => ({
1712
1468
  const context = createContext({
1713
1469
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [], shipCountryCode: 'US' },
1714
1470
  lineItems: [
1715
- createLineItem({
1716
- lineItemId: '1',
1717
- quantity: 3,
1718
- filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' },
1719
- }),
1720
- createLineItem({
1721
- lineItemId: '2',
1722
- quantity: 2,
1723
- filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' },
1724
- }),
1471
+ createLineItem({ lineItemId: '1', quantity: 3, filterContext: { productId: 'P1', variantId: 'V1', tags: [], vendor: 'Nike' } }),
1472
+ createLineItem({ lineItemId: '2', quantity: 2, filterContext: { productId: 'P2', variantId: 'V2', tags: [], vendor: 'Adidas' } }),
1725
1473
  ],
1726
1474
  });
1727
1475
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCostEntry(entry, context, liCosts, 'USD', emptyRatesMap);
1728
- (0, vitest_1.expect)(result.lineItemLevel).toBe(6);
1729
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
1730
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(0);
1476
+ expect(result.lineItemLevel).toBe(6);
1477
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
1478
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(0);
1731
1479
  });
1732
1480
  });
1733
- (0, vitest_1.describe)('calculateOtherCost', () => {
1734
- (0, vitest_1.it)('should return 0 when no order config', () => {
1481
+ describe('calculateOtherCost', () => {
1482
+ it('should return 0 when no order config', () => {
1735
1483
  const configs = createConfigs();
1736
1484
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, createContext(), {}, 'USD', emptyRatesMap);
1737
- (0, vitest_1.expect)(result.total).toBe(0);
1738
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
1739
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
1485
+ expect(result.total).toBe(0);
1486
+ expect(result.orderLevel).toBe(0);
1487
+ expect(result.lineItemLevel).toBe(0);
1740
1488
  });
1741
- (0, vitest_1.it)('should sum multiple entries and separate order-level costs', () => {
1489
+ it('should sum multiple entries and separate order-level costs', () => {
1742
1490
  const configs = createConfigs({
1743
1491
  order: {
1744
1492
  entries: [
@@ -1747,15 +1495,13 @@ const createConfigs = (overrides = {}) => ({
1747
1495
  ],
1748
1496
  },
1749
1497
  });
1750
- const liCosts = {
1751
- '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1752
- };
1498
+ const liCosts = { '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 } };
1753
1499
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, createContext(), liCosts, 'USD', emptyRatesMap);
1754
- (0, vitest_1.expect)(result.total).toBe(5);
1755
- (0, vitest_1.expect)(result.orderLevel).toBe(5);
1756
- (0, vitest_1.expect)(result.lineItemLevel).toBe(0);
1500
+ expect(result.total).toBe(5);
1501
+ expect(result.orderLevel).toBe(5);
1502
+ expect(result.lineItemLevel).toBe(0);
1757
1503
  });
1758
- (0, vitest_1.it)('should accumulate lineItemCosts from multiple PER_LINE_ITEM entries', () => {
1504
+ it('should accumulate lineItemCosts from multiple PER_LINE_ITEM entries', () => {
1759
1505
  const configs = createConfigs({
1760
1506
  order: {
1761
1507
  entries: [
@@ -1771,12 +1517,12 @@ const createConfigs = (overrides = {}) => ({
1771
1517
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1772
1518
  };
1773
1519
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, context, liCosts, 'USD', emptyRatesMap);
1774
- (0, vitest_1.expect)(result.total).toBe(10);
1775
- (0, vitest_1.expect)(result.orderLevel).toBe(0);
1776
- (0, vitest_1.expect)(result.lineItemLevel).toBe(10);
1777
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(10);
1520
+ expect(result.total).toBe(10);
1521
+ expect(result.orderLevel).toBe(0);
1522
+ expect(result.lineItemLevel).toBe(10);
1523
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(10);
1778
1524
  });
1779
- (0, vitest_1.it)('should skip entries outside date range', () => {
1525
+ it('should skip entries outside date range', () => {
1780
1526
  const configs = createConfigs({
1781
1527
  order: {
1782
1528
  entries: [
@@ -1786,29 +1532,25 @@ const createConfigs = (overrides = {}) => ({
1786
1532
  });
1787
1533
  const liCosts = {};
1788
1534
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, createContext(), liCosts, 'USD', emptyRatesMap);
1789
- (0, vitest_1.expect)(result.total).toBe(0);
1535
+ expect(result.total).toBe(0);
1790
1536
  });
1791
- (0, vitest_1.it)('should only sum entries whose filters pass (mixed filter results)', () => {
1537
+ it('should only sum entries whose filters pass (mixed filter results)', () => {
1792
1538
  const configs = createConfigs({
1793
1539
  order: {
1794
1540
  entries: [
1795
1541
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1796
- id: 'e1',
1797
- flatAmount: 3,
1542
+ id: 'e1', flatAmount: 3,
1798
1543
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1799
1544
  }),
1800
1545
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1801
- id: 'e2',
1802
- flatAmount: 7,
1546
+ id: 'e2', flatAmount: 7,
1803
1547
  filters: { products: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['P999'] } },
1804
1548
  }),
1805
1549
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
1806
- id: 'e3',
1807
- percentRate: 2,
1550
+ id: 'e3', percentRate: 2,
1808
1551
  }),
1809
1552
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1810
- id: 'e4',
1811
- flatAmount: 10,
1553
+ id: 'e4', flatAmount: 10,
1812
1554
  filters: { countries: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['CA'] } },
1813
1555
  }),
1814
1556
  ],
@@ -1816,24 +1558,15 @@ const createConfigs = (overrides = {}) => ({
1816
1558
  });
1817
1559
  const context = createContext({
1818
1560
  grossSalePrice: 120,
1819
- orderFilterContext: {
1820
- tags: [],
1821
- paymentGateways: ['stripe'],
1822
- shippingTitles: ['Standard'],
1823
- shipCountryCode: 'US',
1824
- },
1825
- lineItems: [
1826
- createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [], vendor: 'Nike' } }),
1827
- ],
1561
+ orderFilterContext: { tags: [], paymentGateways: ['stripe'], shippingTitles: ['Standard'], shipCountryCode: 'US' },
1562
+ lineItems: [createLineItem({ filterContext: { productId: 'P100', variantId: 'V1', tags: [], vendor: 'Nike' } })],
1828
1563
  });
1829
- const liCosts = {
1830
- '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1831
- };
1564
+ const liCosts = { '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 } };
1832
1565
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, context, liCosts, 'USD', emptyRatesMap);
1833
- (0, vitest_1.expect)(result.total).toBeCloseTo(5.4);
1834
- (0, vitest_1.expect)(result.orderLevel).toBeCloseTo(5.4);
1566
+ expect(result.total).toBeCloseTo(5.4);
1567
+ expect(result.orderLevel).toBeCloseTo(5.4);
1835
1568
  });
1836
- (0, vitest_1.it)('should sum PER_ORDER and PER_LINE_ITEM entries together and separate by level', () => {
1569
+ it('should sum PER_ORDER and PER_LINE_ITEM entries together and separate by level', () => {
1837
1570
  const configs = createConfigs({
1838
1571
  order: {
1839
1572
  entries: [
@@ -1843,66 +1576,65 @@ const createConfigs = (overrides = {}) => ({
1843
1576
  },
1844
1577
  });
1845
1578
  const context = createContext({
1846
- lineItems: [createLineItem({ lineItemId: '1', quantity: 3 }), createLineItem({ lineItemId: '2', quantity: 2 })],
1579
+ lineItems: [
1580
+ createLineItem({ lineItemId: '1', quantity: 3 }),
1581
+ createLineItem({ lineItemId: '2', quantity: 2 }),
1582
+ ],
1847
1583
  });
1848
1584
  const liCosts = {
1849
1585
  '1': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1850
1586
  '2': { totalLineItemHandlingCost: 0, totalLineItemOtherCost: 0 },
1851
1587
  };
1852
1588
  const result = cost_calculator_service_1.CostCalculatorService.calculateOtherCost(configs, context, liCosts, 'USD', emptyRatesMap);
1853
- (0, vitest_1.expect)(result.total).toBe(15);
1854
- (0, vitest_1.expect)(result.orderLevel).toBe(5);
1855
- (0, vitest_1.expect)(result.lineItemLevel).toBe(10);
1856
- (0, vitest_1.expect)(liCosts['1'].totalLineItemOtherCost).toBe(6);
1857
- (0, vitest_1.expect)(liCosts['2'].totalLineItemOtherCost).toBe(4);
1589
+ expect(result.total).toBe(15);
1590
+ expect(result.orderLevel).toBe(5);
1591
+ expect(result.lineItemLevel).toBe(10);
1592
+ expect(liCosts['1'].totalLineItemOtherCost).toBe(6);
1593
+ expect(liCosts['2'].totalLineItemOtherCost).toBe(4);
1858
1594
  });
1859
1595
  });
1860
- (0, vitest_1.describe)('calculateLineItemHandlingCosts', () => {
1861
- (0, vitest_1.it)('should omit line items with no handling fee override', () => {
1596
+ describe('calculateLineItemHandlingCosts', () => {
1597
+ it('should omit line items with no handling fee override', () => {
1862
1598
  const result = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([createLineItem()]);
1863
- (0, vitest_1.expect)(result['1']).toBeUndefined();
1864
- (0, vitest_1.expect)(Object.keys(result)).toHaveLength(0);
1599
+ expect(result['1']).toBeUndefined();
1600
+ expect(Object.keys(result)).toHaveLength(0);
1865
1601
  });
1866
- (0, vitest_1.it)('should include an explicit 0 override as 0, distinct from having no override', () => {
1867
- const result = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([
1868
- createLineItem({ variantHandlingFee: 0, quantity: 3 }),
1869
- ]);
1870
- (0, vitest_1.expect)(result['1']).toBe(0);
1602
+ it('should include an explicit 0 override as 0, distinct from having no override', () => {
1603
+ const result = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([createLineItem({ variantHandlingFee: 0, quantity: 3 })]);
1604
+ expect(result['1']).toBe(0);
1871
1605
  });
1872
- (0, vitest_1.it)('should multiply handling fee by quantity', () => {
1606
+ it('should multiply handling fee by quantity', () => {
1873
1607
  const result = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([
1874
1608
  createLineItem({ lineItemId: '1', quantity: 3, variantHandlingFee: 1.5 }),
1875
1609
  ]);
1876
- (0, vitest_1.expect)(result['1']).toBe(4.5);
1610
+ expect(result['1']).toBe(4.5);
1877
1611
  });
1878
- (0, vitest_1.it)('should handle multiple line items', () => {
1612
+ it('should handle multiple line items', () => {
1879
1613
  const result = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([
1880
1614
  createLineItem({ lineItemId: '1', quantity: 2, variantHandlingFee: 1 }),
1881
1615
  createLineItem({ lineItemId: '2', quantity: 1, variantHandlingFee: 3 }),
1882
1616
  ]);
1883
- (0, vitest_1.expect)(result['1']).toBe(2);
1884
- (0, vitest_1.expect)(result['2']).toBe(3);
1617
+ expect(result['1']).toBe(2);
1618
+ expect(result['2']).toBe(3);
1885
1619
  });
1886
1620
  });
1887
- (0, vitest_1.describe)('calculateOrderCosts', () => {
1888
- (0, vitest_1.it)('should return default result when configs is null', () => {
1621
+ describe('calculateOrderCosts', () => {
1622
+ it('should return default result when configs is null', () => {
1889
1623
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(null, createContext(), 'USD', emptyRatesMap);
1890
- (0, vitest_1.expect)(result.orderLevelHandlingCost).toBe(0);
1891
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(0);
1892
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(0);
1893
- (0, vitest_1.expect)(result.totalOtherCost).toBe(0);
1894
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(0);
1895
- (0, vitest_1.expect)(result.lineItemLevelOtherCost).toBe(0);
1896
- (0, vitest_1.expect)(result.totalGatewayCost).toBe(0);
1897
- (0, vitest_1.expect)(result.totalShippingCost).toBe(0);
1898
- });
1899
- (0, vitest_1.it)('should calculate all cost types together', () => {
1624
+ expect(result.orderLevelHandlingCost).toBe(0);
1625
+ expect(result.lineItemLevelHandlingCost).toBe(0);
1626
+ expect(result.totalHandlingCost).toBe(0);
1627
+ expect(result.totalOtherCost).toBe(0);
1628
+ expect(result.orderLevelOtherCost).toBe(0);
1629
+ expect(result.lineItemLevelOtherCost).toBe(0);
1630
+ expect(result.totalGatewayCost).toBe(0);
1631
+ expect(result.totalShippingCost).toBe(0);
1632
+ });
1633
+ it('should calculate all cost types together', () => {
1900
1634
  const configs = createConfigs({
1901
1635
  globalProductOverride: { globalHandlingFee: 2 },
1902
1636
  gateway: {
1903
- entries: [
1904
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
1905
- ],
1637
+ entries: [{ gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' }],
1906
1638
  },
1907
1639
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.SHOPIFY_CHARGES, currency: 'USD' },
1908
1640
  order: {
@@ -1914,44 +1646,40 @@ const createConfigs = (overrides = {}) => ({
1914
1646
  lineItems: [createLineItem({ variantHandlingFee: 0.5, quantity: 2 })],
1915
1647
  });
1916
1648
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
1917
- (0, vitest_1.expect)(result.orderLevelHandlingCost).toBe(0);
1918
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(1);
1919
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(1);
1920
- (0, vitest_1.expect)(result.totalGatewayCost).toBeCloseTo(3.2);
1921
- (0, vitest_1.expect)(result.totalShippingCost).toBe(10);
1922
- (0, vitest_1.expect)(result.totalOtherCost).toBe(1);
1923
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(1);
1924
- (0, vitest_1.expect)(result.lineItemLevelOtherCost).toBe(0);
1925
- (0, vitest_1.expect)(result.lineItemCosts['1'].totalLineItemHandlingCost).toBe(1);
1926
- });
1927
- (0, vitest_1.it)('should handle partial configs', () => {
1649
+ expect(result.orderLevelHandlingCost).toBe(0);
1650
+ expect(result.lineItemLevelHandlingCost).toBe(1);
1651
+ expect(result.totalHandlingCost).toBe(1);
1652
+ expect(result.totalGatewayCost).toBeCloseTo(3.20);
1653
+ expect(result.totalShippingCost).toBe(10);
1654
+ expect(result.totalOtherCost).toBe(1);
1655
+ expect(result.orderLevelOtherCost).toBe(1);
1656
+ expect(result.lineItemLevelOtherCost).toBe(0);
1657
+ expect(result.lineItemCosts['1'].totalLineItemHandlingCost).toBe(1);
1658
+ });
1659
+ it('should handle partial configs', () => {
1928
1660
  const configs = createConfigs({
1929
1661
  gateway: {
1930
- entries: [
1931
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 0, currency: 'USD', createdAt: '', updatedAt: '' },
1932
- ],
1662
+ entries: [{ gatewayName: 'stripe', flatAmount: 0.30, percentRate: 0, currency: 'USD', createdAt: '', updatedAt: '' }],
1933
1663
  },
1934
1664
  });
1935
1665
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
1936
- (0, vitest_1.expect)(result.orderLevelHandlingCost).toBe(0);
1937
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(0);
1938
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(0);
1939
- (0, vitest_1.expect)(result.totalGatewayCost).toBe(0.3);
1940
- (0, vitest_1.expect)(result.totalShippingCost).toBe(0);
1941
- (0, vitest_1.expect)(result.totalOtherCost).toBe(0);
1942
- });
1943
- (0, vitest_1.it)('should respect product filters in calculateOrderCosts integration', () => {
1666
+ expect(result.orderLevelHandlingCost).toBe(0);
1667
+ expect(result.lineItemLevelHandlingCost).toBe(0);
1668
+ expect(result.totalHandlingCost).toBe(0);
1669
+ expect(result.totalGatewayCost).toBe(0.30);
1670
+ expect(result.totalShippingCost).toBe(0);
1671
+ expect(result.totalOtherCost).toBe(0);
1672
+ });
1673
+ it('should respect product filters in calculateOrderCosts integration', () => {
1944
1674
  const configs = createConfigs({
1945
1675
  order: {
1946
1676
  entries: [
1947
1677
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1948
- id: 'e1',
1949
- flatAmount: 5,
1678
+ id: 'e1', flatAmount: 5,
1950
1679
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Nike'] } },
1951
1680
  }),
1952
1681
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
1953
- id: 'e2',
1954
- flatAmount: 10,
1682
+ id: 'e2', flatAmount: 10,
1955
1683
  filters: { productVendors: { mode: at_tracking_event_types_1.COST_FILTER_MODE.INCLUDE, values: ['Puma'] } },
1956
1684
  }),
1957
1685
  ],
@@ -1967,16 +1695,14 @@ const createConfigs = (overrides = {}) => ({
1967
1695
  ],
1968
1696
  });
1969
1697
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
1970
- (0, vitest_1.expect)(result.totalOtherCost).toBe(5);
1971
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(5);
1698
+ expect(result.totalOtherCost).toBe(5);
1699
+ expect(result.orderLevelOtherCost).toBe(5);
1972
1700
  });
1973
- (0, vitest_1.it)('should accumulate all cost types with multiple line items and separate by level', () => {
1701
+ it('should accumulate all cost types with multiple line items and separate by level', () => {
1974
1702
  const configs = createConfigs({
1975
1703
  globalProductOverride: { globalHandlingFee: 1, currency: 'USD' },
1976
1704
  gateway: {
1977
- entries: [
1978
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
1979
- ],
1705
+ entries: [{ gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' }],
1980
1706
  },
1981
1707
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE, fixedRateAmount: 5, currency: 'USD' },
1982
1708
  order: {
@@ -1995,32 +1721,34 @@ const createConfigs = (overrides = {}) => ({
1995
1721
  ],
1996
1722
  });
1997
1723
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
1998
- (0, vitest_1.expect)(result.orderLevelHandlingCost).toBe(0);
1999
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(3.5);
2000
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(3.5);
2001
- (0, vitest_1.expect)(result.totalGatewayCost).toBeCloseTo(6.1);
2002
- (0, vitest_1.expect)(result.totalShippingCost).toBe(5);
2003
- (0, vitest_1.expect)(result.totalOtherCost).toBe(12);
2004
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(7);
2005
- (0, vitest_1.expect)(result.lineItemLevelOtherCost).toBe(5);
2006
- (0, vitest_1.expect)(result.lineItemCosts['1'].totalLineItemOtherCost).toBe(3);
2007
- (0, vitest_1.expect)(result.lineItemCosts['2'].totalLineItemOtherCost).toBe(2);
2008
- (0, vitest_1.expect)(result.lineItemCosts['1'].totalLineItemHandlingCost).toBe(1.5);
2009
- (0, vitest_1.expect)(result.lineItemCosts['2'].totalLineItemHandlingCost).toBe(2);
2010
- });
2011
- (0, vitest_1.it)('should maintain decimal precision with Big.js', () => {
1724
+ expect(result.orderLevelHandlingCost).toBe(0);
1725
+ expect(result.lineItemLevelHandlingCost).toBe(3.5);
1726
+ expect(result.totalHandlingCost).toBe(3.5);
1727
+ expect(result.totalGatewayCost).toBeCloseTo(6.10);
1728
+ expect(result.totalShippingCost).toBe(5);
1729
+ expect(result.totalOtherCost).toBe(12);
1730
+ expect(result.orderLevelOtherCost).toBe(7);
1731
+ expect(result.lineItemLevelOtherCost).toBe(5);
1732
+ expect(result.lineItemCosts['1'].totalLineItemOtherCost).toBe(3);
1733
+ expect(result.lineItemCosts['2'].totalLineItemOtherCost).toBe(2);
1734
+ expect(result.lineItemCosts['1'].totalLineItemHandlingCost).toBe(1.5);
1735
+ expect(result.lineItemCosts['2'].totalLineItemHandlingCost).toBe(2);
1736
+ });
1737
+ it('should maintain decimal precision with Big.js', () => {
2012
1738
  const configs = createConfigs({
2013
1739
  order: {
2014
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 33.33 })],
1740
+ entries: [
1741
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 33.33 }),
1742
+ ],
2015
1743
  },
2016
1744
  });
2017
1745
  const context = createContext({ totalPrice: 99.99 });
2018
1746
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2019
- (0, vitest_1.expect)(result.totalOtherCost).toBeCloseTo(33.326667, 4);
1747
+ expect(result.totalOtherCost).toBeCloseTo(33.326667, 4);
2020
1748
  });
2021
1749
  });
2022
- (0, vitest_1.describe)('calculateOtherCost - category routing', () => {
2023
- (0, vitest_1.it)('should route COGS category costs to totalOtherCogs', () => {
1750
+ describe('calculateOtherCost - category routing', () => {
1751
+ it('should route COGS category costs to totalOtherCogs', () => {
2024
1752
  const configs = createConfigs({
2025
1753
  order: {
2026
1754
  entries: [
@@ -2030,15 +1758,15 @@ const createConfigs = (overrides = {}) => ({
2030
1758
  },
2031
1759
  });
2032
1760
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2033
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(15);
2034
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
2035
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(0);
2036
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(0);
2037
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(0);
2038
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(0);
2039
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(0);
2040
- });
2041
- (0, vitest_1.it)('should route FULFILLMENT category costs to otherFulfillmentCost', () => {
1761
+ expect(result.categoryCosts.totalOtherCogs).toBe(15);
1762
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
1763
+ expect(result.categoryCosts.otherTransactionCost).toBe(0);
1764
+ expect(result.categoryCosts.marketingCost).toBe(0);
1765
+ expect(result.categoryCosts.agencyFeesCost).toBe(0);
1766
+ expect(result.categoryCosts.opexCost).toBe(0);
1767
+ expect(result.categoryCosts.totalOtherCost).toBe(0);
1768
+ });
1769
+ it('should route FULFILLMENT category costs to otherFulfillmentCost', () => {
2042
1770
  const configs = createConfigs({
2043
1771
  order: {
2044
1772
  entries: [
@@ -2047,10 +1775,10 @@ const createConfigs = (overrides = {}) => ({
2047
1775
  },
2048
1776
  });
2049
1777
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2050
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(8);
2051
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(0);
1778
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(8);
1779
+ expect(result.categoryCosts.totalOtherCogs).toBe(0);
2052
1780
  });
2053
- (0, vitest_1.it)('should route TRANSACTION category costs to otherTransactionCost', () => {
1781
+ it('should route TRANSACTION category costs to otherTransactionCost', () => {
2054
1782
  const configs = createConfigs({
2055
1783
  order: {
2056
1784
  entries: [
@@ -2060,9 +1788,9 @@ const createConfigs = (overrides = {}) => ({
2060
1788
  });
2061
1789
  const context = createContext({ totalPrice: 100 });
2062
1790
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2063
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(3);
1791
+ expect(result.categoryCosts.otherTransactionCost).toBe(3);
2064
1792
  });
2065
- (0, vitest_1.it)('should route MARKETING category costs to marketingCost', () => {
1793
+ it('should route MARKETING category costs to marketingCost', () => {
2066
1794
  const configs = createConfigs({
2067
1795
  order: {
2068
1796
  entries: [
@@ -2071,43 +1799,43 @@ const createConfigs = (overrides = {}) => ({
2071
1799
  },
2072
1800
  });
2073
1801
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2074
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(25);
1802
+ expect(result.categoryCosts.marketingCost).toBe(25);
2075
1803
  });
2076
- (0, vitest_1.it)('should route AGENCY_FEES category costs to agencyFeesCost', () => {
1804
+ it('should route AGENCY_FEES category costs to agencyFeesCost', () => {
2077
1805
  const configs = createConfigs({
2078
1806
  order: {
2079
1807
  entries: [
2080
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, {
2081
- id: 'agency1',
2082
- percentRate: 15,
2083
- category: 'agency_fees',
2084
- }),
1808
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_GROSS_SALES, { id: 'agency1', percentRate: 15, category: 'agency_fees' }),
2085
1809
  ],
2086
1810
  },
2087
1811
  });
2088
1812
  const context = createContext({ grossSalePrice: 200 });
2089
1813
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2090
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(30);
1814
+ expect(result.categoryCosts.agencyFeesCost).toBe(30);
2091
1815
  });
2092
- (0, vitest_1.it)('should route OPEX category costs to opexCost', () => {
1816
+ it('should route OPEX category costs to opexCost', () => {
2093
1817
  const configs = createConfigs({
2094
1818
  order: {
2095
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'opex1', flatAmount: 12, category: 'opex' })],
1819
+ entries: [
1820
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'opex1', flatAmount: 12, category: 'opex' }),
1821
+ ],
2096
1822
  },
2097
1823
  });
2098
1824
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2099
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(12);
1825
+ expect(result.categoryCosts.opexCost).toBe(12);
2100
1826
  });
2101
- (0, vitest_1.it)('should route OTHER category costs to totalOtherCost', () => {
1827
+ it('should route OTHER category costs to totalOtherCost', () => {
2102
1828
  const configs = createConfigs({
2103
1829
  order: {
2104
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'other1', flatAmount: 7, category: 'other' })],
1830
+ entries: [
1831
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'other1', flatAmount: 7, category: 'other' }),
1832
+ ],
2105
1833
  },
2106
1834
  });
2107
1835
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2108
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(7);
1836
+ expect(result.categoryCosts.totalOtherCost).toBe(7);
2109
1837
  });
2110
- (0, vitest_1.it)('should route legacy payment_fees to TRANSACTION (otherTransactionCost)', () => {
1838
+ it('should route legacy payment_fees to TRANSACTION (otherTransactionCost)', () => {
2111
1839
  const configs = createConfigs({
2112
1840
  order: {
2113
1841
  entries: [
@@ -2116,10 +1844,10 @@ const createConfigs = (overrides = {}) => ({
2116
1844
  },
2117
1845
  });
2118
1846
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2119
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(2.5);
2120
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(0);
1847
+ expect(result.categoryCosts.otherTransactionCost).toBe(2.5);
1848
+ expect(result.categoryCosts.totalOtherCost).toBe(0);
2121
1849
  });
2122
- (0, vitest_1.it)('should route legacy packaging to FULFILLMENT (otherFulfillmentCost)', () => {
1850
+ it('should route legacy packaging to FULFILLMENT (otherFulfillmentCost)', () => {
2123
1851
  const configs = createConfigs({
2124
1852
  order: {
2125
1853
  entries: [
@@ -2128,25 +1856,21 @@ const createConfigs = (overrides = {}) => ({
2128
1856
  },
2129
1857
  });
2130
1858
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2131
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(1.75);
2132
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(0);
1859
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(1.75);
1860
+ expect(result.categoryCosts.totalOtherCost).toBe(0);
2133
1861
  });
2134
- (0, vitest_1.it)('should route unknown category to totalOtherCost', () => {
1862
+ it('should route unknown category to totalOtherCost', () => {
2135
1863
  const configs = createConfigs({
2136
1864
  order: {
2137
1865
  entries: [
2138
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
2139
- id: 'unknown1',
2140
- flatAmount: 3,
2141
- category: 'unknown_category_xyz',
2142
- }),
1866
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'unknown1', flatAmount: 3, category: 'unknown_category_xyz' }),
2143
1867
  ],
2144
1868
  },
2145
1869
  });
2146
1870
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2147
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(3);
1871
+ expect(result.categoryCosts.totalOtherCost).toBe(3);
2148
1872
  });
2149
- (0, vitest_1.it)('should route undefined/null category to totalOtherCost', () => {
1873
+ it('should route undefined/null category to totalOtherCost', () => {
2150
1874
  const configs = createConfigs({
2151
1875
  order: {
2152
1876
  entries: [
@@ -2156,9 +1880,9 @@ const createConfigs = (overrides = {}) => ({
2156
1880
  },
2157
1881
  });
2158
1882
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2159
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(10);
1883
+ expect(result.categoryCosts.totalOtherCost).toBe(10);
2160
1884
  });
2161
- (0, vitest_1.it)('should accumulate costs across multiple entries of the same category', () => {
1885
+ it('should accumulate costs across multiple entries of the same category', () => {
2162
1886
  const configs = createConfigs({
2163
1887
  order: {
2164
1888
  entries: [
@@ -2169,12 +1893,15 @@ const createConfigs = (overrides = {}) => ({
2169
1893
  },
2170
1894
  });
2171
1895
  const context = createContext({
2172
- lineItems: [createLineItem({ lineItemId: '1', quantity: 2 }), createLineItem({ lineItemId: '2', quantity: 3 })],
1896
+ lineItems: [
1897
+ createLineItem({ lineItemId: '1', quantity: 2 }),
1898
+ createLineItem({ lineItemId: '2', quantity: 3 }),
1899
+ ],
2173
1900
  });
2174
1901
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2175
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(18);
1902
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(18);
2176
1903
  });
2177
- (0, vitest_1.it)('should route costs to multiple categories correctly', () => {
1904
+ it('should route costs to multiple categories correctly', () => {
2178
1905
  const configs = createConfigs({
2179
1906
  order: {
2180
1907
  entries: [
@@ -2190,62 +1917,59 @@ const createConfigs = (overrides = {}) => ({
2190
1917
  });
2191
1918
  const context = createContext({ totalPrice: 100 });
2192
1919
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2193
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
2194
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(5);
2195
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(2);
2196
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(15);
2197
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(8);
2198
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(20);
2199
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(3);
2200
- (0, vitest_1.expect)(result.totalOtherCost).toBe(3);
2201
- });
2202
- (0, vitest_1.it)('should handle line-item level costs in category routing', () => {
1920
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
1921
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(5);
1922
+ expect(result.categoryCosts.otherTransactionCost).toBe(2);
1923
+ expect(result.categoryCosts.marketingCost).toBe(15);
1924
+ expect(result.categoryCosts.agencyFeesCost).toBe(8);
1925
+ expect(result.categoryCosts.opexCost).toBe(20);
1926
+ expect(result.categoryCosts.totalOtherCost).toBe(3);
1927
+ expect(result.totalOtherCost).toBe(3);
1928
+ });
1929
+ it('should handle line-item level costs in category routing', () => {
2203
1930
  const configs = createConfigs({
2204
1931
  order: {
2205
1932
  entries: [
2206
1933
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { id: 'cogs_li', flatAmount: 2, category: 'cogs' }),
2207
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, {
2208
- id: 'ful_li',
2209
- flatAmount: 1.5,
2210
- category: 'fulfillment',
2211
- }),
1934
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { id: 'ful_li', flatAmount: 1.5, category: 'fulfillment' }),
2212
1935
  ],
2213
1936
  },
2214
1937
  });
2215
1938
  const context = createContext({
2216
- lineItems: [createLineItem({ lineItemId: '1', quantity: 3 }), createLineItem({ lineItemId: '2', quantity: 2 })],
1939
+ lineItems: [
1940
+ createLineItem({ lineItemId: '1', quantity: 3 }),
1941
+ createLineItem({ lineItemId: '2', quantity: 2 }),
1942
+ ],
2217
1943
  });
2218
1944
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2219
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
2220
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(7.5);
1945
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
1946
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(7.5);
2221
1947
  });
2222
- (0, vitest_1.it)('should handle PCT_COGS entry type with category routing', () => {
1948
+ it('should handle PCT_COGS entry type with category routing', () => {
2223
1949
  const configs = createConfigs({
2224
1950
  order: {
2225
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { id: 'pct_cogs', percentRate: 10, category: 'cogs' })],
1951
+ entries: [
1952
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { id: 'pct_cogs', percentRate: 10, category: 'cogs' }),
1953
+ ],
2226
1954
  },
2227
1955
  });
2228
1956
  const context = createContext({ totalProductCost: 50 });
2229
1957
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2230
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(5);
1958
+ expect(result.categoryCosts.totalOtherCogs).toBe(5);
2231
1959
  });
2232
- (0, vitest_1.it)('should handle PCT_SHIPPING entry type routed to fulfillment', () => {
1960
+ it('should handle PCT_SHIPPING entry type routed to fulfillment', () => {
2233
1961
  const configs = createConfigs({
2234
1962
  order: {
2235
1963
  entries: [
2236
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING, {
2237
- id: 'pct_ship',
2238
- percentRate: 20,
2239
- category: 'fulfillment',
2240
- }),
1964
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_SHIPPING, { id: 'pct_ship', percentRate: 20, category: 'fulfillment' }),
2241
1965
  ],
2242
1966
  },
2243
1967
  });
2244
1968
  const context = createContext({ totalShipping: 25 });
2245
1969
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2246
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(5);
1970
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(5);
2247
1971
  });
2248
- (0, vitest_1.it)('should handle refund costs with category routing', () => {
1972
+ it('should handle refund costs with category routing', () => {
2249
1973
  const configs = createConfigs({
2250
1974
  order: {
2251
1975
  entries: [
@@ -2255,9 +1979,9 @@ const createConfigs = (overrides = {}) => ({
2255
1979
  });
2256
1980
  const context = createContext({ hasRefund: true });
2257
1981
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2258
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(15);
1982
+ expect(result.categoryCosts.opexCost).toBe(15);
2259
1983
  });
2260
- (0, vitest_1.it)('should not apply refund costs when hasRefund is false', () => {
1984
+ it('should not apply refund costs when hasRefund is false', () => {
2261
1985
  const configs = createConfigs({
2262
1986
  order: {
2263
1987
  entries: [
@@ -2267,9 +1991,9 @@ const createConfigs = (overrides = {}) => ({
2267
1991
  });
2268
1992
  const context = createContext({ hasRefund: false });
2269
1993
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2270
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(0);
1994
+ expect(result.categoryCosts.opexCost).toBe(0);
2271
1995
  });
2272
- (0, vitest_1.it)('should respect date ranges in category cost routing', () => {
1996
+ it('should respect date ranges in category cost routing', () => {
2273
1997
  const configs = createConfigs({
2274
1998
  order: {
2275
1999
  entries: [
@@ -2292,11 +2016,11 @@ const createConfigs = (overrides = {}) => ({
2292
2016
  });
2293
2017
  const context = createContext({ orderCreatedAt: '2024-06-15T10:00:00Z' });
2294
2018
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2295
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(10);
2019
+ expect(result.categoryCosts.marketingCost).toBe(10);
2296
2020
  });
2297
- (0, vitest_1.it)('should return default categoryCosts when configs is null', () => {
2021
+ it('should return default categoryCosts when configs is null', () => {
2298
2022
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(null, createContext(), 'USD', emptyRatesMap);
2299
- (0, vitest_1.expect)(result.categoryCosts).toEqual({
2023
+ expect(result.categoryCosts).toEqual({
2300
2024
  totalOtherCogs: 0,
2301
2025
  otherFulfillmentCost: 0,
2302
2026
  otherTransactionCost: 0,
@@ -2306,10 +2030,10 @@ const createConfigs = (overrides = {}) => ({
2306
2030
  totalOtherCost: 0,
2307
2031
  });
2308
2032
  });
2309
- (0, vitest_1.it)('should return default categoryCosts when order config is null', () => {
2033
+ it('should return default categoryCosts when order config is null', () => {
2310
2034
  const configs = createConfigs({ order: null });
2311
2035
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2312
- (0, vitest_1.expect)(result.categoryCosts).toEqual({
2036
+ expect(result.categoryCosts).toEqual({
2313
2037
  totalOtherCogs: 0,
2314
2038
  otherFulfillmentCost: 0,
2315
2039
  otherTransactionCost: 0,
@@ -2319,7 +2043,7 @@ const createConfigs = (overrides = {}) => ({
2319
2043
  totalOtherCost: 0,
2320
2044
  });
2321
2045
  });
2322
- (0, vitest_1.it)('should handle mixed legacy and new categories', () => {
2046
+ it('should handle mixed legacy and new categories', () => {
2323
2047
  const configs = createConfigs({
2324
2048
  order: {
2325
2049
  entries: [
@@ -2331,10 +2055,10 @@ const createConfigs = (overrides = {}) => ({
2331
2055
  },
2332
2056
  });
2333
2057
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2334
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(8);
2335
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(6);
2058
+ expect(result.categoryCosts.otherTransactionCost).toBe(8);
2059
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(6);
2336
2060
  });
2337
- (0, vitest_1.it)('should handle weight-based costs with category routing', () => {
2061
+ it('should handle weight-based costs with category routing', () => {
2338
2062
  const configs = createConfigs({
2339
2063
  order: {
2340
2064
  entries: [
@@ -2349,9 +2073,9 @@ const createConfigs = (overrides = {}) => ({
2349
2073
  });
2350
2074
  const context = createContext({ totalWeight: 1000 });
2351
2075
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2352
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(10);
2076
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(10);
2353
2077
  });
2354
- (0, vitest_1.it)('should handle quantity-based costs with category routing', () => {
2078
+ it('should handle quantity-based costs with category routing', () => {
2355
2079
  const configs = createConfigs({
2356
2080
  order: {
2357
2081
  entries: [
@@ -2365,9 +2089,9 @@ const createConfigs = (overrides = {}) => ({
2365
2089
  });
2366
2090
  const context = createContext({ lineItems: [createLineItem({ quantity: 10 })] });
2367
2091
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2368
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(5);
2092
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(5);
2369
2093
  });
2370
- (0, vitest_1.it)('should handle BY_ORDER_QUANTITY costs with category routing', () => {
2094
+ it('should handle BY_ORDER_QUANTITY costs with category routing', () => {
2371
2095
  const configs = createConfigs({
2372
2096
  order: {
2373
2097
  entries: [
@@ -2383,15 +2107,18 @@ const createConfigs = (overrides = {}) => ({
2383
2107
  },
2384
2108
  });
2385
2109
  const context = createContext({
2386
- lineItems: [createLineItem({ lineItemId: '1', quantity: 4 }), createLineItem({ lineItemId: '2', quantity: 3 })],
2110
+ lineItems: [
2111
+ createLineItem({ lineItemId: '1', quantity: 4 }),
2112
+ createLineItem({ lineItemId: '2', quantity: 3 }),
2113
+ ],
2387
2114
  totalQuantity: 7,
2388
2115
  });
2389
2116
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2390
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(5);
2391
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(5);
2392
- (0, vitest_1.expect)(result.lineItemLevelOtherCost).toBe(0);
2117
+ expect(result.categoryCosts.totalOtherCogs).toBe(5);
2118
+ expect(result.orderLevelOtherCost).toBe(5);
2119
+ expect(result.lineItemLevelOtherCost).toBe(0);
2393
2120
  });
2394
- (0, vitest_1.it)('should continue processing other entries when one entry fails', () => {
2121
+ it('should continue processing other entries when one entry fails', () => {
2395
2122
  const configs = createConfigs({
2396
2123
  order: {
2397
2124
  entries: [
@@ -2407,18 +2134,16 @@ const createConfigs = (overrides = {}) => ({
2407
2134
  },
2408
2135
  });
2409
2136
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2410
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
2411
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(5);
2137
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2138
+ expect(result.categoryCosts.marketingCost).toBe(5);
2412
2139
  });
2413
2140
  });
2414
- (0, vitest_1.describe)('calculateOrderCosts - category costs integration', () => {
2415
- (0, vitest_1.it)('should calculate all cost types with category routing in full integration', () => {
2141
+ describe('calculateOrderCosts - category costs integration', () => {
2142
+ it('should calculate all cost types with category routing in full integration', () => {
2416
2143
  const configs = createConfigs({
2417
2144
  globalProductOverride: { globalHandlingFee: 1.5, currency: 'USD' },
2418
2145
  gateway: {
2419
- entries: [
2420
- { gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' },
2421
- ],
2146
+ entries: [{ gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD', createdAt: '', updatedAt: '' }],
2422
2147
  },
2423
2148
  shipping: { method: at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE, fixedRateAmount: 7, currency: 'USD' },
2424
2149
  order: {
@@ -2441,20 +2166,20 @@ const createConfigs = (overrides = {}) => ({
2441
2166
  ],
2442
2167
  });
2443
2168
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2444
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(3.25);
2445
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(3.25);
2446
- (0, vitest_1.expect)(result.totalGatewayCost).toBeCloseTo(6.1);
2447
- (0, vitest_1.expect)(result.totalShippingCost).toBe(7);
2448
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(5);
2449
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(3);
2450
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(2);
2451
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(10);
2452
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(10);
2453
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(8);
2454
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(4);
2455
- (0, vitest_1.expect)(result.totalOtherCost).toBe(4);
2456
- });
2457
- (0, vitest_1.it)('should properly separate order-level and line-item-level costs with categories', () => {
2169
+ expect(result.lineItemLevelHandlingCost).toBe(3.25);
2170
+ expect(result.totalHandlingCost).toBe(3.25);
2171
+ expect(result.totalGatewayCost).toBeCloseTo(6.10);
2172
+ expect(result.totalShippingCost).toBe(7);
2173
+ expect(result.categoryCosts.totalOtherCogs).toBe(5);
2174
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(3);
2175
+ expect(result.categoryCosts.otherTransactionCost).toBe(2);
2176
+ expect(result.categoryCosts.marketingCost).toBe(10);
2177
+ expect(result.categoryCosts.agencyFeesCost).toBe(10);
2178
+ expect(result.categoryCosts.opexCost).toBe(8);
2179
+ expect(result.categoryCosts.totalOtherCost).toBe(4);
2180
+ expect(result.totalOtherCost).toBe(4);
2181
+ });
2182
+ it('should properly separate order-level and line-item-level costs with categories', () => {
2458
2183
  const configs = createConfigs({
2459
2184
  order: {
2460
2185
  entries: [
@@ -2466,35 +2191,38 @@ const createConfigs = (overrides = {}) => ({
2466
2191
  },
2467
2192
  });
2468
2193
  const context = createContext({
2469
- lineItems: [createLineItem({ lineItemId: '1', quantity: 3 }), createLineItem({ lineItemId: '2', quantity: 2 })],
2194
+ lineItems: [
2195
+ createLineItem({ lineItemId: '1', quantity: 3 }),
2196
+ createLineItem({ lineItemId: '2', quantity: 2 }),
2197
+ ],
2470
2198
  });
2471
2199
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2472
- (0, vitest_1.expect)(result.orderLevelOtherCost).toBe(15);
2473
- (0, vitest_1.expect)(result.lineItemLevelOtherCost).toBe(15);
2474
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(20);
2475
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(10);
2476
- (0, vitest_1.expect)(result.lineItemCosts['1'].totalLineItemOtherCost).toBe(9);
2477
- (0, vitest_1.expect)(result.lineItemCosts['2'].totalLineItemOtherCost).toBe(6);
2200
+ expect(result.orderLevelOtherCost).toBe(15);
2201
+ expect(result.lineItemLevelOtherCost).toBe(15);
2202
+ expect(result.categoryCosts.totalOtherCogs).toBe(20);
2203
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(10);
2204
+ expect(result.lineItemCosts['1'].totalLineItemOtherCost).toBe(9);
2205
+ expect(result.lineItemCosts['2'].totalLineItemOtherCost).toBe(6);
2478
2206
  });
2479
2207
  });
2480
- (0, vitest_1.describe)('defensive coding - malformed input handling', () => {
2481
- (0, vitest_1.describe)('empty and missing entries', () => {
2482
- (0, vitest_1.it)('should handle empty entries array', () => {
2208
+ describe('defensive coding - malformed input handling', () => {
2209
+ describe('empty and missing entries', () => {
2210
+ it('should handle empty entries array', () => {
2483
2211
  const configs = createConfigs({
2484
2212
  order: { entries: [] },
2485
2213
  });
2486
2214
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2487
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(0);
2488
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
2489
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(0);
2490
- (0, vitest_1.expect)(result.totalOtherCost).toBe(0);
2215
+ expect(result.categoryCosts.totalOtherCogs).toBe(0);
2216
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2217
+ expect(result.categoryCosts.totalOtherCost).toBe(0);
2218
+ expect(result.totalOtherCost).toBe(0);
2491
2219
  });
2492
- (0, vitest_1.it)('should handle undefined entries', () => {
2220
+ it('should handle undefined entries', () => {
2493
2221
  const configs = createConfigs({
2494
2222
  order: { entries: undefined },
2495
2223
  });
2496
2224
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2497
- (0, vitest_1.expect)(result.categoryCosts).toEqual({
2225
+ expect(result.categoryCosts).toEqual({
2498
2226
  totalOtherCogs: 0,
2499
2227
  otherFulfillmentCost: 0,
2500
2228
  otherTransactionCost: 0,
@@ -2504,12 +2232,12 @@ const createConfigs = (overrides = {}) => ({
2504
2232
  totalOtherCost: 0,
2505
2233
  });
2506
2234
  });
2507
- (0, vitest_1.it)('should handle null entries', () => {
2235
+ it('should handle null entries', () => {
2508
2236
  const configs = createConfigs({
2509
2237
  order: { entries: null },
2510
2238
  });
2511
2239
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2512
- (0, vitest_1.expect)(result.categoryCosts).toEqual({
2240
+ expect(result.categoryCosts).toEqual({
2513
2241
  totalOtherCogs: 0,
2514
2242
  otherFulfillmentCost: 0,
2515
2243
  otherTransactionCost: 0,
@@ -2520,64 +2248,76 @@ const createConfigs = (overrides = {}) => ({
2520
2248
  });
2521
2249
  });
2522
2250
  });
2523
- (0, vitest_1.describe)('malformed entry data', () => {
2524
- (0, vitest_1.it)('should handle entry with undefined flatAmount', () => {
2251
+ describe('malformed entry data', () => {
2252
+ it('should handle entry with undefined flatAmount', () => {
2525
2253
  const configs = createConfigs({
2526
2254
  order: {
2527
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: undefined, category: 'cogs' })],
2255
+ entries: [
2256
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: undefined, category: 'cogs' }),
2257
+ ],
2528
2258
  },
2529
2259
  });
2530
2260
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2531
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(0);
2261
+ expect(result.categoryCosts.totalOtherCogs).toBe(0);
2532
2262
  });
2533
- (0, vitest_1.it)('should handle entry with null flatAmount', () => {
2263
+ it('should handle entry with null flatAmount', () => {
2534
2264
  const configs = createConfigs({
2535
2265
  order: {
2536
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: null, category: 'cogs' })],
2266
+ entries: [
2267
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: null, category: 'cogs' }),
2268
+ ],
2537
2269
  },
2538
2270
  });
2539
2271
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2540
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(0);
2272
+ expect(result.categoryCosts.totalOtherCogs).toBe(0);
2541
2273
  });
2542
- (0, vitest_1.it)('should handle entry with NaN flatAmount', () => {
2274
+ it('should handle entry with NaN flatAmount', () => {
2543
2275
  const configs = createConfigs({
2544
2276
  order: {
2545
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: NaN, category: 'fulfillment' })],
2277
+ entries: [
2278
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: NaN, category: 'fulfillment' }),
2279
+ ],
2546
2280
  },
2547
2281
  });
2548
2282
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2549
- (0, vitest_1.expect)(typeof result.categoryCosts.otherFulfillmentCost).toBe('number');
2283
+ expect(typeof result.categoryCosts.otherFulfillmentCost).toBe('number');
2550
2284
  });
2551
- (0, vitest_1.it)('should handle entry with negative flatAmount', () => {
2285
+ it('should handle entry with negative flatAmount', () => {
2552
2286
  const configs = createConfigs({
2553
2287
  order: {
2554
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: -10, category: 'cogs' })],
2288
+ entries: [
2289
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: -10, category: 'cogs' }),
2290
+ ],
2555
2291
  },
2556
2292
  });
2557
2293
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2558
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(-10);
2294
+ expect(result.categoryCosts.totalOtherCogs).toBe(-10);
2559
2295
  });
2560
- (0, vitest_1.it)('should handle entry with Infinity flatAmount', () => {
2296
+ it('should handle entry with Infinity flatAmount', () => {
2561
2297
  const configs = createConfigs({
2562
2298
  order: {
2563
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: Infinity, category: 'marketing' })],
2299
+ entries: [
2300
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: Infinity, category: 'marketing' }),
2301
+ ],
2564
2302
  },
2565
2303
  });
2566
2304
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2567
- (0, vitest_1.expect)(typeof result.categoryCosts.marketingCost).toBe('number');
2305
+ expect(typeof result.categoryCosts.marketingCost).toBe('number');
2568
2306
  });
2569
- (0, vitest_1.it)('should handle entry with string flatAmount', () => {
2307
+ it('should handle entry with string flatAmount', () => {
2570
2308
  const configs = createConfigs({
2571
2309
  order: {
2572
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: '10.50', category: 'opex' })],
2310
+ entries: [
2311
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: '10.50', category: 'opex' }),
2312
+ ],
2573
2313
  },
2574
2314
  });
2575
2315
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2576
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(10.5);
2316
+ expect(result.categoryCosts.opexCost).toBe(10.5);
2577
2317
  });
2578
2318
  });
2579
- (0, vitest_1.describe)('malformed percent rates', () => {
2580
- (0, vitest_1.it)('should handle undefined percentRate', () => {
2319
+ describe('malformed percent rates', () => {
2320
+ it('should handle undefined percentRate', () => {
2581
2321
  const configs = createConfigs({
2582
2322
  order: {
2583
2323
  entries: [
@@ -2587,9 +2327,9 @@ const createConfigs = (overrides = {}) => ({
2587
2327
  });
2588
2328
  const context = createContext({ totalPrice: 100 });
2589
2329
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2590
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(0);
2330
+ expect(result.categoryCosts.otherTransactionCost).toBe(0);
2591
2331
  });
2592
- (0, vitest_1.it)('should handle null percentRate', () => {
2332
+ it('should handle null percentRate', () => {
2593
2333
  const configs = createConfigs({
2594
2334
  order: {
2595
2335
  entries: [
@@ -2599,74 +2339,86 @@ const createConfigs = (overrides = {}) => ({
2599
2339
  });
2600
2340
  const context = createContext({ grossSalePrice: 200 });
2601
2341
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2602
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(0);
2342
+ expect(result.categoryCosts.agencyFeesCost).toBe(0);
2603
2343
  });
2604
- (0, vitest_1.it)('should handle negative percentRate', () => {
2344
+ it('should handle negative percentRate', () => {
2605
2345
  const configs = createConfigs({
2606
2346
  order: {
2607
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_NET_SALES, { percentRate: -5, category: 'marketing' })],
2347
+ entries: [
2348
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_NET_SALES, { percentRate: -5, category: 'marketing' }),
2349
+ ],
2608
2350
  },
2609
2351
  });
2610
2352
  const context = createContext({ netSalePrice: 100 });
2611
2353
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2612
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(-5);
2354
+ expect(result.categoryCosts.marketingCost).toBe(-5);
2613
2355
  });
2614
- (0, vitest_1.it)('should handle percentRate over 100', () => {
2356
+ it('should handle percentRate over 100', () => {
2615
2357
  const configs = createConfigs({
2616
2358
  order: {
2617
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { percentRate: 150, category: 'fulfillment' })],
2359
+ entries: [
2360
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, { percentRate: 150, category: 'fulfillment' }),
2361
+ ],
2618
2362
  },
2619
2363
  });
2620
2364
  const context = createContext({ totalProductCost: 50 });
2621
2365
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2622
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(75);
2366
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(75);
2623
2367
  });
2624
2368
  });
2625
- (0, vitest_1.describe)('malformed context data', () => {
2626
- (0, vitest_1.it)('should handle zero totalPrice for percent calculations', () => {
2369
+ describe('malformed context data', () => {
2370
+ it('should handle zero totalPrice for percent calculations', () => {
2627
2371
  const configs = createConfigs({
2628
2372
  order: {
2629
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 10, category: 'transaction' })],
2373
+ entries: [
2374
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 10, category: 'transaction' }),
2375
+ ],
2630
2376
  },
2631
2377
  });
2632
2378
  const context = createContext({ totalPrice: 0 });
2633
2379
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2634
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(0);
2380
+ expect(result.categoryCosts.otherTransactionCost).toBe(0);
2635
2381
  });
2636
- (0, vitest_1.it)('should handle negative totalPrice', () => {
2382
+ it('should handle negative totalPrice', () => {
2637
2383
  const configs = createConfigs({
2638
2384
  order: {
2639
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 10, category: 'cogs' })],
2385
+ entries: [
2386
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_TOTAL_SALES, { percentRate: 10, category: 'cogs' }),
2387
+ ],
2640
2388
  },
2641
2389
  });
2642
2390
  const context = createContext({ totalPrice: -100 });
2643
2391
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2644
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(-10);
2392
+ expect(result.categoryCosts.totalOtherCogs).toBe(-10);
2645
2393
  });
2646
- (0, vitest_1.it)('should handle empty lineItems array', () => {
2394
+ it('should handle empty lineItems array', () => {
2647
2395
  const configs = createConfigs({
2648
2396
  order: {
2649
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 5, category: 'fulfillment' })],
2397
+ entries: [
2398
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 5, category: 'fulfillment' }),
2399
+ ],
2650
2400
  },
2651
2401
  });
2652
2402
  const context = createContext({ lineItems: [] });
2653
2403
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2654
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
2655
- (0, vitest_1.expect)(result.lineItemCosts).toEqual({});
2404
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2405
+ expect(result.lineItemCosts).toEqual({});
2656
2406
  });
2657
- (0, vitest_1.it)('should handle lineItems with zero quantity', () => {
2407
+ it('should handle lineItems with zero quantity', () => {
2658
2408
  const configs = createConfigs({
2659
2409
  order: {
2660
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 5, category: 'marketing' })],
2410
+ entries: [
2411
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 5, category: 'marketing' }),
2412
+ ],
2661
2413
  },
2662
2414
  });
2663
2415
  const context = createContext({
2664
2416
  lineItems: [createLineItem({ quantity: 0 })],
2665
2417
  });
2666
2418
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2667
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(0);
2419
+ expect(result.categoryCosts.marketingCost).toBe(0);
2668
2420
  });
2669
- (0, vitest_1.it)('should handle undefined orderCreatedAt', () => {
2421
+ it('should handle undefined orderCreatedAt', () => {
2670
2422
  const configs = createConfigs({
2671
2423
  order: {
2672
2424
  entries: [
@@ -2681,9 +2433,9 @@ const createConfigs = (overrides = {}) => ({
2681
2433
  });
2682
2434
  const context = createContext({ orderCreatedAt: undefined });
2683
2435
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2684
- (0, vitest_1.expect)(typeof result.categoryCosts.totalOtherCogs).toBe('number');
2436
+ expect(typeof result.categoryCosts.totalOtherCogs).toBe('number');
2685
2437
  });
2686
- (0, vitest_1.it)('should handle invalid orderCreatedAt format', () => {
2438
+ it('should handle invalid orderCreatedAt format', () => {
2687
2439
  const configs = createConfigs({
2688
2440
  order: {
2689
2441
  entries: [
@@ -2697,46 +2449,46 @@ const createConfigs = (overrides = {}) => ({
2697
2449
  });
2698
2450
  const context = createContext({ orderCreatedAt: 'not-a-date' });
2699
2451
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2700
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(10);
2452
+ expect(result.categoryCosts.opexCost).toBe(10);
2701
2453
  });
2702
2454
  });
2703
- (0, vitest_1.describe)('currency edge cases', () => {
2704
- (0, vitest_1.it)('should handle empty currency string', () => {
2455
+ describe('currency edge cases', () => {
2456
+ it('should handle empty currency string', () => {
2705
2457
  const configs = createConfigs({
2706
2458
  order: {
2707
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, currency: '', category: 'cogs' })],
2459
+ entries: [
2460
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, currency: '', category: 'cogs' }),
2461
+ ],
2708
2462
  },
2709
2463
  });
2710
2464
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2711
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
2465
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2712
2466
  });
2713
- (0, vitest_1.it)('should handle null order currency', () => {
2467
+ it('should handle null order currency', () => {
2714
2468
  const configs = createConfigs({
2715
2469
  order: {
2716
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'fulfillment' })],
2470
+ entries: [
2471
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'fulfillment' }),
2472
+ ],
2717
2473
  },
2718
2474
  });
2719
2475
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), null, emptyRatesMap);
2720
- (0, vitest_1.expect)(typeof result.categoryCosts.otherFulfillmentCost).toBe('number');
2476
+ expect(typeof result.categoryCosts.otherFulfillmentCost).toBe('number');
2721
2477
  });
2722
- (0, vitest_1.it)('should handle missing exchange rates', () => {
2478
+ it('should handle missing exchange rates', () => {
2723
2479
  const configs = createConfigs({
2724
2480
  order: {
2725
2481
  entries: [
2726
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
2727
- flatAmount: 10,
2728
- currency: 'EUR',
2729
- category: 'transaction',
2730
- }),
2482
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, currency: 'EUR', category: 'transaction' }),
2731
2483
  ],
2732
2484
  },
2733
2485
  });
2734
2486
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', {});
2735
- (0, vitest_1.expect)(typeof result.categoryCosts.otherTransactionCost).toBe('number');
2487
+ expect(typeof result.categoryCosts.otherTransactionCost).toBe('number');
2736
2488
  });
2737
2489
  });
2738
- (0, vitest_1.describe)('weight and quantity tier edge cases', () => {
2739
- (0, vitest_1.it)('should fall back to flat mode when weightIntervals array is empty', () => {
2490
+ describe('weight and quantity tier edge cases', () => {
2491
+ it('should fall back to flat mode when weightIntervals array is empty', () => {
2740
2492
  const configs = createConfigs({
2741
2493
  order: {
2742
2494
  entries: [
@@ -2750,9 +2502,9 @@ const createConfigs = (overrides = {}) => ({
2750
2502
  });
2751
2503
  const context = createContext({ totalWeight: 1000 });
2752
2504
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2753
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(5000);
2505
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(5000);
2754
2506
  });
2755
- (0, vitest_1.it)('should fall back to flat mode when quantityIntervals array is empty', () => {
2507
+ it('should fall back to flat mode when quantityIntervals array is empty', () => {
2756
2508
  const configs = createConfigs({
2757
2509
  order: {
2758
2510
  entries: [
@@ -2766,9 +2518,9 @@ const createConfigs = (overrides = {}) => ({
2766
2518
  });
2767
2519
  const context = createContext({ lineItems: [createLineItem({ quantity: 10 })] });
2768
2520
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2769
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(50);
2521
+ expect(result.categoryCosts.totalOtherCogs).toBe(50);
2770
2522
  });
2771
- (0, vitest_1.it)('should handle weight outside all tier ranges', () => {
2523
+ it('should handle weight outside all tier ranges', () => {
2772
2524
  const configs = createConfigs({
2773
2525
  order: {
2774
2526
  entries: [
@@ -2785,9 +2537,9 @@ const createConfigs = (overrides = {}) => ({
2785
2537
  });
2786
2538
  const context = createContext({ totalWeight: 1000 });
2787
2539
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2788
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
2540
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2789
2541
  });
2790
- (0, vitest_1.it)('should handle zero totalWeight', () => {
2542
+ it('should handle zero totalWeight', () => {
2791
2543
  const configs = createConfigs({
2792
2544
  order: {
2793
2545
  entries: [
@@ -2801,9 +2553,9 @@ const createConfigs = (overrides = {}) => ({
2801
2553
  });
2802
2554
  const context = createContext({ totalWeight: 0 });
2803
2555
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2804
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(0);
2556
+ expect(result.categoryCosts.marketingCost).toBe(0);
2805
2557
  });
2806
- (0, vitest_1.it)('should handle negative totalWeight', () => {
2558
+ it('should handle negative totalWeight', () => {
2807
2559
  const configs = createConfigs({
2808
2560
  order: {
2809
2561
  entries: [
@@ -2817,21 +2569,23 @@ const createConfigs = (overrides = {}) => ({
2817
2569
  });
2818
2570
  const context = createContext({ totalWeight: -100 });
2819
2571
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2820
- (0, vitest_1.expect)(typeof result.categoryCosts.opexCost).toBe('number');
2572
+ expect(typeof result.categoryCosts.opexCost).toBe('number');
2821
2573
  });
2822
2574
  });
2823
- (0, vitest_1.describe)('filter context edge cases', () => {
2824
- (0, vitest_1.it)('should handle undefined orderFilterContext', () => {
2575
+ describe('filter context edge cases', () => {
2576
+ it('should handle undefined orderFilterContext', () => {
2825
2577
  const configs = createConfigs({
2826
2578
  order: {
2827
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'cogs' })],
2579
+ entries: [
2580
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'cogs' }),
2581
+ ],
2828
2582
  },
2829
2583
  });
2830
2584
  const context = createContext({ orderFilterContext: undefined });
2831
2585
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2832
- (0, vitest_1.expect)(typeof result.categoryCosts.totalOtherCogs).toBe('number');
2586
+ expect(typeof result.categoryCosts.totalOtherCogs).toBe('number');
2833
2587
  });
2834
- (0, vitest_1.it)('should handle empty tags array in filter context', () => {
2588
+ it('should handle empty tags array in filter context', () => {
2835
2589
  const configs = createConfigs({
2836
2590
  order: {
2837
2591
  entries: [
@@ -2849,11 +2603,11 @@ const createConfigs = (overrides = {}) => ({
2849
2603
  orderFilterContext: { tags: [], paymentGateways: [], shippingTitles: [] },
2850
2604
  });
2851
2605
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2852
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
2606
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2853
2607
  });
2854
2608
  });
2855
- (0, vitest_1.describe)('date range edge cases', () => {
2856
- (0, vitest_1.it)('should handle entry with effectiveFrom after effectiveTo', () => {
2609
+ describe('date range edge cases', () => {
2610
+ it('should handle entry with effectiveFrom after effectiveTo', () => {
2857
2611
  const configs = createConfigs({
2858
2612
  order: {
2859
2613
  entries: [
@@ -2868,9 +2622,9 @@ const createConfigs = (overrides = {}) => ({
2868
2622
  });
2869
2623
  const context = createContext({ orderCreatedAt: '2024-06-15T10:00:00Z' });
2870
2624
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2871
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(0);
2625
+ expect(result.categoryCosts.otherTransactionCost).toBe(0);
2872
2626
  });
2873
- (0, vitest_1.it)('should handle entry with same effectiveFrom and effectiveTo', () => {
2627
+ it('should handle entry with same effectiveFrom and effectiveTo', () => {
2874
2628
  const configs = createConfigs({
2875
2629
  order: {
2876
2630
  entries: [
@@ -2885,9 +2639,9 @@ const createConfigs = (overrides = {}) => ({
2885
2639
  });
2886
2640
  const context = createContext({ orderCreatedAt: '2024-06-15T10:00:00Z' });
2887
2641
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2888
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(10);
2642
+ expect(result.categoryCosts.agencyFeesCost).toBe(10);
2889
2643
  });
2890
- (0, vitest_1.it)('should handle invalid effectiveFrom format', () => {
2644
+ it('should handle invalid effectiveFrom format', () => {
2891
2645
  const configs = createConfigs({
2892
2646
  order: {
2893
2647
  entries: [
@@ -2901,11 +2655,11 @@ const createConfigs = (overrides = {}) => ({
2901
2655
  });
2902
2656
  const context = createContext({ orderCreatedAt: '2024-06-15T10:00:00Z' });
2903
2657
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2904
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(10);
2658
+ expect(result.categoryCosts.opexCost).toBe(10);
2905
2659
  });
2906
2660
  });
2907
- (0, vitest_1.describe)('concurrent category accumulation', () => {
2908
- (0, vitest_1.it)('should correctly accumulate when multiple entries have same ID but different categories', () => {
2661
+ describe('concurrent category accumulation', () => {
2662
+ it('should correctly accumulate when multiple entries have same ID but different categories', () => {
2909
2663
  const configs = createConfigs({
2910
2664
  order: {
2911
2665
  entries: [
@@ -2915,10 +2669,10 @@ const createConfigs = (overrides = {}) => ({
2915
2669
  },
2916
2670
  });
2917
2671
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2918
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
2919
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(5);
2672
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2673
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(5);
2920
2674
  });
2921
- (0, vitest_1.it)('should handle maximum number of entries without performance degradation', () => {
2675
+ it('should handle maximum number of entries without performance degradation', () => {
2922
2676
  const entries = Array.from({ length: 100 }, (_, i) => createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
2923
2677
  id: `entry-${i}`,
2924
2678
  flatAmount: 1,
@@ -2935,12 +2689,12 @@ const createConfigs = (overrides = {}) => ({
2935
2689
  result.categoryCosts.agencyFeesCost +
2936
2690
  result.categoryCosts.opexCost +
2937
2691
  result.categoryCosts.totalOtherCost;
2938
- (0, vitest_1.expect)(totalCost).toBe(100);
2692
+ expect(totalCost).toBe(100);
2939
2693
  });
2940
2694
  });
2941
2695
  });
2942
- (0, vitest_1.describe)('Accounting Identity Tests', () => {
2943
- (0, vitest_1.describe)('sum of category costs equals order + line-item level costs', () => {
2696
+ describe('Accounting Identity Tests', () => {
2697
+ describe('sum of category costs equals order + line-item level costs', () => {
2944
2698
  const sumCategoryCosts = (categoryCosts) => {
2945
2699
  return (categoryCosts.totalOtherCogs +
2946
2700
  categoryCosts.otherFulfillmentCost +
@@ -2950,19 +2704,21 @@ const createConfigs = (overrides = {}) => ({
2950
2704
  categoryCosts.opexCost +
2951
2705
  categoryCosts.totalOtherCost);
2952
2706
  };
2953
- (0, vitest_1.it)('should maintain identity with single order-level COGS entry', () => {
2707
+ it('should maintain identity with single order-level COGS entry', () => {
2954
2708
  const configs = createConfigs({
2955
2709
  order: {
2956
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 25, category: 'cogs' })],
2710
+ entries: [
2711
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 25, category: 'cogs' }),
2712
+ ],
2957
2713
  },
2958
2714
  });
2959
2715
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
2960
2716
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
2961
2717
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
2962
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
2963
- (0, vitest_1.expect)(sumOfCategories).toBe(25);
2718
+ expect(sumOfCategories).toBe(inputTotal);
2719
+ expect(sumOfCategories).toBe(25);
2964
2720
  });
2965
- (0, vitest_1.it)('should maintain identity with single line-item-level entry', () => {
2721
+ it('should maintain identity with single line-item-level entry', () => {
2966
2722
  const lineItems = [
2967
2723
  createLineItem({ lineItemId: 'li-1', quantity: 3 }),
2968
2724
  createLineItem({ lineItemId: 'li-2', quantity: 2 }),
@@ -2970,16 +2726,18 @@ const createConfigs = (overrides = {}) => ({
2970
2726
  const context = createContext({ lineItems, totalQuantity: 5 });
2971
2727
  const configs = createConfigs({
2972
2728
  order: {
2973
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 4, category: 'fulfillment' })],
2729
+ entries: [
2730
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_LINE_ITEM, { flatAmount: 4, category: 'fulfillment' }),
2731
+ ],
2974
2732
  },
2975
2733
  });
2976
2734
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
2977
2735
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
2978
2736
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
2979
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
2980
- (0, vitest_1.expect)(sumOfCategories).toBe(20);
2737
+ expect(sumOfCategories).toBe(inputTotal);
2738
+ expect(sumOfCategories).toBe(20);
2981
2739
  });
2982
- (0, vitest_1.it)('should maintain identity with mixed order-level and line-item-level entries across all categories', () => {
2740
+ it('should maintain identity with mixed order-level and line-item-level entries across all categories', () => {
2983
2741
  const lineItems = [
2984
2742
  createLineItem({ lineItemId: 'li-1', quantity: 2 }),
2985
2743
  createLineItem({ lineItemId: 'li-2', quantity: 3, refundedQuantity: 1 }),
@@ -3011,17 +2769,17 @@ const createConfigs = (overrides = {}) => ({
3011
2769
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3012
2770
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3013
2771
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3014
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3015
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
3016
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(10);
3017
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(5);
3018
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(5);
3019
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(15);
3020
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(5);
3021
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(3);
3022
- (0, vitest_1.expect)(sumOfCategories).toBe(53);
3023
- });
3024
- (0, vitest_1.it)('should maintain identity when entries are filtered out by date range', () => {
2772
+ expect(sumOfCategories).toBe(inputTotal);
2773
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2774
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(10);
2775
+ expect(result.categoryCosts.otherTransactionCost).toBe(5);
2776
+ expect(result.categoryCosts.marketingCost).toBe(5);
2777
+ expect(result.categoryCosts.agencyFeesCost).toBe(15);
2778
+ expect(result.categoryCosts.opexCost).toBe(5);
2779
+ expect(result.categoryCosts.totalOtherCost).toBe(3);
2780
+ expect(sumOfCategories).toBe(53);
2781
+ });
2782
+ it('should maintain identity when entries are filtered out by date range', () => {
3025
2783
  const configs = createConfigs({
3026
2784
  order: {
3027
2785
  entries: [
@@ -3049,13 +2807,13 @@ const createConfigs = (overrides = {}) => ({
3049
2807
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3050
2808
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3051
2809
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3052
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3053
- (0, vitest_1.expect)(sumOfCategories).toBe(10);
3054
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
3055
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
3056
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(0);
2810
+ expect(sumOfCategories).toBe(inputTotal);
2811
+ expect(sumOfCategories).toBe(10);
2812
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2813
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2814
+ expect(result.categoryCosts.marketingCost).toBe(0);
3057
2815
  });
3058
- (0, vitest_1.it)('should maintain identity when entries are filtered out by cost filters', () => {
2816
+ it('should maintain identity when entries are filtered out by cost filters', () => {
3059
2817
  const lineItems = [
3060
2818
  createLineItem({
3061
2819
  lineItemId: 'li-1',
@@ -3101,13 +2859,13 @@ const createConfigs = (overrides = {}) => ({
3101
2859
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3102
2860
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3103
2861
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3104
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3105
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
3106
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
3107
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(10);
3108
- (0, vitest_1.expect)(sumOfCategories).toBe(20);
2862
+ expect(sumOfCategories).toBe(inputTotal);
2863
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2864
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
2865
+ expect(result.categoryCosts.otherTransactionCost).toBe(10);
2866
+ expect(sumOfCategories).toBe(20);
3109
2867
  });
3110
- (0, vitest_1.it)('should maintain identity with multiple entries in same category', () => {
2868
+ it('should maintain identity with multiple entries in same category', () => {
3111
2869
  const configs = createConfigs({
3112
2870
  order: {
3113
2871
  entries: [
@@ -3120,11 +2878,11 @@ const createConfigs = (overrides = {}) => ({
3120
2878
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
3121
2879
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3122
2880
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3123
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3124
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(30);
3125
- (0, vitest_1.expect)(sumOfCategories).toBe(30);
2881
+ expect(sumOfCategories).toBe(inputTotal);
2882
+ expect(result.categoryCosts.totalOtherCogs).toBe(30);
2883
+ expect(sumOfCategories).toBe(30);
3126
2884
  });
3127
- (0, vitest_1.it)('should maintain identity with legacy category mappings', () => {
2885
+ it('should maintain identity with legacy category mappings', () => {
3128
2886
  const configs = createConfigs({
3129
2887
  order: {
3130
2888
  entries: [
@@ -3138,29 +2896,29 @@ const createConfigs = (overrides = {}) => ({
3138
2896
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
3139
2897
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3140
2898
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3141
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3142
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(15);
3143
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(28);
3144
- (0, vitest_1.expect)(sumOfCategories).toBe(43);
2899
+ expect(sumOfCategories).toBe(inputTotal);
2900
+ expect(result.categoryCosts.otherTransactionCost).toBe(15);
2901
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(28);
2902
+ expect(sumOfCategories).toBe(43);
3145
2903
  });
3146
- (0, vitest_1.it)('should maintain identity with empty config', () => {
2904
+ it('should maintain identity with empty config', () => {
3147
2905
  const configs = createConfigs({
3148
2906
  order: { entries: [] },
3149
2907
  });
3150
2908
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
3151
2909
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3152
2910
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3153
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3154
- (0, vitest_1.expect)(sumOfCategories).toBe(0);
2911
+ expect(sumOfCategories).toBe(inputTotal);
2912
+ expect(sumOfCategories).toBe(0);
3155
2913
  });
3156
- (0, vitest_1.it)('should maintain identity with null config', () => {
2914
+ it('should maintain identity with null config', () => {
3157
2915
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(null, createContext(), 'USD', emptyRatesMap);
3158
2916
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3159
2917
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3160
- (0, vitest_1.expect)(sumOfCategories).toBe(inputTotal);
3161
- (0, vitest_1.expect)(sumOfCategories).toBe(0);
2918
+ expect(sumOfCategories).toBe(inputTotal);
2919
+ expect(sumOfCategories).toBe(0);
3162
2920
  });
3163
- (0, vitest_1.it)('should maintain identity with currency conversion', () => {
2921
+ it('should maintain identity with currency conversion', () => {
3164
2922
  const exchangeRates = {
3165
2923
  USD: { EUR: 0.85, GBP: 0.73 },
3166
2924
  EUR: { USD: 1.18, GBP: 0.86 },
@@ -3169,11 +2927,7 @@ const createConfigs = (overrides = {}) => ({
3169
2927
  order: {
3170
2928
  entries: [
3171
2929
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'cogs', currency: 'EUR' }),
3172
- createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
3173
- flatAmount: 20,
3174
- category: 'fulfillment',
3175
- currency: 'GBP',
3176
- }),
2930
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 20, category: 'fulfillment', currency: 'GBP' }),
3177
2931
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 15, category: 'marketing', currency: 'USD' }),
3178
2932
  ],
3179
2933
  },
@@ -3181,11 +2935,11 @@ const createConfigs = (overrides = {}) => ({
3181
2935
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', exchangeRates);
3182
2936
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3183
2937
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3184
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3185
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBeCloseTo(10 * 1.18, 5);
3186
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(15);
2938
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
2939
+ expect(result.categoryCosts.totalOtherCogs).toBeCloseTo(10 * 1.18, 5);
2940
+ expect(result.categoryCosts.marketingCost).toBe(15);
3187
2941
  });
3188
- (0, vitest_1.it)('should maintain identity with percentage-based entries', () => {
2942
+ it('should maintain identity with percentage-based entries', () => {
3189
2943
  const context = createContext({
3190
2944
  totalProductCost: 100,
3191
2945
  totalShipping: 50,
@@ -3207,15 +2961,15 @@ const createConfigs = (overrides = {}) => ({
3207
2961
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3208
2962
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3209
2963
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3210
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3211
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(10);
3212
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(10);
3213
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(10);
3214
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(20);
3215
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(5.4);
3216
- (0, vitest_1.expect)(sumOfCategories).toBe(55.4);
3217
- });
3218
- (0, vitest_1.it)('should maintain identity with weight-based entries', () => {
2964
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
2965
+ expect(result.categoryCosts.totalOtherCogs).toBe(10);
2966
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(10);
2967
+ expect(result.categoryCosts.otherTransactionCost).toBe(10);
2968
+ expect(result.categoryCosts.marketingCost).toBe(20);
2969
+ expect(result.categoryCosts.opexCost).toBe(5.4);
2970
+ expect(sumOfCategories).toBe(55.4);
2971
+ });
2972
+ it('should maintain identity with weight-based entries', () => {
3219
2973
  const context = createContext({ totalWeight: 1500 });
3220
2974
  const configs = createConfigs({
3221
2975
  order: {
@@ -3231,10 +2985,10 @@ const createConfigs = (overrides = {}) => ({
3231
2985
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3232
2986
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3233
2987
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3234
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3235
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0.75);
2988
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
2989
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0.75);
3236
2990
  });
3237
- (0, vitest_1.it)('should maintain identity with weight-tiered entries', () => {
2991
+ it('should maintain identity with weight-tiered entries', () => {
3238
2992
  const context = createContext({ totalWeight: 750 });
3239
2993
  const configs = createConfigs({
3240
2994
  order: {
@@ -3254,10 +3008,10 @@ const createConfigs = (overrides = {}) => ({
3254
3008
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3255
3009
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3256
3010
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3257
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3258
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(8);
3011
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
3012
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(8);
3259
3013
  });
3260
- (0, vitest_1.it)('should maintain identity with quantity-tiered entries', () => {
3014
+ it('should maintain identity with quantity-tiered entries', () => {
3261
3015
  const context = createContext({
3262
3016
  lineItems: [
3263
3017
  createLineItem({ lineItemId: '1', quantity: 5 }),
@@ -3281,27 +3035,29 @@ const createConfigs = (overrides = {}) => ({
3281
3035
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3282
3036
  const sumOfCategories = sumCategoryCosts(result.categoryCosts);
3283
3037
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3284
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3285
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(18);
3038
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
3039
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(18);
3286
3040
  });
3287
3041
  });
3288
- (0, vitest_1.describe)('no double-counting between categories', () => {
3289
- (0, vitest_1.it)('should route each entry to exactly one category', () => {
3042
+ describe('no double-counting between categories', () => {
3043
+ it('should route each entry to exactly one category', () => {
3290
3044
  const configs = createConfigs({
3291
3045
  order: {
3292
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'e1', flatAmount: 100, category: 'cogs' })],
3046
+ entries: [
3047
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { id: 'e1', flatAmount: 100, category: 'cogs' }),
3048
+ ],
3293
3049
  },
3294
3050
  });
3295
3051
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
3296
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBe(100);
3297
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBe(0);
3298
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(0);
3299
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBe(0);
3300
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBe(0);
3301
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBe(0);
3302
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBe(0);
3303
- });
3304
- (0, vitest_1.it)('should not double-count when entry matches multiple conditions', () => {
3052
+ expect(result.categoryCosts.totalOtherCogs).toBe(100);
3053
+ expect(result.categoryCosts.otherFulfillmentCost).toBe(0);
3054
+ expect(result.categoryCosts.otherTransactionCost).toBe(0);
3055
+ expect(result.categoryCosts.marketingCost).toBe(0);
3056
+ expect(result.categoryCosts.agencyFeesCost).toBe(0);
3057
+ expect(result.categoryCosts.opexCost).toBe(0);
3058
+ expect(result.categoryCosts.totalOtherCost).toBe(0);
3059
+ });
3060
+ it('should not double-count when entry matches multiple conditions', () => {
3305
3061
  const lineItems = [
3306
3062
  createLineItem({
3307
3063
  lineItemId: 'li-1',
@@ -3334,12 +3090,12 @@ const createConfigs = (overrides = {}) => ({
3334
3090
  },
3335
3091
  });
3336
3092
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, context, 'USD', emptyRatesMap);
3337
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBe(50);
3338
- (0, vitest_1.expect)(result.orderLevelOtherCost + result.lineItemLevelOtherCost).toBe(50);
3093
+ expect(result.categoryCosts.otherTransactionCost).toBe(50);
3094
+ expect(result.orderLevelOtherCost + result.lineItemLevelOtherCost).toBe(50);
3339
3095
  });
3340
3096
  });
3341
- (0, vitest_1.describe)('handling/gateway/shipping costs are separate from category costs', () => {
3342
- (0, vitest_1.it)('should not include handling costs in category cost sum', () => {
3097
+ describe('handling/gateway/shipping costs are separate from category costs', () => {
3098
+ it('should not include handling costs in category cost sum', () => {
3343
3099
  const lineItems = [
3344
3100
  createLineItem({ lineItemId: 'li-1', quantity: 2, variantHandlingFee: 5 }),
3345
3101
  createLineItem({ lineItemId: 'li-2', quantity: 1, variantHandlingFee: 3 }),
@@ -3347,7 +3103,9 @@ const createConfigs = (overrides = {}) => ({
3347
3103
  const configs = createConfigs({
3348
3104
  globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
3349
3105
  order: {
3350
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'cogs' })],
3106
+ entries: [
3107
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'cogs' }),
3108
+ ],
3351
3109
  },
3352
3110
  });
3353
3111
  const context = createContext({ lineItems, totalQuantity: 3 });
@@ -3359,19 +3117,21 @@ const createConfigs = (overrides = {}) => ({
3359
3117
  result.categoryCosts.agencyFeesCost +
3360
3118
  result.categoryCosts.opexCost +
3361
3119
  result.categoryCosts.totalOtherCost;
3362
- (0, vitest_1.expect)(sumOfCategories).toBe(10);
3363
- (0, vitest_1.expect)(result.totalHandlingCost).toBe(13);
3364
- (0, vitest_1.expect)(result.lineItemLevelHandlingCost).toBe(13);
3120
+ expect(sumOfCategories).toBe(10);
3121
+ expect(result.totalHandlingCost).toBe(13);
3122
+ expect(result.lineItemLevelHandlingCost).toBe(13);
3365
3123
  });
3366
- (0, vitest_1.it)('should not include gateway costs in category cost sum', () => {
3124
+ it('should not include gateway costs in category cost sum', () => {
3367
3125
  const configs = createConfigs({
3368
3126
  gateway: {
3369
3127
  entries: [
3370
- { id: 'g1', name: 'Stripe', gatewayName: 'stripe', flatAmount: 0.3, percentRate: 2.9, currency: 'USD' },
3128
+ { id: 'g1', name: 'Stripe', gatewayName: 'stripe', flatAmount: 0.30, percentRate: 2.9, currency: 'USD' },
3371
3129
  ],
3372
3130
  },
3373
3131
  order: {
3374
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'fulfillment' })],
3132
+ entries: [
3133
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'fulfillment' }),
3134
+ ],
3375
3135
  },
3376
3136
  });
3377
3137
  const context = createContext({ totalPrice: 100 });
@@ -3383,10 +3143,10 @@ const createConfigs = (overrides = {}) => ({
3383
3143
  result.categoryCosts.agencyFeesCost +
3384
3144
  result.categoryCosts.opexCost +
3385
3145
  result.categoryCosts.totalOtherCost;
3386
- (0, vitest_1.expect)(sumOfCategories).toBe(10);
3387
- (0, vitest_1.expect)(result.totalGatewayCost).toBe(3.2);
3146
+ expect(sumOfCategories).toBe(10);
3147
+ expect(result.totalGatewayCost).toBe(3.2);
3388
3148
  });
3389
- (0, vitest_1.it)('should not include shipping costs in category cost sum', () => {
3149
+ it('should not include shipping costs in category cost sum', () => {
3390
3150
  const configs = createConfigs({
3391
3151
  shipping: {
3392
3152
  method: at_tracking_event_types_1.SHIPPING_METHOD.FIXED_RATE,
@@ -3394,7 +3154,9 @@ const createConfigs = (overrides = {}) => ({
3394
3154
  currency: 'USD',
3395
3155
  },
3396
3156
  order: {
3397
- entries: [createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'marketing' })],
3157
+ entries: [
3158
+ createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, { flatAmount: 10, category: 'marketing' }),
3159
+ ],
3398
3160
  },
3399
3161
  });
3400
3162
  const result = cost_calculator_service_1.CostCalculatorService.calculateOrderCosts(configs, createContext(), 'USD', emptyRatesMap);
@@ -3405,18 +3167,18 @@ const createConfigs = (overrides = {}) => ({
3405
3167
  result.categoryCosts.agencyFeesCost +
3406
3168
  result.categoryCosts.opexCost +
3407
3169
  result.categoryCosts.totalOtherCost;
3408
- (0, vitest_1.expect)(sumOfCategories).toBe(10);
3409
- (0, vitest_1.expect)(result.totalShippingCost).toBe(15);
3170
+ expect(sumOfCategories).toBe(10);
3171
+ expect(result.totalShippingCost).toBe(15);
3410
3172
  });
3411
3173
  });
3412
- (0, vitest_1.describe)('stress test: large realistic order with all cost types', () => {
3413
- (0, vitest_1.it)('should maintain accounting identity with complex realistic order', () => {
3174
+ describe('stress test: large realistic order with all cost types', () => {
3175
+ it('should maintain accounting identity with complex realistic order', () => {
3414
3176
  const lineItems = [
3415
3177
  createLineItem({
3416
3178
  lineItemId: 'li-1',
3417
3179
  quantity: 5,
3418
3180
  refundedQuantity: 0,
3419
- variantHandlingFee: 1.5,
3181
+ variantHandlingFee: 1.50,
3420
3182
  filterContext: { tags: ['electronics'], productId: '100', variantId: '200', vendor: 'Samsung' },
3421
3183
  }),
3422
3184
  createLineItem({
@@ -3430,17 +3192,17 @@ const createConfigs = (overrides = {}) => ({
3430
3192
  lineItemId: 'li-3',
3431
3193
  quantity: 2,
3432
3194
  refundedQuantity: 0,
3433
- variantHandlingFee: 2.0,
3195
+ variantHandlingFee: 2.00,
3434
3196
  filterContext: { tags: ['premium', 'electronics'], productId: '102', variantId: '202', vendor: 'Apple' },
3435
3197
  }),
3436
3198
  ];
3437
3199
  const context = createContext({
3438
3200
  orderCreatedAt: '2024-06-15T10:00:00Z',
3439
- totalPrice: 850.0,
3440
- grossSalePrice: 920.0,
3441
- netSalePrice: 780.0,
3442
- totalProductCost: 425.0,
3443
- totalShipping: 25.0,
3201
+ totalPrice: 850.00,
3202
+ grossSalePrice: 920.00,
3203
+ netSalePrice: 780.00,
3204
+ totalProductCost: 425.00,
3205
+ totalShipping: 25.00,
3444
3206
  totalWeight: 2500,
3445
3207
  totalQuantity: 10,
3446
3208
  hasRefund: true,
@@ -3460,7 +3222,7 @@ const createConfigs = (overrides = {}) => ({
3460
3222
  };
3461
3223
  const configs = createConfigs({
3462
3224
  globalProductOverride: {
3463
- globalHandlingFee: 0.5,
3225
+ globalHandlingFee: 0.50,
3464
3226
  currency: 'USD',
3465
3227
  },
3466
3228
  gateway: {
@@ -3469,7 +3231,7 @@ const createConfigs = (overrides = {}) => ({
3469
3231
  id: 'stripe',
3470
3232
  name: 'Stripe',
3471
3233
  gatewayName: 'stripe',
3472
- flatAmount: 0.3,
3234
+ flatAmount: 0.30,
3473
3235
  percentRate: 2.9,
3474
3236
  currency: 'USD',
3475
3237
  },
@@ -3484,7 +3246,7 @@ const createConfigs = (overrides = {}) => ({
3484
3246
  countries: ['US'],
3485
3247
  isDefault: false,
3486
3248
  rateType: at_tracking_event_types_1.SHIPPING_RATE_TYPE.FLAT,
3487
- flatAmount: 12.0,
3249
+ flatAmount: 12.00,
3488
3250
  currency: 'USD',
3489
3251
  },
3490
3252
  {
@@ -3507,7 +3269,7 @@ const createConfigs = (overrides = {}) => ({
3507
3269
  entries: [
3508
3270
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
3509
3271
  id: 'packaging-base',
3510
- flatAmount: 2.0,
3272
+ flatAmount: 2.00,
3511
3273
  category: 'cogs',
3512
3274
  }),
3513
3275
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PCT_COGS, {
@@ -3537,7 +3299,7 @@ const createConfigs = (overrides = {}) => ({
3537
3299
  }),
3538
3300
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_ORDER, {
3539
3301
  id: 'agency-retainer-allocation',
3540
- flatAmount: 8.0,
3302
+ flatAmount: 8.00,
3541
3303
  currency: 'EUR',
3542
3304
  category: 'agency_fees',
3543
3305
  }),
@@ -3548,12 +3310,12 @@ const createConfigs = (overrides = {}) => ({
3548
3310
  }),
3549
3311
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_ORDER, {
3550
3312
  id: 'refund-processing',
3551
- flatAmount: 5.0,
3313
+ flatAmount: 5.00,
3552
3314
  category: 'opex',
3553
3315
  }),
3554
3316
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.PER_REFUND_LINE_ITEM, {
3555
3317
  id: 'restocking-fee',
3556
- flatAmount: 3.0,
3318
+ flatAmount: 3.00,
3557
3319
  category: 'other',
3558
3320
  }),
3559
3321
  createEntry(at_tracking_event_types_1.ORDER_COST_ENTRY_TYPE.BY_LINE_ITEM_QUANTITY, {
@@ -3577,22 +3339,22 @@ const createConfigs = (overrides = {}) => ({
3577
3339
  result.categoryCosts.opexCost +
3578
3340
  result.categoryCosts.totalOtherCost;
3579
3341
  const inputTotal = result.orderLevelOtherCost + result.lineItemLevelOtherCost;
3580
- (0, vitest_1.expect)(sumOfCategories).toBeCloseTo(inputTotal, 5);
3581
- (0, vitest_1.expect)(Number.isFinite(sumOfCategories)).toBe(true);
3582
- (0, vitest_1.expect)(sumOfCategories).toBeGreaterThanOrEqual(0);
3583
- (0, vitest_1.expect)(Number.isFinite(result.totalHandlingCost)).toBe(true);
3584
- (0, vitest_1.expect)(Number.isFinite(result.totalGatewayCost)).toBe(true);
3585
- (0, vitest_1.expect)(Number.isFinite(result.totalShippingCost)).toBe(true);
3586
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCogs).toBeGreaterThan(0);
3587
- (0, vitest_1.expect)(result.categoryCosts.otherFulfillmentCost).toBeGreaterThan(0);
3588
- (0, vitest_1.expect)(result.categoryCosts.otherTransactionCost).toBeGreaterThan(0);
3589
- (0, vitest_1.expect)(result.categoryCosts.marketingCost).toBeGreaterThan(0);
3590
- (0, vitest_1.expect)(result.categoryCosts.agencyFeesCost).toBeGreaterThan(0);
3591
- (0, vitest_1.expect)(result.categoryCosts.opexCost).toBeGreaterThan(0);
3592
- (0, vitest_1.expect)(result.categoryCosts.totalOtherCost).toBeGreaterThan(0);
3593
- (0, vitest_1.expect)(result.totalHandlingCost).toBeGreaterThan(0);
3594
- (0, vitest_1.expect)(result.totalGatewayCost).toBeGreaterThan(0);
3595
- (0, vitest_1.expect)(result.totalShippingCost).toBeGreaterThan(0);
3342
+ expect(sumOfCategories).toBeCloseTo(inputTotal, 5);
3343
+ expect(Number.isFinite(sumOfCategories)).toBe(true);
3344
+ expect(sumOfCategories).toBeGreaterThanOrEqual(0);
3345
+ expect(Number.isFinite(result.totalHandlingCost)).toBe(true);
3346
+ expect(Number.isFinite(result.totalGatewayCost)).toBe(true);
3347
+ expect(Number.isFinite(result.totalShippingCost)).toBe(true);
3348
+ expect(result.categoryCosts.totalOtherCogs).toBeGreaterThan(0);
3349
+ expect(result.categoryCosts.otherFulfillmentCost).toBeGreaterThan(0);
3350
+ expect(result.categoryCosts.otherTransactionCost).toBeGreaterThan(0);
3351
+ expect(result.categoryCosts.marketingCost).toBeGreaterThan(0);
3352
+ expect(result.categoryCosts.agencyFeesCost).toBeGreaterThan(0);
3353
+ expect(result.categoryCosts.opexCost).toBeGreaterThan(0);
3354
+ expect(result.categoryCosts.totalOtherCost).toBeGreaterThan(0);
3355
+ expect(result.totalHandlingCost).toBeGreaterThan(0);
3356
+ expect(result.totalGatewayCost).toBeGreaterThan(0);
3357
+ expect(result.totalShippingCost).toBeGreaterThan(0);
3596
3358
  });
3597
3359
  });
3598
3360
  });