@pisell/pisellos 0.10.90 → 0.10.93

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 (229) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  6. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  7. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  8. package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
  9. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  10. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  11. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  12. package/dist/modules/BookingContext/utils/index.js +1 -0
  13. package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
  14. package/dist/modules/BookingContext/utils/productExtend.js +132 -33
  15. package/dist/modules/BookingContext/utils/resources.js +1 -1
  16. package/dist/modules/Cart/index.js +4 -3
  17. package/dist/modules/Cart/types.d.ts +2 -0
  18. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  19. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  20. package/dist/modules/Date/index.d.ts +1 -1
  21. package/dist/modules/Date/index.js +60 -14
  22. package/dist/modules/Date/types.d.ts +5 -0
  23. package/dist/modules/OpenData/salesSettings.js +1 -1
  24. package/dist/modules/OpenData/types.d.ts +9 -0
  25. package/dist/modules/OpenData/utils.d.ts +1 -1
  26. package/dist/modules/OpenData/utils.js +3 -2
  27. package/dist/modules/Order/index.d.ts +22 -7
  28. package/dist/modules/Order/index.js +1565 -1161
  29. package/dist/modules/Order/localEftposState.d.ts +13 -0
  30. package/dist/modules/Order/localEftposState.js +39 -0
  31. package/dist/modules/Order/types.d.ts +33 -11
  32. package/dist/modules/Order/types.js +2 -2
  33. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  34. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  35. package/dist/modules/Order/utils.d.ts +4 -1
  36. package/dist/modules/Order/utils.js +75 -52
  37. package/dist/modules/Payment/walletpass.js +32 -6
  38. package/dist/modules/Product/index.d.ts +1 -1
  39. package/dist/modules/Product/types.d.ts +16 -0
  40. package/dist/modules/ProductList/index.js +1 -1
  41. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  42. package/dist/modules/ResourcePlanner/planner.js +383 -24
  43. package/dist/modules/ResourcePlanner/types.d.ts +42 -0
  44. package/dist/modules/Rules/index.js +86 -54
  45. package/dist/modules/Schedule/index.d.ts +7 -1
  46. package/dist/modules/Schedule/index.js +155 -39
  47. package/dist/modules/Schedule/types.d.ts +2 -0
  48. package/dist/modules/bookingReadValidation.d.ts +6 -0
  49. package/dist/modules/bookingReadValidation.js +72 -0
  50. package/dist/plugins/request.d.ts +2 -0
  51. package/dist/server/index.d.ts +9 -0
  52. package/dist/server/index.js +1928 -1462
  53. package/dist/server/modules/form/index.d.ts +19 -0
  54. package/dist/server/modules/form/index.js +205 -0
  55. package/dist/server/modules/form/types.d.ts +13 -0
  56. package/dist/server/modules/form/types.js +3 -0
  57. package/dist/server/modules/index.d.ts +3 -0
  58. package/dist/server/modules/index.js +4 -0
  59. package/dist/server/modules/order/index.d.ts +21 -0
  60. package/dist/server/modules/order/index.js +1399 -831
  61. package/dist/server/modules/order/types.d.ts +3 -0
  62. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  63. package/dist/server/modules/products/index.d.ts +28 -7
  64. package/dist/server/modules/products/index.js +1295 -769
  65. package/dist/server/modules/products/replication.d.ts +8 -0
  66. package/dist/server/modules/products/replication.js +69 -0
  67. package/dist/server/modules/products/types.d.ts +12 -1
  68. package/dist/server/modules/products/types.js +4 -0
  69. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  70. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  71. package/dist/shared/receipt/small-ticket.d.ts +1 -0
  72. package/dist/shared/receipt/small-ticket.js +58 -26
  73. package/dist/shared/receipt/templateVisibility.d.ts +3 -0
  74. package/dist/shared/receipt/templateVisibility.js +6 -2
  75. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  76. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  77. package/dist/solution/BaseSales/index.d.ts +22 -6
  78. package/dist/solution/BaseSales/index.js +1881 -1347
  79. package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
  80. package/dist/solution/BaseSales/pickupTiming.js +35 -8
  81. package/dist/solution/BaseSales/types.d.ts +4 -0
  82. package/dist/solution/BaseSales/types.js +1 -0
  83. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  84. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  85. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  86. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  87. package/dist/solution/BookingByStep/index.d.ts +20 -4
  88. package/dist/solution/BookingByStep/index.js +681 -361
  89. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  90. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  91. package/dist/solution/BookingTicket/index.d.ts +10 -0
  92. package/dist/solution/BookingTicket/index.js +686 -598
  93. package/dist/solution/BookingTicket/types.d.ts +1 -1
  94. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  95. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  96. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  97. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  98. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  99. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
  100. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  101. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
  102. package/dist/solution/OrderInvoicePreview/index.js +4 -3
  103. package/dist/solution/Sales/index.js +1 -1
  104. package/dist/solution/ScanOrder/index.d.ts +2 -0
  105. package/dist/solution/ScanOrder/index.js +230 -97
  106. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  107. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  108. package/dist/solution/ScanOrder/types.d.ts +3 -0
  109. package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
  110. package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
  111. package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
  112. package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
  113. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  114. package/dist/utils/pos-receipt-auto-print.js +14 -0
  115. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  116. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  117. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  118. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  119. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  120. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  121. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  122. package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
  123. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  124. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  125. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  126. package/lib/modules/BookingContext/utils/index.js +11 -0
  127. package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
  128. package/lib/modules/BookingContext/utils/productExtend.js +104 -5
  129. package/lib/modules/BookingContext/utils/resources.js +1 -1
  130. package/lib/modules/Cart/index.js +4 -2
  131. package/lib/modules/Cart/types.d.ts +2 -0
  132. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  133. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  134. package/lib/modules/Date/index.d.ts +1 -1
  135. package/lib/modules/Date/index.js +28 -5
  136. package/lib/modules/Date/types.d.ts +5 -0
  137. package/lib/modules/OpenData/salesSettings.js +1 -1
  138. package/lib/modules/OpenData/types.d.ts +9 -0
  139. package/lib/modules/OpenData/utils.d.ts +1 -1
  140. package/lib/modules/OpenData/utils.js +3 -2
  141. package/lib/modules/Order/index.d.ts +22 -7
  142. package/lib/modules/Order/index.js +457 -174
  143. package/lib/modules/Order/localEftposState.d.ts +13 -0
  144. package/lib/modules/Order/localEftposState.js +44 -0
  145. package/lib/modules/Order/types.d.ts +33 -11
  146. package/lib/modules/Order/types.js +2 -2
  147. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  148. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  149. package/lib/modules/Order/utils.d.ts +4 -1
  150. package/lib/modules/Order/utils.js +29 -3
  151. package/lib/modules/Payment/walletpass.js +23 -1
  152. package/lib/modules/Product/index.d.ts +1 -1
  153. package/lib/modules/Product/types.d.ts +16 -0
  154. package/lib/modules/ProductList/index.js +1 -1
  155. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  156. package/lib/modules/ResourcePlanner/planner.js +299 -9
  157. package/lib/modules/ResourcePlanner/types.d.ts +42 -0
  158. package/lib/modules/Rules/index.js +32 -3
  159. package/lib/modules/Schedule/index.d.ts +7 -1
  160. package/lib/modules/Schedule/index.js +68 -4
  161. package/lib/modules/Schedule/types.d.ts +2 -0
  162. package/lib/modules/bookingReadValidation.d.ts +6 -0
  163. package/lib/modules/bookingReadValidation.js +56 -0
  164. package/lib/plugins/request.d.ts +2 -0
  165. package/lib/server/index.d.ts +9 -0
  166. package/lib/server/index.js +279 -30
  167. package/lib/server/modules/form/index.d.ts +19 -0
  168. package/lib/server/modules/form/index.js +73 -0
  169. package/lib/server/modules/form/types.d.ts +13 -0
  170. package/lib/server/modules/form/types.js +9 -0
  171. package/lib/server/modules/index.d.ts +3 -0
  172. package/lib/server/modules/index.js +15 -1
  173. package/lib/server/modules/order/index.d.ts +21 -0
  174. package/lib/server/modules/order/index.js +344 -35
  175. package/lib/server/modules/order/types.d.ts +3 -0
  176. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  177. package/lib/server/modules/products/index.d.ts +28 -7
  178. package/lib/server/modules/products/index.js +224 -62
  179. package/lib/server/modules/products/replication.d.ts +8 -0
  180. package/lib/server/modules/products/replication.js +30 -0
  181. package/lib/server/modules/products/types.d.ts +12 -1
  182. package/lib/server/modules/products/types.js +3 -0
  183. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  184. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  185. package/lib/shared/receipt/small-ticket.d.ts +1 -0
  186. package/lib/shared/receipt/small-ticket.js +53 -25
  187. package/lib/shared/receipt/templateVisibility.d.ts +3 -0
  188. package/lib/shared/receipt/templateVisibility.js +6 -2
  189. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  190. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  191. package/lib/solution/BaseSales/index.d.ts +22 -6
  192. package/lib/solution/BaseSales/index.js +347 -59
  193. package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
  194. package/lib/solution/BaseSales/pickupTiming.js +24 -3
  195. package/lib/solution/BaseSales/types.d.ts +4 -0
  196. package/lib/solution/BaseSales/types.js +1 -0
  197. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  198. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  199. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  200. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  201. package/lib/solution/BookingByStep/index.d.ts +20 -4
  202. package/lib/solution/BookingByStep/index.js +229 -17
  203. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  204. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  205. package/lib/solution/BookingTicket/index.d.ts +10 -0
  206. package/lib/solution/BookingTicket/index.js +57 -6
  207. package/lib/solution/BookingTicket/types.d.ts +1 -1
  208. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  209. package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
  210. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  211. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  212. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  213. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  214. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  215. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
  216. package/lib/solution/OrderInvoicePreview/index.js +1 -0
  217. package/lib/solution/Sales/index.js +1 -1
  218. package/lib/solution/ScanOrder/index.d.ts +2 -0
  219. package/lib/solution/ScanOrder/index.js +131 -22
  220. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  221. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  222. package/lib/solution/ScanOrder/types.d.ts +3 -0
  223. package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
  224. package/lib/solution/UnifiedBookingSales/index.js +717 -144
  225. package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
  226. package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
  227. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  228. package/lib/utils/pos-receipt-auto-print.js +13 -0
  229. package/package.json +1 -1
@@ -7,11 +7,13 @@ exports.buildSmallTicketData = buildSmallTicketData;
7
7
  exports.hasSmallTicketData = hasSmallTicketData;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _decimal = _interopRequireDefault(require("decimal.js"));
10
+ var _unpaidAmountGap = require("../../modules/Order/unpaidAmountGap");
10
11
  var _holderRelations = require("../../modules/Order/holderRelations");
11
12
  var _pickupTiming = require("../../modules/Order/pickupTiming");
12
13
  var _templateVisibility = require("./templateVisibility");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  const DEFAULT_LOCALES = ['en', 'zh_CN'];
16
+ const BOOKING_ID_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
15
17
 
16
18
  // Attach provenance to a private copy BEFORE any locale-dependent filtering.
17
19
  // Symbols survive the existing spread-based normalization, never enter JSON,
@@ -84,6 +86,7 @@ const LABELS = {
84
86
  cashReceived: 'Cash received',
85
87
  changeDue: 'Change due',
86
88
  eftpos: 'Eftpos',
89
+ creditCard: 'Credit card',
87
90
  wallet: 'Wallet',
88
91
  giftCard: 'Gift card',
89
92
  pointCard: 'Point card',
@@ -130,6 +133,7 @@ const LABELS = {
130
133
  cashReceived: '收取现金',
131
134
  changeDue: '找零',
132
135
  eftpos: '刷卡支付',
136
+ creditCard: '信用卡',
133
137
  wallet: '钱包支付',
134
138
  giftCard: '礼品卡',
135
139
  pointCard: '积分卡',
@@ -176,6 +180,7 @@ const LABELS = {
176
180
  cashReceived: '收取現金',
177
181
  changeDue: '找零',
178
182
  eftpos: '刷卡支付',
183
+ creditCard: '信用卡',
179
184
  wallet: '錢包支付',
180
185
  giftCard: '禮品卡',
181
186
  pointCard: '積分卡',
@@ -220,6 +225,7 @@ const LABELS = {
220
225
  asap: 'できるだけ早く',
221
226
  cash: '現金',
222
227
  eftpos: 'カード',
228
+ creditCard: 'クレジットカード',
223
229
  wallet: 'ウォレット',
224
230
  giftCard: 'ギフトカード',
225
231
  pointCard: 'ポイントカード',
@@ -265,6 +271,7 @@ const LABELS = {
265
271
  asap: 'Assim que possível',
266
272
  cash: 'Dinheiro',
267
273
  eftpos: 'Cartão',
274
+ creditCard: 'Cartão de crédito',
268
275
  wallet: 'Carteira',
269
276
  giftCard: 'Cartão-presente',
270
277
  pointCard: 'Cartão de pontos',
@@ -294,7 +301,8 @@ const LABELS = {
294
301
  }
295
302
  };
296
303
  function buildSmallTicketData(params) {
297
- const order = params.includeReceiptKeys ? copyReceiptSource(params.order || {}) : params.order || {};
304
+ const normalizedOrder = (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(params.order || {});
305
+ const order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
298
306
  const shopInfo = params.shopInfo || {};
299
307
  const locales = resolveLocales(shopInfo, params.locales);
300
308
  const productMap = params.productMap || {};
@@ -347,7 +355,7 @@ function buildLocaleData(params) {
347
355
  financials
348
356
  }),
349
357
  customer: buildCustomer(order, locale, visibility.customer),
350
- appointment: buildAppointment(order, locale),
358
+ appointment: buildAppointment(order, locale, visibility.lineGroups.resourceTitle),
351
359
  ...(delivery.length ? {
352
360
  delivery
353
361
  } : {}),
@@ -414,7 +422,10 @@ function buildBaseData(params) {
414
422
  };
415
423
  }
416
424
  function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
417
- const domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
425
+ const default_domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
426
+ const private_domain = typeof shopInfo.private_domain === 'string' ? shopInfo.private_domain.trim() : '';
427
+ // 私有域名优先于默认域名
428
+ const domain = default_domain;
418
429
  const orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
419
430
  if (!domain || !orderNumber) return undefined;
420
431
  try {
@@ -476,7 +487,7 @@ function buildProducts(order, locale, productMap) {
476
487
  if (holderName) {
477
488
  // 复用 Web Invoice / 原生均支持的文本扩展行,不混入金额或商品备注。
478
489
  extensionList.push({
479
- ...receiptKey(rawProduct, 'product-holder', 'text'),
490
+ ...receiptKey(rawProduct, 'product-holder'),
480
491
  item: `${label(locale, 'productHolder')}: ${holderName}`,
481
492
  value: ''
482
493
  });
@@ -1201,13 +1212,6 @@ function buildFees(params) {
1201
1212
  const isPriceIncludeTax = firstPresentValue(summary.is_price_include_tax, order.is_price_include_tax, shopInfo.is_price_include_tax);
1202
1213
  const roundingAmount = firstPresentValue(summary.rounding_amount, order.rounding_amount);
1203
1214
  const payProcessingFee = financials.payProcessingFee;
1204
- if (isNonZero(payProcessingFee)) {
1205
- fees.push({
1206
- ...receiptKey(order, 'payment-processing-fee'),
1207
- item: label(locale, 'payProcessingFee'),
1208
- value: formatMoney(payProcessingFee, currencySymbol)
1209
- });
1210
- }
1211
1215
  const productExpectAmount = firstPresentValue(summary.product_expect_amount, summary.product_amount, order.product_expect_amount);
1212
1216
  const productOriginalAmount = firstPresentValue(summary.product_original_amount, order.product_original_amount) ?? calculateProductOriginalAmount(order);
1213
1217
  const totalSavingsAmount = new _decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
@@ -1218,7 +1222,9 @@ function buildFees(params) {
1218
1222
  total_amount: formatMoney(firstPresentValue(summary.total_amount, order.total_amount) ?? 0, currencySymbol),
1219
1223
  original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
1220
1224
  product_expect_amount: formatMoney(productExpectAmount ?? 0, currencySymbol),
1221
- item_discount_amount: formatCalculatedMoney(itemDiscountAmount, currencySymbol),
1225
+ ...(isNonZero(itemDiscountAmount) ? {
1226
+ item_discount_amount: formatCalculatedMoney(itemDiscountAmount, currencySymbol)
1227
+ } : {}),
1222
1228
  expect_amount: formatMoney(financials.totalAmount, currencySymbol),
1223
1229
  product_quantity: toNumber(firstPresentValue(summary.product_quantity, products.reduce((sum, product) => sum + product.product_quantity, 0)), 0),
1224
1230
  has_pay: formatMoney(financials.orderPaidAmount, currencySymbol),
@@ -1228,7 +1234,7 @@ function buildFees(params) {
1228
1234
  customer_paid_amount: formatMoney(financials.customerPaidAmount, currencySymbol),
1229
1235
  net_payment_applied: formatMoney(financials.netPaymentApplied, currencySymbol),
1230
1236
  ...(isPresentId(roundingAmount) ? {
1231
- rounding_amount: formatMoney(roundingAmount, currencySymbol)
1237
+ rounding_amount: formatCalculatedMoney(roundingAmount, currencySymbol)
1232
1238
  } : {}),
1233
1239
  ...(isNonZero(totalSavingsAmount) ? {
1234
1240
  order_total_discount: formatMoney(totalSavingsAmount, currencySymbol)
@@ -1358,7 +1364,7 @@ function formatPickupBookingStart(bookings, locale) {
1358
1364
  const dateText = locale === 'en' ? `${day}/${month}/${year}` : `${year}/${month}/${day}`;
1359
1365
  return `${time.slice(0, 5)} ${dateText}`;
1360
1366
  }
1361
- function buildAppointment(order, locale) {
1367
+ function buildAppointment(order, locale, showResourceTitle) {
1362
1368
  const parentScheduleId = order.metadata?.appointment_booking_parent_schedule_id;
1363
1369
  const bookings = sortBookings(normalizeArray(order.bookings).filter(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking) && isReceiptAppointmentBooking(booking, parentScheduleId)));
1364
1370
  if (bookings.length) {
@@ -1367,7 +1373,8 @@ function buildAppointment(order, locale) {
1367
1373
  booking,
1368
1374
  allResources,
1369
1375
  bookingCount: bookings.length,
1370
- locale
1376
+ locale,
1377
+ showResourceTitle
1371
1378
  }));
1372
1379
  }
1373
1380
  const tableName = order.table_name || order.metadata?.table_name || order.metadata?.table?.name || order.form_data?.table_name;
@@ -1406,12 +1413,13 @@ function buildAppointmentRows(params) {
1406
1413
  };
1407
1414
  const bookingId = stringify(firstPresentValue(booking.booking_id, booking.schedule_event_id, bookingUid)).trim();
1408
1415
  const bookingTime = formatBookingRange(booking, locale);
1409
- const resourceText = formatBookingResources(resolveBookingResourcesForReceipt(booking, allResources, bookingCount), locale);
1416
+ const resourceText = formatBookingResources(resolveBookingResourcesForReceipt(booking, allResources, bookingCount), locale, params.showResourceTitle);
1410
1417
  const holder = getLocalizedValue(booking.holder?.name ?? booking.metadata?.holder?.name, locale).trim();
1411
1418
  return [{
1412
1419
  ...receiptKey(booking, 'booking-id'),
1413
1420
  item: label(locale, 'bookingId'),
1414
- value: bookingId,
1421
+ // 异步落单时可能只有内部关联 UUID;留空后由下方过滤移除整行。
1422
+ value: BOOKING_ID_UUID_PATTERN.test(bookingId) ? '' : bookingId,
1415
1423
  ...association
1416
1424
  }, {
1417
1425
  ...receiptKey(booking, 'booking-time', 'shared'),
@@ -1468,8 +1476,8 @@ function resolveBookingResourcesForReceipt(booking, allResources, bookingCount)
1468
1476
  if (bookingCount === 1 && allResources.length) return allResources;
1469
1477
  return [];
1470
1478
  }
1471
- function formatBookingResources(resources, locale) {
1472
- return resources.map(resource => [getLocalizedValue(resource.form_title || resource.metadata?.form_name || resource.relation_form_name || resource.metadata?.relation_form_name, locale), getLocalizedValue(resource.title || resource.name || resource.main_field || resource.metadata?.main_field || resource.metadata?.resource_name, locale)].filter(Boolean).join(' ')).filter(Boolean).join(', ');
1479
+ function formatBookingResources(resources, locale, showResourceTitle) {
1480
+ return resources.map(resource => [showResourceTitle ? getLocalizedValue(resource.form_title || resource.metadata?.form_name || resource.relation_form_name || resource.metadata?.relation_form_name, locale) : '', getLocalizedValue(resource.title || resource.name || resource.main_field || resource.metadata?.main_field || resource.metadata?.resource_name, locale)].filter(Boolean).join(' ')).filter(Boolean).join(', ');
1473
1481
  }
1474
1482
  function sortBookings(bookings) {
1475
1483
  return bookings.map((booking, index) => ({
@@ -2013,7 +2021,7 @@ function buildVirtualCurrencySnapshotAssets(params) {
2013
2021
  })) return [];
2014
2022
  const rows = [{
2015
2023
  ...receiptKey(virtualCurrency, 'asset-name'),
2016
- item: stringify(virtualCurrency.product_name).trim(),
2024
+ item: appendMaskedCardCode(stringify(virtualCurrency.product_name).trim(), virtualCurrency.code),
2017
2025
  value: ''
2018
2026
  }];
2019
2027
  const balance = getVirtualCurrencySnapshotBalance(virtualCurrency);
@@ -2461,12 +2469,30 @@ function appendMaskedCardCode(name, code) {
2461
2469
  function trimDecimal(value) {
2462
2470
  return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
2463
2471
  }
2472
+ function getLocalizedPaymentName(value, locale) {
2473
+ if (typeof value === 'string') return value.trim();
2474
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return '';
2475
+ const candidates = [value[locale], value[locale.replace('_', '-')], value[locale.replace('-', '_')], value.original, value.auto, value.default, value.en];
2476
+ for (const candidate of candidates) {
2477
+ if (typeof candidate === 'string' && candidate.trim()) return candidate.trim();
2478
+ }
2479
+ return '';
2480
+ }
2481
+ function getExplicitPaymentName(payment, locale) {
2482
+ // Cloud order snapshots retain the localized name in metadata after reload.
2483
+ const candidates = [payment.name, payment.title, payment.payment_method_name, payment.method_name, payment.metadata?.custom_payment_name];
2484
+ for (const candidate of candidates) {
2485
+ const name = getLocalizedPaymentName(candidate, locale);
2486
+ if (name) return name;
2487
+ }
2488
+ return '';
2489
+ }
2464
2490
  function getFundRecordPaymentName(payment, locale) {
2465
2491
  const fundRecord = getFundRecord(payment);
2466
2492
  if (!fundRecord) return '';
2467
- const name = getLocalizedValue(fundRecord.wallet_pass_name, locale);
2493
+ const name = getLocalizedPaymentName(fundRecord.wallet_pass_name, locale);
2468
2494
  if (!name && !maskMachineCode(fundRecord.code)) return '';
2469
- const fallbackName = getLocalizedValue(payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code, locale);
2495
+ const fallbackName = getExplicitPaymentName(payment, locale) || getLocalizedPaymentName(payment.code, locale);
2470
2496
  return appendMaskedCardCode(name || fallbackName, fundRecord.code);
2471
2497
  }
2472
2498
  function appendMachineCodeToName(name, payment) {
@@ -2476,13 +2502,15 @@ function appendMachineCodeToName(name, payment) {
2476
2502
  function paymentMethodName(payment, locale) {
2477
2503
  const fundRecordName = getFundRecordPaymentName(payment, locale);
2478
2504
  if (fundRecordName) return fundRecordName;
2479
- const raw = payment.name || payment.title || payment.payment_method_name || payment.method_name;
2480
- if (raw) return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
2505
+ const name = getExplicitPaymentName(payment, locale);
2506
+ if (name) return appendMachineCodeToName(name, payment);
2481
2507
  const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
2482
2508
  if (code.includes('cash')) return label(locale, 'cash');
2483
- if (code.includes('eftpos') || code.includes('card')) return label(locale, 'eftpos');
2509
+ if (code.includes('eftpos')) return label(locale, 'eftpos');
2484
2510
  if (code.includes('wallet')) return label(locale, 'wallet');
2485
2511
  if (code.includes('gift')) return label(locale, 'giftCard');
2512
+ if (code === 'credit_card' || code.startsWith('credit_card_')) return label(locale, 'creditCard');
2513
+ if (code.includes('card')) return label(locale, 'eftpos');
2486
2514
  return stringify(payment.code || payment.type || payment.payment_method || payment.method);
2487
2515
  }
2488
2516
  function getSummary(order) {
@@ -1,5 +1,8 @@
1
1
  /** Template children are direct module members; legacy missing values stay visible. */
2
2
  export interface InvoiceDataVisibility {
3
+ lineGroups: {
4
+ resourceTitle: boolean;
5
+ };
3
6
  handover: {
4
7
  show: boolean;
5
8
  method: boolean;
@@ -34,6 +34,9 @@ function resolveInvoiceDataVisibility(settings) {
34
34
  const field = (config, key) => invoiceSettingIsVisible(config?.[key]?.is_show);
35
35
  const passTypes = Array.isArray(card?.pass_type) && card.pass_type.length > 0 ? new Set(card.pass_type.filter(tag => typeof tag === 'string' && tag.length > 0)) : null;
36
36
  return {
37
+ lineGroups: {
38
+ resourceTitle: field(module('line_groups'), 'resource_title')
39
+ },
37
40
  handover: {
38
41
  show: invoiceSettingIsVisible(handover?.is_show),
39
42
  method: field(handover, 'method'),
@@ -57,7 +60,8 @@ function requiresInvoiceDataFiltering(settings) {
57
60
  const {
58
61
  handover,
59
62
  customer,
60
- card
63
+ card,
64
+ lineGroups
61
65
  } = resolveInvoiceDataVisibility(settings);
62
- return !handover.show || !handover.method || !handover.fulfillmentTime || !customer.show || !customer.name || !customer.email || !customer.phone || !card.show || card.passTypes !== null;
66
+ return !lineGroups.resourceTitle || !handover.show || !handover.method || !handover.fulfillmentTime || !customer.show || !customer.name || !customer.email || !customer.phone || !card.show || card.passTypes !== null;
63
67
  }
@@ -0,0 +1,27 @@
1
+ import type { OrderModule } from '../../modules/Order';
2
+ import type { ShopServiceType } from '../../modules/Order/types';
3
+ import type { ProductList } from '../../modules/ProductList';
4
+ import type { OpenDataConfig } from '../../modules/OpenData/types';
5
+ interface FulfillmentItemRulesHost {
6
+ getOrder: () => OrderModule;
7
+ getProducts: () => ProductList | undefined;
8
+ loadOpenData: () => Promise<OpenDataConfig | null>;
9
+ getScope: () => string;
10
+ getOtherParams: () => Record<string, any>;
11
+ fetchStrategyModels: (ids: number[]) => Promise<any>;
12
+ reportError: (error: unknown) => void;
13
+ }
14
+ /** Executes item rules at the sales boundary, independent of the calling template. */
15
+ export declare class FulfillmentItemRulesController {
16
+ private readonly host;
17
+ private sequence;
18
+ private pending;
19
+ private evaluator;
20
+ constructor(host: FulfillmentItemRulesHost);
21
+ invalidate(): void;
22
+ apply(serviceType: ShopServiceType): Promise<void>;
23
+ private loadProducts;
24
+ private getMainProductNumber;
25
+ private loadPrefillSources;
26
+ }
27
+ export {};
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FulfillmentItemRulesController = void 0;
7
+ var _dayjs = _interopRequireDefault(require("dayjs"));
8
+ var _itemRule = require("../../model/strategy/adapter/itemRule");
9
+ var _transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const ownershipField = 'fulfillment_item_rule';
12
+ function positiveIds(value) {
13
+ if (!Array.isArray(value)) return [];
14
+ return [...new Set(value.map(Number).filter(id => Number.isInteger(id) && id > 0))];
15
+ }
16
+ function lineIdentity(line) {
17
+ return {
18
+ product_id: line.product_id,
19
+ product_variant_id: line.product_variant_id,
20
+ unique_identification_number: line.metadata?.unique_identification_number || line.unique_identification_number,
21
+ product_sku: line.product_sku,
22
+ product_bundle: line.product_bundle
23
+ };
24
+ }
25
+ function cartFingerprint(lines) {
26
+ return JSON.stringify(lines.map(line => [lineIdentity(line), line.num, line.metadata?.[ownershipField]]));
27
+ }
28
+ function selectionFingerprint(lines, excludedIds) {
29
+ const quantities = new Map();
30
+ for (const line of lines) {
31
+ if (excludedIds.has(Number(line.product_id)) || line.metadata?._giftInfo) continue;
32
+ const key = JSON.stringify([Number(line.product_id), Number(line.product_variant_id) || 0]);
33
+ quantities.set(key, (quantities.get(key) || 0) + Number(line.num || 0));
34
+ }
35
+ return JSON.stringify([...quantities].sort(([left], [right]) => left.localeCompare(right)));
36
+ }
37
+ function ownerKey(action, product) {
38
+ return JSON.stringify([action.strategyId, action.ruleId, product.product_id, product.product_variant_id ?? 0]);
39
+ }
40
+ function ownedLines(lines, key) {
41
+ return lines.filter(line => line.metadata?.[ownershipField] === key);
42
+ }
43
+
44
+ /** Executes item rules at the sales boundary, independent of the calling template. */
45
+ class FulfillmentItemRulesController {
46
+ sequence = 0;
47
+ pending = Promise.resolve();
48
+ evaluator = new _itemRule.ItemRuleEvaluator();
49
+ constructor(host) {
50
+ this.host = host;
51
+ }
52
+ invalidate() {
53
+ this.sequence += 1;
54
+ }
55
+ apply(serviceType) {
56
+ const sequence = ++this.sequence;
57
+ // Even an unsupported mode supersedes any pending takeaway operation.
58
+ if (serviceType !== 'takeaway' && serviceType !== 'dine_in') return Promise.resolve();
59
+ const order = this.host.getOrder();
60
+ const tempOrder = order.getTempOrder?.();
61
+ const scope = this.host.getScope();
62
+ const identity = JSON.stringify([tempOrder?.order_id, tempOrder?.external_sale_number, tempOrder?.customer_id]);
63
+ const initialProducts = tempOrder?.products;
64
+ const initialFingerprint = cartFingerprint(initialProducts || []);
65
+ const isCurrent = () => sequence === this.sequence && scope === this.host.getScope() && this.host.getOrder() === order && order.getTempOrder?.() === tempOrder && identity === JSON.stringify([tempOrder?.order_id, tempOrder?.external_sale_number, tempOrder?.customer_id]) && tempOrder?.metadata?.shop_service_data?.service_type === serviceType;
66
+ const run = async () => {
67
+ const openData = await this.host.loadOpenData();
68
+ const ids = positiveIds(openData?.[`fulfillment.${serviceType}_fees_rules`]);
69
+ if (!ids.length || !isCurrent()) return;
70
+ if (!tempOrder) return;
71
+ const assertSnapshot = () => {
72
+ if (!isCurrent() || tempOrder.products !== initialProducts || cartFingerprint(tempOrder.products) !== initialFingerprint) {
73
+ throw new Error('The order changed while preparing fulfillment item rules');
74
+ }
75
+ };
76
+ assertSnapshot();
77
+ const response = await this.host.fetchStrategyModels(ids);
78
+ assertSnapshot();
79
+ if (response?.code !== 200 || !Array.isArray(response?.data?.list)) {
80
+ throw new Error('Unable to load fulfillment item rules');
81
+ }
82
+ // Response order need not match the configured order (the latter breaks priority ties).
83
+ const configs = ids.map(id => {
84
+ const config = response.data.list.find(item => Number(item?.id) === id)?.metadata;
85
+ if (config?.metadata?.type !== 'item_rule' || !Array.isArray(config.actions) || !config.conditions) {
86
+ throw new Error(`Invalid or missing fulfillment item rule ${id}`);
87
+ }
88
+ return config;
89
+ });
90
+ const runtime = this.host.getOtherParams();
91
+ const pax = runtime.itemRule?.pax || {};
92
+ const businessData = {
93
+ executionScope: 'set_handover',
94
+ serviceType,
95
+ channel: String(runtime.channel ?? runtime.platform ?? ''),
96
+ pax: {
97
+ total: Number(pax.total) || 0,
98
+ adult: Number(pax.adult) || 0,
99
+ child: Number(pax.child) || 0
100
+ },
101
+ cartItems: tempOrder.products.map(line => ({
102
+ product_id: Number(line.product_id),
103
+ product_variant_id: Number(line.product_variant_id) || 0,
104
+ quantity: Number(line.num) || 0
105
+ })),
106
+ strategyConfigs: configs,
107
+ custom: runtime.itemRule?.custom
108
+ };
109
+ const initialEvaluation = this.evaluator.evaluate(businessData);
110
+ const requiresMainQuantity = initialEvaluation.rawResults.some(result => result.applicable && result.matchedActions.some(action => action.type === 'PREFILL_CART' && action.target === 'cart' && action.config?.scope === 'set_handover' && action.config.products?.some(product => product.quantityFrom === 'main_product_number')));
111
+ const actions = requiresMainQuantity ? this.evaluator.evaluate({
112
+ ...businessData,
113
+ mainProductNumber: await this.getMainProductNumber(tempOrder.products, configs)
114
+ }).cartActions : initialEvaluation.cartActions;
115
+ assertSnapshot();
116
+ // Prepare every addition before changing the cart; missing products must not leave a half-loaded batch.
117
+ const sources = await this.loadPrefillSources(actions, tempOrder.products);
118
+ assertSnapshot();
119
+ const targetIds = new Set(actions.flatMap(action => action.products.map(product => Number(product.product_id))));
120
+ const originalSelection = selectionFingerprint(tempOrder.products, targetIds);
121
+ // Promotion may add gifts or split/merge rows. Only a change to the purchased
122
+ // quantities invalidates this selection, not promotion's own line reshaping.
123
+ const targetIsCurrent = () => isCurrent() && selectionFingerprint(tempOrder.products, targetIds) === originalSelection;
124
+ for (const action of actions) {
125
+ if (!targetIsCurrent()) return;
126
+ if (action.type === 'DELETE_PRODUCT') {
127
+ const deletedIds = new Set(action.products.map(product => Number(product.product_id)));
128
+ const lines = tempOrder.products.filter(line => deletedIds.has(Number(line.product_id)));
129
+ if (lines.length) {
130
+ await order.removeProductsFromOrder(lines.map(lineIdentity), {
131
+ isCurrentOrder: targetIsCurrent
132
+ });
133
+ }
134
+ continue;
135
+ }
136
+ for (const product of action.products) {
137
+ if (!targetIsCurrent()) return;
138
+ const key = ownerKey(action, product);
139
+ const existing = ownedLines(tempOrder.products, key);
140
+ const quantity = Math.max(0, Math.floor(Number(product.quantity) || 0));
141
+ if (product.repeat_skip && existing.length) {
142
+ if (quantity === 0) {
143
+ await order.removeProductsFromOrder(existing.map(lineIdentity), {
144
+ isCurrentOrder: targetIsCurrent
145
+ });
146
+ continue;
147
+ }
148
+ // Keep one owned row and its pricing; never absorb independently added products.
149
+ if (existing.length > 1) {
150
+ await order.removeProductsFromOrder(existing.slice(1).map(lineIdentity), {
151
+ isCurrentOrder: targetIsCurrent
152
+ });
153
+ }
154
+ if (!targetIsCurrent()) return;
155
+ if (Number(existing[0].num) !== quantity) {
156
+ await order.updateOrderProductQuantity({
157
+ ...lineIdentity(existing[0]),
158
+ num: quantity
159
+ }, {
160
+ isCurrentOrder: targetIsCurrent
161
+ });
162
+ }
163
+ continue;
164
+ }
165
+ if (quantity === 0) continue;
166
+ const source = sources.get(Number(product.product_id));
167
+ const line = (0, _transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)({
168
+ sourceProduct: source,
169
+ payload: {
170
+ product_id: product.product_id,
171
+ product_variant_id: product.product_variant_id ?? 0,
172
+ quantity
173
+ }
174
+ });
175
+ if (!line) throw new Error(`Unable to prepare fulfillment product ${product.product_id}`);
176
+ line.metadata = {
177
+ ...line.metadata,
178
+ [ownershipField]: key
179
+ };
180
+ const beforeProducts = tempOrder.products;
181
+ const beforeFingerprint = cartFingerprint(beforeProducts);
182
+ await order.addProductToOrder(line, undefined, {
183
+ insertAtStart: true,
184
+ disableMerge: true,
185
+ availabilityCommitGuard: () => {
186
+ if (!targetIsCurrent() || tempOrder.products !== beforeProducts || cartFingerprint(tempOrder.products) !== beforeFingerprint) {
187
+ throw new Error('The order changed while adding a fulfillment product');
188
+ }
189
+ },
190
+ availabilityCommitTargetGuard: () => targetIsCurrent() && ownedLines(tempOrder.products, key).length > 0
191
+ });
192
+ }
193
+ }
194
+ };
195
+ // Serialize writes; a newer choice invalidates the old request before its next mutation.
196
+ const task = this.pending.then(run).catch(error => {
197
+ if (sequence === this.sequence) this.host.reportError(error);
198
+ // Fees are best effort by product decision: Next must remain usable on failure.
199
+ });
200
+ this.pending = task;
201
+ return task;
202
+ }
203
+ async loadProducts(ids) {
204
+ if (!ids.length) return [];
205
+ const products = this.host.getProducts();
206
+ if (!products) throw new Error('products module is unavailable for fulfillment item rules');
207
+ const runtime = this.host.getOtherParams();
208
+ const now = (0, _dayjs.default)();
209
+ return products.loadProducts({
210
+ product_ids: ids,
211
+ cacheId: runtime.cacheId,
212
+ customer_id: this.host.getOrder().getTempOrder()?.customer_id ?? undefined,
213
+ schedule_date: now.format('YYYY-MM-DD'),
214
+ schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
215
+ });
216
+ }
217
+ async getMainProductNumber(lines, configs) {
218
+ const feeIds = new Set(configs.flatMap(config => config.actions.flatMap(action => action.config?.scope === 'set_handover' && ['PREFILL_CART', 'DELETE_PRODUCT'].includes(action.type) ? (action.config.products || []).map(product => Number(product.product_id)) : [])));
219
+ const candidates = lines.filter(line => !line.metadata?.[ownershipField] && !feeIds.has(Number(line.product_id)));
220
+ if (!candidates.length) return 0;
221
+ const ids = positiveIds(candidates.map(line => line.product_id));
222
+ const cached = (await this.host.getProducts()?.queryProducts({
223
+ includeIds: ids
224
+ })) || [];
225
+ const sources = new Map();
226
+ for (const line of candidates) {
227
+ const cachedSource = cached.find(product => Number(product.id) === Number(line.product_id));
228
+ const source = Array.isArray(cachedSource?.data_variants) ? cachedSource : line._origin;
229
+ if (Array.isArray(source?.data_variants)) sources.set(Number(line.product_id), source);
230
+ }
231
+ const missing = ids.filter(id => !sources.has(id));
232
+ for (const source of await this.loadProducts(missing)) sources.set(Number(source.id ?? source.product_id), source);
233
+ if (ids.some(id => !sources.has(id))) throw new Error('Unable to identify fulfillment main products');
234
+ return candidates.reduce((sum, line) => {
235
+ const source = sources.get(Number(line.product_id));
236
+ const isMain = source?.data_variants?.some(variant => variant?.data?.client_meta?.is_main_product === 1);
237
+ return sum + (isMain ? Math.max(0, Math.floor(Number(line.num) || 0)) : 0);
238
+ }, 0);
239
+ }
240
+ async loadPrefillSources(actions, lines) {
241
+ const ids = positiveIds(actions.flatMap(action => action.type === 'PREFILL_CART' ? action.products.filter(product => product.quantity > 0).map(product => product.product_id) : []));
242
+ const cached = ids.length ? (await this.host.getProducts()?.queryProducts({
243
+ includeIds: ids
244
+ })) || [] : [];
245
+ const sources = new Map(cached.map(product => [Number(product.id), product]));
246
+ // Existing owned rows can supply their original product if the catalog no longer contains it.
247
+ for (const line of lines) {
248
+ if (line.metadata?.[ownershipField] && line._origin && !sources.has(Number(line.product_id))) {
249
+ sources.set(Number(line.product_id), line._origin);
250
+ }
251
+ }
252
+ for (const source of await this.loadProducts(ids.filter(id => !sources.has(id)))) {
253
+ sources.set(Number(source.id ?? source.product_id), source);
254
+ }
255
+ if (ids.some(id => !sources.has(id))) throw new Error('Unable to load fulfillment fee products');
256
+ return sources;
257
+ }
258
+ }
259
+ exports.FulfillmentItemRulesController = FulfillmentItemRulesController;