@pisell/pisellos 2.3.226 → 2.3.228

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 (52) hide show
  1. package/dist/modules/Customer/types.d.ts +0 -4
  2. package/dist/modules/Order/index.d.ts +2 -0
  3. package/dist/modules/Order/index.js +82 -125
  4. package/dist/modules/Order/types.d.ts +0 -2
  5. package/dist/modules/Order/utils.js +0 -2
  6. package/dist/modules/Product/index.d.ts +1 -1
  7. package/dist/modules/Rules/index.js +1 -1
  8. package/dist/modules/Rules/types.d.ts +2 -0
  9. package/dist/modules/Summary/utils.d.ts +1 -1
  10. package/dist/solution/BaseSales/index.js +0 -3
  11. package/dist/solution/BookingByStep/index.d.ts +2 -2
  12. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
  13. package/dist/solution/Checkout/index.js +69 -104
  14. package/dist/solution/Checkout/types.d.ts +0 -1
  15. package/dist/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
  16. package/dist/solution/ScanOrder/additionalOrderPayload.js +52 -0
  17. package/dist/solution/ScanOrder/index.js +13 -19
  18. package/dist/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
  19. package/dist/solution/UnifiedBookingSales/draftDiscounts.js +101 -0
  20. package/dist/solution/UnifiedBookingSales/index.d.ts +7 -0
  21. package/dist/solution/UnifiedBookingSales/index.js +1253 -1072
  22. package/dist/solution/UnifiedBookingSales/types.d.ts +5 -0
  23. package/dist/solution/VenueBooking/index.js +490 -522
  24. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  25. package/lib/modules/Customer/types.d.ts +0 -4
  26. package/lib/modules/Order/index.d.ts +2 -0
  27. package/lib/modules/Order/index.js +9 -46
  28. package/lib/modules/Order/types.d.ts +0 -2
  29. package/lib/modules/Order/utils.js +1 -5
  30. package/lib/modules/Product/index.d.ts +1 -1
  31. package/lib/modules/Rules/index.js +1 -1
  32. package/lib/modules/Rules/types.d.ts +2 -0
  33. package/lib/modules/Summary/utils.d.ts +1 -1
  34. package/lib/solution/BaseSales/index.js +0 -3
  35. package/lib/solution/BookingByStep/index.d.ts +2 -2
  36. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
  37. package/lib/solution/Checkout/index.js +0 -21
  38. package/lib/solution/Checkout/types.d.ts +0 -1
  39. package/lib/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
  40. package/lib/solution/ScanOrder/additionalOrderPayload.js +50 -0
  41. package/lib/solution/ScanOrder/index.js +5 -9
  42. package/lib/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
  43. package/lib/solution/UnifiedBookingSales/draftDiscounts.js +36 -0
  44. package/lib/solution/UnifiedBookingSales/index.d.ts +7 -0
  45. package/lib/solution/UnifiedBookingSales/index.js +78 -0
  46. package/lib/solution/UnifiedBookingSales/types.d.ts +5 -0
  47. package/lib/solution/VenueBooking/index.js +1 -6
  48. package/package.json +1 -1
  49. package/dist/modules/Order/utils/bookingUuid.d.ts +0 -4
  50. package/dist/modules/Order/utils/bookingUuid.js +0 -24
  51. package/lib/modules/Order/utils/bookingUuid.d.ts +0 -4
  52. package/lib/modules/Order/utils/bookingUuid.js +0 -25
@@ -40,6 +40,7 @@ import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOption
40
40
  import dayjs from 'dayjs';
41
41
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
42
42
  import { prepareScanOrderMenuAvailability, ScanOrderMenuAvailabilityError } from "./menuAvailability";
43
+ import { formatScanOrderMoreProducts } from "./additionalOrderPayload";
43
44
  export * from "./types";
44
45
  function isItemRewardProductDiscount(discount) {
45
46
  var _discount$metadata, _discount$metadata2;
@@ -1430,18 +1431,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1430
1431
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1431
1432
  var bookings = payload.bookings || [];
1432
1433
  if (!tempOrder.order_id && bookings.length === 0) {
1433
- var _tempOrder$_extend;
1434
- var extend = (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 ? _tempOrder$_extend : tempOrder._extend = {};
1435
- if (!extend.scanOrderBookingUuid) {
1436
- var _this5$store$order, _this5$store$order$pe;
1437
- extend.scanOrderBookingUuid = createUuidV4();
1438
- (_this5$store$order = _this5.store.order) === null || _this5$store$order === void 0 || (_this5$store$order$pe = _this5$store$order.persistTempOrder) === null || _this5$store$order$pe === void 0 || _this5$store$order$pe.call(_this5$store$order);
1439
- }
1440
1434
  var bookingStart = dayjs(now);
1441
1435
  var bookingDuration = resolveTableOccupancyDuration(tempOrder);
1442
1436
  var bookingEnd = bookingStart.add(bookingDuration, 'minute');
1443
1437
  bookings = [normalizeSubmitBooking({
1444
- uuid: extend.scanOrderBookingUuid,
1445
1438
  relation_id: 0,
1446
1439
  form_id: 0,
1447
1440
  start_time: bookingStart.format('HH:mm'),
@@ -1530,7 +1523,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1530
1523
  value: function () {
1531
1524
  var _submitScanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1532
1525
  var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
1533
- var tempOrder, enhancePayload, latestSummary, payload, products, orderId, result;
1526
+ var tempOrder, enhancePayload, latestSummary, payload, products, orderId, requestBody, result;
1534
1527
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1535
1528
  while (1) switch (_context17.prev = _context17.next) {
1536
1529
  case 0:
@@ -1563,19 +1556,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1563
1556
  summary: latestSummary,
1564
1557
  enhance: enhancePayload
1565
1558
  });
1566
- products = filterProductsForScanOrderMore(payload.products);
1559
+ products = formatScanOrderMoreProducts(filterProductsForScanOrderMore(payload.products));
1567
1560
  orderId = tempOrder.order_id;
1568
- _context17.next = 13;
1569
- return this.request.put("/order/order/product/".concat(orderId), {
1561
+ requestBody = {
1570
1562
  products: products,
1571
1563
  request_unique_idempotency_token: payload.request_unique_idempotency_token
1572
- }, {
1564
+ };
1565
+ _context17.next = 14;
1566
+ return this.request.put("/order/order/product/".concat(orderId), requestBody, {
1573
1567
  customToast: function customToast() {}
1574
1568
  });
1575
- case 13:
1569
+ case 14:
1576
1570
  result = _context17.sent;
1577
1571
  if (!((result === null || result === void 0 ? void 0 : result.code) === 200 && !(result !== null && result !== void 0 && result.data))) {
1578
- _context17.next = 16;
1572
+ _context17.next = 17;
1579
1573
  break;
1580
1574
  }
1581
1575
  return _context17.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
@@ -1583,9 +1577,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1583
1577
  order_id: orderId
1584
1578
  }
1585
1579
  }));
1586
- case 16:
1587
- return _context17.abrupt("return", result);
1588
1580
  case 17:
1581
+ return _context17.abrupt("return", result);
1582
+ case 18:
1589
1583
  case "end":
1590
1584
  return _context17.stop();
1591
1585
  }
@@ -1606,10 +1600,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1606
1600
  _step5;
1607
1601
  try {
1608
1602
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1609
- var _product$metadata3, _product$metadata4, _tempOrder$_extend2;
1603
+ var _product$metadata3, _product$metadata4, _tempOrder$_extend;
1610
1604
  var product = _step5.value;
1611
1605
  var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
1612
- var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.productsByUid) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2[String(uid)]) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.origin : undefined];
1606
+ var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
1613
1607
  for (var _i5 = 0, _origins = origins; _i5 < _origins.length; _i5++) {
1614
1608
  var origin = _origins[_i5];
1615
1609
  if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
@@ -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;