@pisell/pisellos 2.3.225 → 2.3.227

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.
@@ -131,6 +131,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
131
131
  scannedDiscountList?: Discount[];
132
132
  }>;
133
133
  applyDiscount(options?: {
134
+ /** Draft recovery must remove stale discounts even when no card survives revalidation. */
135
+ force?: boolean;
134
136
  reapplyBookingDiscountProductUids?: string[];
135
137
  reapplyWeighedDiscountProductUids?: string[];
136
138
  preferredEntitlementPassIds?: number[];
@@ -642,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
644
  generateIdempotencyToken(): string;
643
645
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
646
  createOrder(params: CommitOrderParams['query']): {
645
- type: "appointment_booking" | "virtual";
647
+ type: "virtual" | "appointment_booking";
646
648
  platform: string;
647
649
  sales_channel: string;
648
650
  order_sales_channel: string;
@@ -1376,7 +1376,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1376
1376
  delete tempOrder.discount_list;
1377
1377
  var discountList = ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.getDiscountList()) || [];
1378
1378
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
1379
- if (shouldSkipDiscountCalculation) return;
1379
+ if (shouldSkipDiscountCalculation && !(options !== null && options !== void 0 && options.force)) return;
1380
1380
  var rulesModule = this.store.rules;
1381
1381
  if (!rulesModule) return;
1382
1382
  var result = rulesModule.calcDiscount({
@@ -1390,7 +1390,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1390
1390
  }, {
1391
1391
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
1392
1392
  reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids,
1393
- preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
1393
+ preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds,
1394
+ force: options === null || options === void 0 ? void 0 : options.force
1394
1395
  });
1395
1396
  if (result !== null && result !== void 0 && result.productList) {
1396
1397
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
@@ -498,7 +498,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
498
498
  }
499
499
  });
500
500
  }
501
- var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
501
+ var hasDiscountInput = (options === null || options === void 0 ? void 0 : options.force) === true || editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
502
502
  if (!hasDiscountInput) {
503
503
  return {
504
504
  discountList: discountList,
@@ -34,6 +34,8 @@ export interface RulesCalcDiscountParams {
34
34
  orderTotalAmount: number;
35
35
  }
36
36
  export interface RulesCalcDiscountOptions {
37
+ /** Clear stale line discounts when draft revalidation yields no eligible cards. */
38
+ force?: boolean;
37
39
  isSelected?: boolean;
38
40
  discountId?: number;
39
41
  selectedList?: SetDiscountSelectedParams[];
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
345
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -25,23 +25,27 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
27
  small_ticket_data_flag?: number | undefined;
28
- metadata: Record<string, any>;
29
28
  type: string;
29
+ metadata: Record<string, any>;
30
+ business_code?: string | undefined;
31
+ status: string;
30
32
  note: string;
31
33
  holder: Record<string, any> | null;
32
- relation_forms: any[];
34
+ customer_id: number | null;
35
+ bookings: any[];
36
+ payments: any[];
37
+ contacts_info: Record<string, any> | null;
38
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
39
+ refunds?: any[] | undefined;
33
40
  holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
34
41
  order_id: number | null;
35
42
  external_sale_number: string;
36
43
  order_number: string | null;
37
44
  shop_order_number: string | null;
38
45
  shop_full_order_number: string | null;
39
- business_code?: string | undefined;
40
46
  sales_channel: string;
41
47
  order_sales_channel: string;
42
- status: string;
43
48
  shipping_status: string;
44
- customer_id: number | null;
45
49
  customer_name: string;
46
50
  country_calling_code: string;
47
51
  phone: string;
@@ -60,12 +64,8 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
60
64
  delivery_type?: string | undefined;
61
65
  table_number?: Record<string, any> | undefined;
62
66
  schedule_date: string;
63
- bookings: any[];
64
- payments: any[];
65
- contacts_info: Record<string, any> | null;
66
- order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
67
- refunds?: any[] | undefined;
68
67
  surcharges: any[];
68
+ relation_forms: any[];
69
69
  contacts: any[];
70
70
  };
71
71
  export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
@@ -0,0 +1,8 @@
1
+ /** Persist selection intent only; availability and pricing must come from fresh OS data. */
2
+ export interface DraftDiscountSelection {
3
+ id: string;
4
+ code?: string;
5
+ selected: boolean;
6
+ isScan?: boolean;
7
+ }
8
+ export declare function collectDraftDiscountSelection(order: Record<string, any>, runtime?: Record<string, any>[]): DraftDiscountSelection[];
@@ -0,0 +1,101 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ /** Persist selection intent only; availability and pricing must come from fresh OS data. */
9
+
10
+ var voucherTypes = new Set(['discount_card', 'product_discount_card', 'good_pass', 'entitlement_pass']);
11
+ export function collectDraftDiscountSelection(order, runtime) {
12
+ var selections = new Map();
13
+ var append = function append(discount) {
14
+ var _discount$discount, _discount$data, _discount$discount_ca, _discount$metadata;
15
+ var line = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
16
+ if (!voucherTypes.has((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type)) || discount.isEditMode) return;
17
+ var id = String(line ? ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id || '' : discount.id || '');
18
+ if (!id || !Number.isFinite(Number(id)) || Number(id) <= 0) return;
19
+ var machineCode = ((_discount$data = discount.data) === null || _discount$data === void 0 || (_discount$data = _discount$data.discount_card_list) === null || _discount$data === void 0 ? void 0 : _discount$data[0]) || ((_discount$discount_ca = discount.discount_card_list) === null || _discount$discount_ca === void 0 ? void 0 : _discount$discount_ca[0]) || discount.machinecode || discount.machine_code || discount;
20
+ var code = machineCode.encoded || ((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.encoded);
21
+ var previous = selections.get(id);
22
+ selections.set(id, {
23
+ id: id,
24
+ code: typeof code === 'string' && code.trim() ? code.trim() : previous === null || previous === void 0 ? void 0 : previous.code,
25
+ selected: line || discount.isSelected !== false,
26
+ isScan: Boolean(discount.isScan || (previous === null || previous === void 0 ? void 0 : previous.isScan))
27
+ });
28
+ };
29
+ // Old venue drafts may have lost the root list on reload, while line discounts retain the code.
30
+ var _iterator = _createForOfIteratorHelper(order.products || []),
31
+ _step;
32
+ try {
33
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
34
+ var product = _step.value;
35
+ var _iterator4 = _createForOfIteratorHelper(product.discount_list || []),
36
+ _step4;
37
+ try {
38
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
39
+ var discount = _step4.value;
40
+ append(discount, true);
41
+ }
42
+ } catch (err) {
43
+ _iterator4.e(err);
44
+ } finally {
45
+ _iterator4.f();
46
+ }
47
+ var _iterator5 = _createForOfIteratorHelper(product.product_bundle || []),
48
+ _step5;
49
+ try {
50
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
51
+ var bundle = _step5.value;
52
+ var _iterator6 = _createForOfIteratorHelper(bundle.discount_list || []),
53
+ _step6;
54
+ try {
55
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
56
+ var _discount = _step6.value;
57
+ append(_discount, true);
58
+ }
59
+ } catch (err) {
60
+ _iterator6.e(err);
61
+ } finally {
62
+ _iterator6.f();
63
+ }
64
+ }
65
+ } catch (err) {
66
+ _iterator5.e(err);
67
+ } finally {
68
+ _iterator5.f();
69
+ }
70
+ }
71
+ } catch (err) {
72
+ _iterator.e(err);
73
+ } finally {
74
+ _iterator.f();
75
+ }
76
+ var _iterator2 = _createForOfIteratorHelper(order.discount_list || []),
77
+ _step2;
78
+ try {
79
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
80
+ var _discount2 = _step2.value;
81
+ append(_discount2);
82
+ }
83
+ } catch (err) {
84
+ _iterator2.e(err);
85
+ } finally {
86
+ _iterator2.f();
87
+ }
88
+ var _iterator3 = _createForOfIteratorHelper(runtime || []),
89
+ _step3;
90
+ try {
91
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
92
+ var _discount3 = _step3.value;
93
+ append(_discount3);
94
+ }
95
+ } catch (err) {
96
+ _iterator3.e(err);
97
+ } finally {
98
+ _iterator3.f();
99
+ }
100
+ return _toConsumableArray(selections.values());
101
+ }
@@ -1,3 +1,4 @@
1
+ import { type DraftDiscountSelection } from './draftDiscounts';
1
2
  import type { Module, ModuleOptions, PisellCore } from '../../types';
2
3
  import type { ProductData } from '../../modules';
3
4
  import type { BookingCalcContext } from '../../modules/BookingContext';
@@ -195,6 +196,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
195
196
  protected getRegisteredModuleNames(): readonly string[];
196
197
  protected createSubModule(moduleName: string): Module | null;
197
198
  addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
199
+ getDraftDiscountSelection(): DraftDiscountSelection[];
200
+ /** Restore a local draft's cards as editable runtime entries, never as settled historical cards. */
201
+ restoreDraftDiscountSelection(snapshot: {
202
+ order: Record<string, any>;
203
+ discountSelection?: DraftDiscountSelection[];
204
+ }): Promise<void>;
198
205
  syncAuthenticatedOrderCustomer(): Promise<boolean>;
199
206
  private isAuthenticatedCustomerUserPlatform;
200
207
  private resolveDiscountOrderIdentity;