@pisell/pisellos 2.2.323 → 2.2.324

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 (195) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/modules/BookingContext/index.d.ts +2 -2
  6. package/dist/modules/BookingContext/index.js +55 -25
  7. package/dist/modules/BookingContext/types.d.ts +2 -0
  8. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  9. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  10. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  11. package/dist/modules/BookingContext/utils/index.js +1 -0
  12. package/dist/modules/BookingContext/utils/productExtend.d.ts +20 -1
  13. package/dist/modules/BookingContext/utils/productExtend.js +122 -29
  14. package/dist/modules/Date/index.d.ts +1 -1
  15. package/dist/modules/Date/index.js +60 -14
  16. package/dist/modules/Date/types.d.ts +5 -0
  17. package/dist/modules/Discount/index.js +1 -0
  18. package/dist/modules/OpenData/index.d.ts +1 -0
  19. package/dist/modules/OpenData/index.js +1 -0
  20. package/dist/modules/OpenData/salesSettings.d.ts +32 -0
  21. package/dist/modules/OpenData/salesSettings.js +80 -0
  22. package/dist/modules/OpenData/types.d.ts +16 -0
  23. package/dist/modules/OpenData/utils.d.ts +1 -1
  24. package/dist/modules/OpenData/utils.js +3 -2
  25. package/dist/modules/Order/index.d.ts +54 -11
  26. package/dist/modules/Order/index.js +2699 -1411
  27. package/dist/modules/Order/types.d.ts +43 -5
  28. package/dist/modules/Order/types.js +4 -0
  29. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  30. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  31. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  32. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  33. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  34. package/dist/modules/Order/utils.d.ts +3 -1
  35. package/dist/modules/Order/utils.js +6 -2
  36. package/dist/modules/ProductList/clientDataVariants.js +6 -2
  37. package/dist/modules/ProductList/index.d.ts +2 -0
  38. package/dist/modules/ProductList/index.js +161 -51
  39. package/dist/modules/ResourcePlanner/planner.js +58 -2
  40. package/dist/modules/ResourcePlanner/types.d.ts +13 -0
  41. package/dist/modules/Rules/index.d.ts +2 -0
  42. package/dist/modules/Rules/index.js +58 -39
  43. package/dist/modules/Schedule/index.d.ts +7 -1
  44. package/dist/modules/Schedule/index.js +155 -39
  45. package/dist/modules/Schedule/types.d.ts +2 -0
  46. package/dist/modules/bookingReadValidation.d.ts +6 -0
  47. package/dist/modules/bookingReadValidation.js +72 -0
  48. package/dist/plugins/request.d.ts +2 -0
  49. package/dist/server/index.d.ts +5 -0
  50. package/dist/server/index.js +1312 -1154
  51. package/dist/server/modules/order/index.js +2 -1
  52. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  53. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  54. package/dist/shared/receipt/small-ticket.d.ts +4 -0
  55. package/dist/shared/receipt/small-ticket.js +70 -12
  56. package/dist/solution/BaseSales/index.d.ts +39 -5
  57. package/dist/solution/BaseSales/index.js +1828 -1462
  58. package/dist/solution/BaseSales/types.d.ts +1 -0
  59. package/dist/solution/BaseSales/types.js +1 -0
  60. package/dist/solution/BookingByStep/index.d.ts +17 -3
  61. package/dist/solution/BookingByStep/index.js +676 -361
  62. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  63. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  64. package/dist/solution/BookingTicket/index.d.ts +15 -3
  65. package/dist/solution/BookingTicket/index.js +249 -135
  66. package/dist/solution/BookingTicket/types.d.ts +14 -2
  67. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
  68. package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
  69. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  70. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  71. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  72. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
  73. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  74. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  75. package/dist/solution/OrderInvoicePreview/index.js +14 -8
  76. package/dist/solution/ScanOrder/index.d.ts +2 -0
  77. package/dist/solution/ScanOrder/index.js +166 -67
  78. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  79. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  80. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  81. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
  82. package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
  83. package/dist/solution/UnifiedBookingSales/index.js +3374 -1177
  84. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  85. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
  86. package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  87. package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
  88. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  89. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
  90. package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
  91. package/dist/solution/UnifiedBookingSales/types.js +7 -1
  92. package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  93. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
  94. package/dist/utils/platform.d.ts +2 -0
  95. package/dist/utils/platform.js +6 -0
  96. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  97. package/dist/utils/pos-receipt-auto-print.js +14 -0
  98. package/lib/index.d.ts +1 -0
  99. package/lib/index.js +12 -0
  100. package/lib/inventory/index.d.ts +92 -0
  101. package/lib/inventory/index.js +287 -0
  102. package/lib/modules/BookingContext/index.d.ts +2 -2
  103. package/lib/modules/BookingContext/index.js +42 -10
  104. package/lib/modules/BookingContext/types.d.ts +2 -0
  105. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  106. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  107. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  108. package/lib/modules/BookingContext/utils/index.js +11 -0
  109. package/lib/modules/BookingContext/utils/productExtend.d.ts +20 -1
  110. package/lib/modules/BookingContext/utils/productExtend.js +96 -7
  111. package/lib/modules/Date/index.d.ts +1 -1
  112. package/lib/modules/Date/index.js +28 -5
  113. package/lib/modules/Date/types.d.ts +5 -0
  114. package/lib/modules/Discount/index.js +1 -0
  115. package/lib/modules/OpenData/index.d.ts +1 -0
  116. package/lib/modules/OpenData/index.js +12 -0
  117. package/lib/modules/OpenData/salesSettings.d.ts +32 -0
  118. package/lib/modules/OpenData/salesSettings.js +70 -0
  119. package/lib/modules/OpenData/types.d.ts +16 -0
  120. package/lib/modules/OpenData/utils.d.ts +1 -1
  121. package/lib/modules/OpenData/utils.js +3 -2
  122. package/lib/modules/Order/index.d.ts +54 -11
  123. package/lib/modules/Order/index.js +659 -80
  124. package/lib/modules/Order/types.d.ts +43 -5
  125. package/lib/modules/Order/types.js +2 -0
  126. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  127. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  128. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  129. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  130. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  131. package/lib/modules/Order/utils.d.ts +3 -1
  132. package/lib/modules/Order/utils.js +6 -2
  133. package/lib/modules/ProductList/clientDataVariants.js +6 -2
  134. package/lib/modules/ProductList/index.d.ts +2 -0
  135. package/lib/modules/ProductList/index.js +74 -0
  136. package/lib/modules/ResourcePlanner/planner.js +52 -1
  137. package/lib/modules/ResourcePlanner/types.d.ts +13 -0
  138. package/lib/modules/Rules/index.d.ts +2 -0
  139. package/lib/modules/Rules/index.js +25 -9
  140. package/lib/modules/Schedule/index.d.ts +7 -1
  141. package/lib/modules/Schedule/index.js +68 -4
  142. package/lib/modules/Schedule/types.d.ts +2 -0
  143. package/lib/modules/bookingReadValidation.d.ts +6 -0
  144. package/lib/modules/bookingReadValidation.js +56 -0
  145. package/lib/plugins/request.d.ts +2 -0
  146. package/lib/server/index.d.ts +5 -0
  147. package/lib/server/index.js +124 -16
  148. package/lib/server/modules/order/index.js +2 -1
  149. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  150. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  151. package/lib/shared/receipt/small-ticket.d.ts +4 -0
  152. package/lib/shared/receipt/small-ticket.js +63 -8
  153. package/lib/solution/BaseSales/index.d.ts +39 -5
  154. package/lib/solution/BaseSales/index.js +212 -18
  155. package/lib/solution/BaseSales/types.d.ts +1 -0
  156. package/lib/solution/BaseSales/types.js +1 -0
  157. package/lib/solution/BookingByStep/index.d.ts +17 -3
  158. package/lib/solution/BookingByStep/index.js +222 -14
  159. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  160. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  161. package/lib/solution/BookingTicket/index.d.ts +15 -3
  162. package/lib/solution/BookingTicket/index.js +47 -4
  163. package/lib/solution/BookingTicket/types.d.ts +14 -2
  164. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
  165. package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
  166. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  167. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  168. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  169. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
  170. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  171. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  172. package/lib/solution/OrderInvoicePreview/index.js +7 -1
  173. package/lib/solution/ScanOrder/index.d.ts +2 -0
  174. package/lib/solution/ScanOrder/index.js +72 -2
  175. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  176. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  177. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  178. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
  179. package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
  180. package/lib/solution/UnifiedBookingSales/index.js +1316 -73
  181. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  182. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
  183. package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  184. package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
  185. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  186. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
  187. package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
  188. package/lib/solution/UnifiedBookingSales/types.js +4 -1
  189. package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  190. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
  191. package/lib/utils/platform.d.ts +2 -0
  192. package/lib/utils/platform.js +7 -0
  193. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  194. package/lib/utils/pos-receipt-auto-print.js +13 -0
  195. package/package.json +1 -1
@@ -449,6 +449,17 @@ export interface ReplaceTempOrderOptions {
449
449
  recalculateSummary?: boolean;
450
450
  persist?: boolean;
451
451
  saveDraft?: boolean;
452
+ /** Internal same-order updates may explicitly retain an anonymous order's session. */
453
+ preserveOrderSessionId?: string;
454
+ }
455
+ export interface OrderSessionChangedPayload {
456
+ sessionId: string | null;
457
+ previousSessionId: string | null;
458
+ }
459
+ export interface HydrateTempOrderOptions {
460
+ recalcOnHydrate?: boolean;
461
+ source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
462
+ preserveOrderSessionId?: string;
452
463
  }
453
464
  export type AddProductBookingInput = Record<string, any>;
454
465
  /**
@@ -457,6 +468,8 @@ export type AddProductBookingInput = Record<string, any>;
457
468
  * 避免步进器修改数量改变该组展示位置。
458
469
  */
459
470
  export interface AddProductToOrderOptions {
471
+ /** Associates a selection with an existing runtime voucher group. */
472
+ productVoucherGroupKey?: string;
460
473
  insertAfterProductUid?: string;
461
474
  /** 新增商品行插入 products 首位,优先于 insertAfterProductUid。 */
462
475
  insertAtStart?: boolean;
@@ -474,11 +487,22 @@ export interface AddProductToOrderOptions {
474
487
  /** 发布后的订单/业务归属检查;只用于阻止旧异步收尾写入新单,不再校验截止或 revision。 */
475
488
  availabilityCommitTargetGuard?: () => boolean;
476
489
  }
490
+ /** Atomic replacement of one unsubmitted Party booking and its explicitly confirmed retail children. */
491
+ export interface ReplaceBookingProductWithRelatedRetailParams {
492
+ productLineUid: string;
493
+ product: Partial<OrderProduct> & OrderProductIdentity;
494
+ booking: AddProductBookingInput;
495
+ relatedRetailProducts: Array<Partial<OrderProduct> & OrderProductIdentity>;
496
+ availabilityCommitGuard: () => void;
497
+ availabilityCommitTargetGuard?: () => boolean;
498
+ }
477
499
  /**
478
500
  * 删除商品后的可选位置保持策略。
479
501
  * 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
480
502
  */
481
503
  export interface RemoveProductsFromOrderOptions {
504
+ /** Validate the selected row/cascade snapshot before mutation; may throw. Not called during finalization. */
505
+ beforeApply?: () => void;
482
506
  /** 自动购物车写入的订单归属检查;失效时不再变更或发布异步收尾结果。 */
483
507
  isCurrentOrder?: () => boolean;
484
508
  preserveDisplayPosition?: {
@@ -523,6 +547,13 @@ export interface UpdateOrderProductParams {
523
547
  */
524
548
  allow_booking_discount_reapply?: boolean;
525
549
  }
550
+ /** Opt-in atomic draft update for asynchronous re-quotation callers. */
551
+ export interface UpdateOrderProductsOptions {
552
+ /** Validate the quoted source snapshot immediately before publication; may throw. */
553
+ beforeApply?: () => void;
554
+ /** Order/business ownership only. Called after publication too; exclude old prices/quantities. */
555
+ isCurrentOrder?: () => boolean;
556
+ }
526
557
  /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
527
558
  export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
528
559
  num: number;
@@ -557,6 +588,11 @@ export interface OrderHooksConfig {
557
588
  beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
558
589
  /** Captures tenant/business runtime identity for asynchronous cart intents. */
559
590
  getCartIntentScope?: () => unknown;
591
+ /** Awaited before a local cart draft is published. Reject to leave the live order unchanged. */
592
+ onBeforeCartCommit?: (context: {
593
+ currentItems: readonly OrderProduct[];
594
+ proposedItems: readonly OrderProduct[];
595
+ }) => void | Promise<void>;
560
596
  onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
561
597
  }
562
598
  /**
@@ -862,6 +898,10 @@ export interface OrderModuleAPI {
862
898
  salesSummaryModuleName?: string;
863
899
  }) => void;
864
900
  getTempOrder: () => OrderTempOrder | null;
901
+ /** Runtime-only identity; never part of an order or a persisted draft. */
902
+ getOrderSessionId: () => string | null;
903
+ /** Also rejects a session while an asynchronous order replacement is pending. */
904
+ isOrderSessionCurrent: (sessionId: string) => boolean;
865
905
  ensureTempOrder: () => OrderTempOrder;
866
906
  replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
867
907
  addNewOrder: () => Promise<OrderTempOrder>;
@@ -910,6 +950,7 @@ export interface OrderModuleAPI {
910
950
  updateTempOrderBuzzer: (buzzer: string) => string;
911
951
  updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
912
952
  addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions) => Promise<OrderProduct[]>;
953
+ replaceBookingProductWithRelatedRetail: (params: ReplaceBookingProductWithRelatedRetailParams) => Promise<OrderProduct[]>;
913
954
  getSalesNotes: () => SalesNote[];
914
955
  createSalesNotesMutationSnapshot: () => SalesNotesMutationSnapshot;
915
956
  restoreSalesNotesMutationSnapshot: (snapshot: SalesNotesMutationSnapshot) => void;
@@ -918,7 +959,7 @@ export interface OrderModuleAPI {
918
959
  clearSalesNotes: () => Promise<void>;
919
960
  updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
920
961
  /** 批量更新购物车行,末尾仅触发一次促销重算与 summary 刷新 */
921
- updateOrderProducts: (paramsList: UpdateOrderProductParams[]) => Promise<OrderProduct[]>;
962
+ updateOrderProducts: (paramsList: UpdateOrderProductParams[], options?: UpdateOrderProductsOptions) => Promise<OrderProduct[]>;
922
963
  updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams, options?: {
923
964
  isCurrentOrder?: () => boolean;
924
965
  }) => Promise<OrderProduct[]>;
@@ -992,10 +1033,7 @@ export interface OrderModuleAPI {
992
1033
  }) => OrderPaymentData[];
993
1034
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
994
1035
  saveDraft: () => Promise<void>;
995
- hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
996
- recalcOnHydrate?: boolean;
997
- source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
998
- }) => Promise<OrderTempOrder>;
1036
+ hydrateTempOrderFromRecord: (record: Record<string, any>, options?: HydrateTempOrderOptions) => Promise<OrderTempOrder>;
999
1037
  syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
1000
1038
  getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
1001
1039
  getLastOrderInfo: () => Record<string, any> | undefined;
@@ -69,11 +69,13 @@ let OrderHooks = exports.OrderHooks = /*#__PURE__*/function (OrderHooks) {
69
69
  * 默认追加到 products 尾部;预约数量同步可插入到既有预约组的最新行之后,
70
70
  * 避免步进器修改数量改变该组展示位置。
71
71
  */
72
+ /** Atomic replacement of one unsubmitted Party booking and its explicitly confirmed retail children. */
72
73
  /**
73
74
  * 删除商品后的可选位置保持策略。
74
75
  * 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
75
76
  */
76
77
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
78
+ /** Opt-in atomic draft update for asynchronous re-quotation callers. */
77
79
  /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
78
80
  /**
79
81
  * 订单信息
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cloud saved orders with no payment rows report a zero gap, even while unpaid.
3
+ * Restore the OS payment target from the same snapshot, without repricing products.
4
+ * Voided rows are local payment history and are omitted from cloud checkout.
5
+ */
6
+ export declare function normalizeUnpaidOrderAmountGap<T extends Record<string, any>>(order: T): T;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeUnpaidOrderAmountGap = normalizeUnpaidOrderAmountGap;
7
+ var _decimal = _interopRequireDefault(require("decimal.js"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const UNPAID_STATUSES = new Set(['unpaid', 'payment_pending', 'payment_processing']);
10
+ const CANCELLED_STATUSES = new Set(['cancelled', 'canceled', 'voided']);
11
+ function firstValue(...values) {
12
+ return values.find(value => value != null && String(value).trim() !== '');
13
+ }
14
+ function money(value) {
15
+ if (typeof value !== 'string' && typeof value !== 'number') return undefined;
16
+ try {
17
+ const amount = new _decimal.default(value);
18
+ return amount.isFinite() ? amount : undefined;
19
+ } catch {
20
+ return undefined;
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Cloud saved orders with no payment rows report a zero gap, even while unpaid.
26
+ * Restore the OS payment target from the same snapshot, without repricing products.
27
+ * Voided rows are local payment history and are omitted from cloud checkout.
28
+ */
29
+ function normalizeUnpaidOrderAmountGap(order) {
30
+ const summary = order.summary && typeof order.summary === 'object' && !Array.isArray(order.summary) ? order.summary : {};
31
+ const status = String(firstValue(order.payment_status, summary.payment_status, order.original_payment_status) ?? '').trim().toLowerCase();
32
+ if (!UNPAID_STATUSES.has(status) || CANCELLED_STATUSES.has(String(order.status ?? '').trim().toLowerCase())) return order;
33
+ if (Array.isArray(order.refunds) && order.refunds.length > 0) return order;
34
+
35
+ // An omitted collection is a sparse patch, not proof that the order has no payments.
36
+ if (!Array.isArray(order.payments) || order.payments.some(payment => String(payment?.status ?? '').trim().toLowerCase() !== 'voided')) return order;
37
+ for (const field of ['order_paid_amount', 'customer_paid_amount', 'total_refund_amount', 'paid_amount', 'payment_amount']) {
38
+ const values = [summary[field], order[field]].filter(value => value != null && String(value).trim() !== '');
39
+ if (values.some(value => !money(value)?.isZero())) return order;
40
+ }
41
+ const gapValue = firstValue(summary.amount_gap, order.amount_gap);
42
+ if (gapValue !== undefined && !money(gapValue)?.isZero()) return order;
43
+ const expected = money(firstValue(summary.expect_amount, order.expect_amount, summary.total_amount, order.total_amount));
44
+ if (!expected?.gt(0)) return order;
45
+ let target = expected;
46
+ if (Number(order.is_deposit) === 1) {
47
+ const deposit = money(firstValue(summary.deposit_amount, order.deposit_amount, 0));
48
+ if (!deposit || deposit.lt(0) || deposit.gt(expected)) return order;
49
+ if (deposit.gt(0)) target = deposit;
50
+ }
51
+ const amountGap = target.toFixed(2);
52
+ return {
53
+ ...order,
54
+ amount_gap: amountGap,
55
+ summary: {
56
+ ...summary,
57
+ amount_gap: amountGap
58
+ }
59
+ };
60
+ }
@@ -241,7 +241,7 @@ function consolidateDiscountFreeProductLines(tempOrder) {
241
241
  bundle_selling_price: String(bundle?.bundle_selling_price ?? '')
242
242
  }))
243
243
  });
244
- const mergeKey = [discountSplitOriginUid, product.product_id, product.product_variant_id ?? 0, fingerprint, priceSignature].join('#');
244
+ const mergeKey = [discountSplitOriginUid, productUid ? tempOrder._extend?.productsByUid?.[productUid]?.productVoucherGroupKey ?? '' : '', product.product_id, product.product_variant_id ?? 0, fingerprint, priceSignature].join('#');
245
245
  const matchedIndex = productIndexByKey.get(mergeKey);
246
246
 
247
247
  // 当前拆分来源 + 商品结构组合第一次出现时,保留该行作为回并目标。
@@ -0,0 +1,15 @@
1
+ import type { Discount } from '../../Discount/types';
2
+ import type { OrderTempOrder } from '../types';
3
+ /** Runtime-only allocation constraints. Never copied into order/product metadata. */
4
+ export interface ProductVoucherGroup {
5
+ key: string;
6
+ discountIds: Array<number | string>;
7
+ }
8
+ export declare function productVoucherGroupKey(order: OrderTempOrder, product: any): string | undefined;
9
+ export declare function isUsableProductVoucher(discount: Discount): boolean;
10
+ export declare function voucherGroupError(): Error & {
11
+ code: string;
12
+ };
13
+ export declare function allowsProductVoucher(order: OrderTempOrder | null | undefined, product: any, discount: Discount): boolean;
14
+ /** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
15
+ export declare function validateProductVoucherGroups(order: OrderTempOrder, discounts: Discount[], previous?: OrderTempOrder, requireCoverage?: boolean): void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowsProductVoucher = allowsProductVoucher;
7
+ exports.isUsableProductVoucher = isUsableProductVoucher;
8
+ exports.productVoucherGroupKey = productVoucherGroupKey;
9
+ exports.validateProductVoucherGroups = validateProductVoucherGroups;
10
+ exports.voucherGroupError = voucherGroupError;
11
+ var _availability = require("../../Discount/availability");
12
+ var _dayjs = _interopRequireDefault(require("dayjs"));
13
+ var _utils = require("../../../solution/ShopDiscount/utils");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ /** Runtime-only allocation constraints. Never copied into order/product metadata. */
16
+
17
+ function productVoucherGroupKey(order, product) {
18
+ const uid = product?.metadata?.unique_identification_number ?? product?.unique_identification_number;
19
+ return order._extend?.productsByUid?.[String(uid)]?.productVoucherGroupKey;
20
+ }
21
+ function isUsableProductVoucher(discount) {
22
+ return (discount.tag || discount.type) === 'good_pass' && !discount.isEditMode && !discount.isDisabled && !(0, _availability.getDiscountUsageBlockReason)(discount) && !(0, _utils.getDiscountTimeUnavailableReason)(discount, (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss'));
23
+ }
24
+ function voucherGroupError() {
25
+ return Object.assign(new Error('The selected items no longer match the available vouchers. Please adjust your selection.'), {
26
+ code: 'PRODUCT_VOUCHER_GROUP_INVALID'
27
+ });
28
+ }
29
+ function allowsProductVoucher(order, product, discount) {
30
+ const groups = order?._extend?.productVoucherGroups;
31
+ if (!order || !groups?.length) return true;
32
+ const key = productVoucherGroupKey(order, product);
33
+ if (!key) return !groups.some(group => group.discountIds.some(id => String(id) === String(discount.id)));
34
+ return (discount.tag || discount.type) === 'good_pass' && Boolean(groups.find(group => group.key === key)?.discountIds.some(id => String(id) === String(discount.id)));
35
+ }
36
+
37
+ /** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
38
+ function validateProductVoucherGroups(order, discounts, previous, requireCoverage = false) {
39
+ const groups = order._extend?.productVoucherGroups;
40
+ if (!groups?.length) return;
41
+ const usedIds = new Set();
42
+ const byId = new Map(discounts.filter(isUsableProductVoucher).map(discount => [String(discount.id), discount]));
43
+ const quantity = item => Number(item.num ?? item.product_quantity ?? 0);
44
+ for (const group of groups) {
45
+ const items = order.products.filter(item => productVoucherGroupKey(order, item) === group.key);
46
+ const selected = items.reduce((sum, item) => sum + quantity(item), 0);
47
+ const before = previous?.products.filter(item => productVoucherGroupKey(previous, item) === group.key).reduce((sum, item) => sum + quantity(item), 0) ?? 0;
48
+ if (!requireCoverage && previous && selected <= before) continue;
49
+ const ids = new Set(group.discountIds.map(String).filter(id => byId.has(id)));
50
+ if (!Number.isInteger(selected) || selected < 0 || selected > ids.size) throw voucherGroupError();
51
+ if (!requireCoverage) continue;
52
+ for (const item of items) {
53
+ const applied = (item.discount_list || []).filter(entry => (entry.type || entry.tag) === 'good_pass');
54
+ // Rules splits a good_pass allocation into one physical line per instance.
55
+ const id = String(applied[0]?.discount?.resource_id ?? '');
56
+ const voucher = byId.get(id);
57
+ if (quantity(item) !== 1 || applied.length !== 1 || !ids.has(id) || !voucher?.isAvailable || voucher.config?.isAvailable === false || usedIds.has(id)) throw voucherGroupError();
58
+ usedIds.add(id);
59
+ }
60
+ }
61
+ if (order.products.some(item => !groups.some(group => group.key === productVoucherGroupKey(order, item)))) {
62
+ throw voucherGroupError();
63
+ }
64
+ }
@@ -128,7 +128,9 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
128
128
  *
129
129
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
130
130
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
131
- * (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
131
+ * (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
132
+ * 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
133
+ * Rules 内部 `getProductTotalPrice` /
132
134
  * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
133
135
  * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
134
136
  * total(source + option + bundle)对齐。
@@ -651,7 +651,9 @@ function getBundleSellingMagnitude(bundle) {
651
651
  *
652
652
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
653
653
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
654
- * (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
654
+ * (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
655
+ * 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
656
+ * Rules 内部 `getProductTotalPrice` /
655
657
  * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
656
658
  * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
657
659
  * total(source + option + bundle)对齐。
@@ -934,7 +936,8 @@ function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
934
936
  _id: product.metadata?.unique_identification_number ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, _utils2.buildProductLineFingerprint)(getProductSkuOptions(product), product.product_bundle)}`,
935
937
  // Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
936
938
  // 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
937
- price: sourcePrice,
939
+ // 赠品基础价不再参与卡券;source 元数据保留原价,供后续与赠送优惠相抵。
940
+ price: metadataAny._giftInfo ? '0.00' : sourcePrice,
938
941
  // total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
939
942
  total: new _decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
940
943
  origin_total: new _decimal.default(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
@@ -1124,6 +1127,7 @@ function normalizeSubmitPlatform(platform) {
1124
1127
  const lower = value.toLowerCase();
1125
1128
  if (lower === 'pc') return 'PC';
1126
1129
  if (lower === 'h5') return 'H5';
1130
+ if (lower === 'webpos') return 'pos';
1127
1131
  return value;
1128
1132
  }
1129
1133
  function normalizeSubmitProductionCode(value) {
@@ -37,7 +37,9 @@ function collectReferencedRuleIds(products) {
37
37
  if (!Array.isArray(variants)) return;
38
38
  variants.forEach(variant => {
39
39
  const id = String(variant?.data_variant_rule_id ?? '').trim();
40
- if (id) ids.add(id);
40
+ // Rule 0 is the default-variant sentinel, not a strategy to load.
41
+ // Keep the evaluator responsible for its pricing/settlement semantics.
42
+ if (id && Number(id) !== 0) ids.add(id);
41
43
  });
42
44
  };
43
45
  products.forEach(product => {
@@ -56,10 +58,12 @@ function isEvaluatorReady(evaluator, products) {
56
58
  // A referenced Data Variant cannot be evaluated authoritatively until those
57
59
  // configs have arrived. Evaluators without this capability remain compatible.
58
60
  if (typeof evaluator.getStrategyConfigs === 'function') {
61
+ const referencedRuleIds = collectReferencedRuleIds(products);
62
+ if (referencedRuleIds.size === 0) return true;
59
63
  const configs = evaluator.getStrategyConfigs();
60
64
  if (!Array.isArray(configs) || configs.length === 0) return false;
61
65
  const availableRuleIds = new Set(configs.map(config => String(config?.metadata?.id ?? '').trim()).filter(Boolean));
62
- return Array.from(collectReferencedRuleIds(products)).every(id => availableRuleIds.has(id));
66
+ return Array.from(referencedRuleIds).every(id => availableRuleIds.has(id));
63
67
  }
64
68
  return true;
65
69
  }
@@ -37,6 +37,8 @@ export declare class ProductList extends BaseModule implements Module {
37
37
  schedule_date?: string;
38
38
  channel?: string;
39
39
  }): Promise<any>;
40
+ /** Venue-only raw, complete pool load. No date/customer evaluation and no shared catalog publication. */
41
+ loadVenueCatalogPool(params?: Pick<ProductListLoadProductsParams, 'product_ids' | 'collection' | 'category_ids' | 'extension_type' | 'cacheId'>): Promise<ProductData[]>;
40
42
  /**
41
43
  * Remember raw remote product records before client-side Data Variant
42
44
  * evaluation. Quote-only reads can then always start from a clean baseline.
@@ -66,7 +66,13 @@ class ProductList extends _BaseModule.BaseModule {
66
66
  * productList.updateOtherParams({ channel: 'pos' });
67
67
  */
68
68
  updateOtherParams(params) {
69
+ const previousScope = this.otherParams.catalogScopeKey;
69
70
  this.otherParams = params || {};
71
+ if (previousScope !== this.otherParams.catalogScopeKey && (previousScope || this.otherParams.catalogScopeKey)) {
72
+ this.store.list = [];
73
+ this.rawProductPriceSources.clear();
74
+ this.core.effects.emit(`${this.name}:changed`, this.store.list);
75
+ }
70
76
  }
71
77
  async storeChange(path, value) {
72
78
  // No longer needed - products are stored as plain objects instead of Product instances
@@ -101,6 +107,12 @@ class ProductList extends _BaseModule.BaseModule {
101
107
  status = 'published',
102
108
  strategy_context
103
109
  } = {}, options) {
110
+ const scope = this.otherParams.catalogScopeKey;
111
+ const assertScope = () => {
112
+ if (scope !== this.otherParams.catalogScopeKey) throw Object.assign(new Error('Product catalog context changed'), {
113
+ name: 'AbortError'
114
+ });
115
+ };
104
116
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
105
117
  // if (!schedule_ids?.length) {
106
118
  // const schedule_ids_data = this.store.schedule
@@ -180,6 +192,7 @@ class ProductList extends _BaseModule.BaseModule {
180
192
  const handledByOsServer = (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request);
181
193
  const originalCallback = options?.callback;
182
194
  const subscriptionCallback = typeof originalCallback === 'function' ? async result => {
195
+ if (scope !== this.otherParams.catalogScopeKey) return;
183
196
  const callbackList = result?.data?.list;
184
197
  if (!Array.isArray(callbackList)) {
185
198
  originalCallback(result);
@@ -197,6 +210,7 @@ class ProductList extends _BaseModule.BaseModule {
197
210
  queryPayload,
198
211
  handledByOsServer
199
212
  });
213
+ assertScope();
200
214
  await this.addProduct(products);
201
215
  originalCallback(handledByOsServer ? result : {
202
216
  ...result,
@@ -212,6 +226,7 @@ class ProductList extends _BaseModule.BaseModule {
212
226
  subscriberId: options?.subscriberId,
213
227
  customToast: () => {}
214
228
  });
229
+ assertScope();
215
230
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
216
231
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
217
232
  }
@@ -250,6 +265,65 @@ class ProductList extends _BaseModule.BaseModule {
250
265
  return productsData.data;
251
266
  }
252
267
 
268
+ /** Venue-only raw, complete pool load. No date/customer evaluation and no shared catalog publication. */
269
+ async loadVenueCatalogPool(params = {}) {
270
+ const channelMap = {
271
+ online_store: 'online-store',
272
+ scan_to_order: 'online-store',
273
+ 'scan-to-order': 'online-store',
274
+ scan_to_order_2: 'online-store',
275
+ scan_to_order_3: 'scantoorder3'
276
+ };
277
+ const channel = this.otherParams?.channel;
278
+ const response = await this.request.post('/product/query', {
279
+ // Bypass the endpoint cache when seeding this pool; subsequent reads still
280
+ // reuse the venue catalog session's single local snapshot.
281
+ force_ignore_cache_flag: 1,
282
+ // The customer endpoint otherwise filters out future/variant members.
283
+ open_quotation: 0,
284
+ open_bundle: 1,
285
+ with: [..._clientDataVariants.PRODUCT_QUERY_DATA_VARIANT_RELATIONS],
286
+ with_count: ['bundleGroup', 'optionGroup'],
287
+ with_schedule: 1,
288
+ status: 'published',
289
+ num: 500,
290
+ skip: 1,
291
+ is_eject: 1,
292
+ // Channel is stable for this runtime owner and remains a server publication
293
+ // filter. Date/customer/menu membership and pricing are evaluated locally.
294
+ application_code: typeof channel === 'string' ? channelMap[channel] || channel : channel,
295
+ ...(params.product_ids?.length ? {
296
+ ids: params.product_ids
297
+ } : {}),
298
+ ...(params.collection ? {
299
+ collection: params.collection
300
+ } : {}),
301
+ ...(params.category_ids?.length ? {
302
+ category_ids: params.category_ids
303
+ } : {}),
304
+ ...(params.extension_type?.length ? {
305
+ extension_type: params.extension_type
306
+ } : {}),
307
+ front_end_cache_id: params.cacheId
308
+ }, {
309
+ useCache: false,
310
+ customToast: () => {}
311
+ });
312
+ const data = response?.data;
313
+ if (response?.status === false || response?.code != null && Number(response.code) !== 200 || !Array.isArray(data?.list)) {
314
+ throw Object.assign(new Error(response?.message || 'The complete venue product pool could not be loaded.'), {
315
+ code: 'VENUE_CATALOG_LOAD_FAILED'
316
+ });
317
+ }
318
+ const total = data.total ?? data.total_count ?? data.total_num;
319
+ if (total != null && Number.isFinite(Number(total)) && Number(total) > data.list.length || total == null && data.list.length >= 500) {
320
+ throw Object.assign(new Error('The venue product pool is incomplete. A single complete catalog response is required.'), {
321
+ code: 'VENUE_CATALOG_INCOMPLETE'
322
+ });
323
+ }
324
+ return (0, _lodashEs.cloneDeep)(data.list);
325
+ }
326
+
253
327
  /**
254
328
  * Remember raw remote product records before client-side Data Variant
255
329
  * evaluation. Quote-only reads can then always start from a clean baseline.
@@ -225,6 +225,16 @@ function isCandidateFromExcludedScheduleDate(params) {
225
225
  }
226
226
  return getSessionRangesForProduct(projection, product, candidateDateRange, true).some(range => getProductTimeRangeIdentity(range) === candidateIdentity);
227
227
  }
228
+ function resolveRememberedDurationRange(product, value, timezoneName) {
229
+ if (value === undefined) return null;
230
+ const range = normalizeAbsoluteRange(value, timezoneName);
231
+ if (!range || range.end <= range.start) {
232
+ throw availabilityError('INVALID_TARGET_FILTER', '记忆时间必须包含有效且递增的开始和结束时间');
233
+ }
234
+ if (product.kind !== 'duration') return null;
235
+ if (!product.isFlexibleDuration && (!Number.isFinite(product.durationMinutes) || range.end - range.start !== Number(product.durationMinutes) * 60000)) return null;
236
+ return range;
237
+ }
228
238
  function evaluateCandidateTimeGate(params) {
229
239
  const {
230
240
  projection,
@@ -298,6 +308,10 @@ function evaluateCandidateTimeGate(params) {
298
308
  };
299
309
  }
300
310
  if (policy.type === 'before_start') {
311
+ const rememberedRange = resolveRememberedDurationRange(product, evaluationContext.rememberedTimeByProductId?.[String(product.id)], timezoneName);
312
+ // Only the exact order-scoped interval may retain its start after this
313
+ // cutoff. The end/past and operating-window gates above still apply.
314
+ if (rememberedRange?.start === candidateRange.start && rememberedRange.end === candidateRange.end) return null;
301
315
  // POS fixed-duration candidates use the context's stable opening-minute
302
316
  // anchor. Keep that anchored range selectable while it is still active;
303
317
  // otherwise a minute refresh turns it into 0 capacity and incorrectly
@@ -555,6 +569,10 @@ function buildCellKey(params) {
555
569
  return [String(params.productId), params.groupId, String(params.resourceId), params.start, params.end].join(':');
556
570
  }
557
571
  function dedupeOccupancyRefKey(occupancy) {
572
+ const sessionKey = occupancy.raw?.__availabilitySessionOccupancyKey;
573
+ if (typeof sessionKey === 'string' && sessionKey) {
574
+ return `session:${JSON.stringify([String(occupancy.resourceId), sessionKey])}`;
575
+ }
558
576
  if (occupancy.scheduleEventId !== undefined && occupancy.scheduleEventId !== null) {
559
577
  return `scheduleEvent:${String(occupancy.resourceId)}:${String(occupancy.scheduleEventId)}`;
560
578
  }
@@ -1043,6 +1061,19 @@ function getDurationBusinessDate(projection, startAt) {
1043
1061
  });
1044
1062
  return period?.businessDate || startAt.slice(0, 10);
1045
1063
  }
1064
+ function getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes) {
1065
+ const range = request.requestedRangesByProductId?.[String(product.id)];
1066
+ if (!runtimeOptions.allowRequestedRanges || !range || product.kind !== 'duration' && product.kind !== 'session') return [];
1067
+ const start = toDateTime(range.startAt);
1068
+ const end = toDateTime(range.endAt);
1069
+ if (!Number.isFinite(start) || !Number.isFinite(end) || !Number.isInteger((end - start) / 60000) || end <= start) {
1070
+ throw availabilityError('INVALID_TARGET_FILTER', '手工预约范围必须包含有效起止时间和正整数分钟时长');
1071
+ }
1072
+ const candidate = createDurationTimeRangeWithEnd(product, start, end, projection, fixedOffsetMinutes);
1073
+ candidate.businessDate = getDurationBusinessDate(projection, candidate.startAt);
1074
+ assertRangesWithinProjection(projection, [candidate]);
1075
+ return [candidate];
1076
+ }
1046
1077
  function getAlignedDurationRanges(params) {
1047
1078
  const {
1048
1079
  projection,
@@ -1143,6 +1174,12 @@ function getAlignedDurationRanges(params) {
1143
1174
  addRange(start, start + duration * 60000);
1144
1175
  }
1145
1176
  }
1177
+ const rememberedRange = resolveRememberedDurationRange(product, request.rememberedTimeByProductId?.[String(product.id)], projection.meta.timezone);
1178
+ if (rememberedRange && baseRanges.some(range => contains(range, rememberedRange))) {
1179
+ // Never extend a remembered flexible interval when the resource now has a
1180
+ // later closing time, or rebuild a fixed interval after its duration changed.
1181
+ addRange(rememberedRange.start, rememberedRange.end);
1182
+ }
1146
1183
  const editingAt = request.editingStartAtByProductId?.[String(product.id)];
1147
1184
  if (editingAt !== undefined) {
1148
1185
  const start = toDateTime(editingAt);
@@ -1197,6 +1234,16 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
1197
1234
  const resourceWindowIndex = buildResourceWindowIndex(projection, allowExcludedScheduleDateOverride);
1198
1235
  const filteredProductIdSet = request.productIds?.length ? new Set(request.productIds.map(String)) : null;
1199
1236
  return projection.products.filter(product => !filteredProductIdSet || filteredProductIdSet.has(String(product.id))).map(product => {
1237
+ const requestedRanges = getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes);
1238
+ if (requestedRanges.length > 0) {
1239
+ return {
1240
+ productId: product.id,
1241
+ title: product.title,
1242
+ kind: product.kind,
1243
+ slotStepMinutes,
1244
+ ranges: dedupeProductRanges(requestedRanges)
1245
+ };
1246
+ }
1200
1247
  if (product.kind === 'normal') {
1201
1248
  return {
1202
1249
  productId: product.id,
@@ -1476,7 +1523,8 @@ function buildEvaluationContext(params) {
1476
1523
  durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
1477
1524
  allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true,
1478
1525
  useDurationTimeGrid: params.useDurationTimeGrid === true,
1479
- enforceSaleCutoff: params.enforceSaleCutoff === true
1526
+ enforceSaleCutoff: params.enforceSaleCutoff === true,
1527
+ rememberedTimeByProductId: params.rememberedTimeByProductId
1480
1528
  };
1481
1529
  }
1482
1530
  function summarizeStatuses(statuses) {
@@ -1885,6 +1933,7 @@ function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
1885
1933
  resourceIds: request.resourceIds,
1886
1934
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
1887
1935
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
1936
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
1888
1937
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
1889
1938
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
1890
1939
  });
@@ -1963,6 +2012,7 @@ function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
1963
2012
  evaluatedAt,
1964
2013
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
1965
2014
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
2015
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
1966
2016
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
1967
2017
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
1968
2018
  });
@@ -2165,6 +2215,7 @@ function validateAvailabilitySelection(projection, params, runtimeOptions = {})
2165
2215
  requirementSelections: params.requirementSelections,
2166
2216
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
2167
2217
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
2218
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
2168
2219
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
2169
2220
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
2170
2221
  })
@@ -263,8 +263,17 @@ export interface GetProductTimeRangesRequest {
263
263
  partySize?: number;
264
264
  durationMinutesByProductId?: Record<string, number>;
265
265
  durationStartTimesByProductId?: Record<string, string[]>;
266
+ /** Explicit POS manual interval. Endpoints are absolute datetimes, not business-day HH:mm. */
267
+ requestedRangesByProductId?: Record<string, {
268
+ startAt: string;
269
+ endAt: string;
270
+ }>;
266
271
  /** Restore only the exact remembered start; recompute the end from current product/windows. */
267
272
  rememberedStartAtByProductId?: Record<string, string>;
273
+ /** Order-scoped v2 memory preserves the complete actual booking interval. */
274
+ rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
275
+ /** Required by the POS facade before accepting v2 remembered intervals. */
276
+ orderSessionId?: string;
268
277
  /** Edit only: preserve the full actual start plus an explicit durationMinutesByProductId. */
269
278
  editingStartAtByProductId?: Record<string, string>;
270
279
  /**
@@ -279,6 +288,8 @@ export interface GetProductTimeRangesRuntimeOptions {
279
288
  useDurationTimeGrid?: boolean;
280
289
  /** Automatic remembered selection must not use POS opening-minute cutoff exceptions. */
281
290
  enforceSaleCutoff?: boolean;
291
+ /** Internal POS capability, validated against the current order session by the facade. */
292
+ rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
282
293
  /**
283
294
  * Internal POS capability: fixed-duration candidates start from the stable
284
295
  * context anchor's current minute instead of rounding up to ten minutes, and
@@ -294,6 +305,8 @@ export interface GetProductTimeRangesRuntimeOptions {
294
305
  * disabled.
295
306
  */
296
307
  allowSessionCustomRanges?: boolean;
308
+ /** Internal POS manual capability; automatic/remembered selections must leave this disabled. */
309
+ allowRequestedRanges?: boolean;
297
310
  /**
298
311
  * Internal POS capability: materialize candidates whose schedule date was
299
312
  * explicitly excluded, while availability evaluation keeps them unavailable.
@@ -9,6 +9,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
9
9
  private store;
10
10
  window: WindowPlugin;
11
11
  private hooks;
12
+ private discountScope?;
13
+ setDiscountScope(scope: (product: any, discount: Discount) => boolean): void;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
16
  setRulesList(rulesList: Rules[]): Promise<void>;