@pisell/pisellos 2.3.231 → 2.3.233

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 (46) hide show
  1. package/dist/modules/Customer/types.d.ts +4 -0
  2. package/dist/modules/Order/index.d.ts +10 -1
  3. package/dist/modules/Order/index.js +1350 -1133
  4. package/dist/modules/Order/types.d.ts +3 -0
  5. package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
  6. package/dist/modules/Order/utils/bookingUuid.js +24 -0
  7. package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
  8. package/dist/modules/Order/utils/virtualSettlement.js +13 -0
  9. package/dist/modules/Order/utils.js +11 -6
  10. package/dist/modules/Product/index.d.ts +1 -1
  11. package/dist/shared/payment/loadPaymentMethods.d.ts +4 -1
  12. package/dist/shared/payment/loadPaymentMethods.js +35 -2
  13. package/dist/solution/BaseSales/index.d.ts +1 -0
  14. package/dist/solution/BaseSales/index.js +516 -423
  15. package/dist/solution/BookingByStep/index.d.ts +2 -2
  16. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +14 -13
  17. package/dist/solution/Checkout/index.js +104 -69
  18. package/dist/solution/Checkout/types.d.ts +1 -0
  19. package/dist/solution/ScanOrder/index.js +10 -2
  20. package/dist/solution/VenueBooking/index.js +522 -490
  21. package/dist/utils/platform.d.ts +1 -0
  22. package/dist/utils/platform.js +4 -0
  23. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  24. package/lib/modules/Customer/types.d.ts +4 -0
  25. package/lib/modules/Order/index.d.ts +10 -1
  26. package/lib/modules/Order/index.js +141 -20
  27. package/lib/modules/Order/types.d.ts +3 -0
  28. package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
  29. package/lib/modules/Order/utils/bookingUuid.js +25 -0
  30. package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
  31. package/lib/modules/Order/utils/virtualSettlement.js +9 -1
  32. package/lib/modules/Order/utils.js +13 -5
  33. package/lib/modules/Product/index.d.ts +1 -1
  34. package/lib/shared/payment/loadPaymentMethods.d.ts +4 -1
  35. package/lib/shared/payment/loadPaymentMethods.js +13 -0
  36. package/lib/solution/BaseSales/index.d.ts +1 -0
  37. package/lib/solution/BaseSales/index.js +49 -10
  38. package/lib/solution/BookingByStep/index.d.ts +2 -2
  39. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +14 -13
  40. package/lib/solution/Checkout/index.js +21 -0
  41. package/lib/solution/Checkout/types.d.ts +1 -0
  42. package/lib/solution/ScanOrder/index.js +6 -0
  43. package/lib/solution/VenueBooking/index.js +6 -1
  44. package/lib/utils/platform.d.ts +1 -0
  45. package/lib/utils/platform.js +5 -0
  46. package/package.json +1 -1
@@ -419,6 +419,7 @@ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'p
419
419
  products: OrderSubmitProduct[];
420
420
  notes?: SalesNoteProtocol[];
421
421
  summary?: OrderSummary;
422
+ product_tax_fee?: string;
422
423
  small_ticket_data_flag?: number;
423
424
  }
424
425
  export interface OrderState {
@@ -596,6 +597,8 @@ export interface CommitOrderParams {
596
597
  };
597
598
  }
598
599
  export interface OrderSubmitBooking {
600
+ /** Stable booking identity, created once and shared with external allocations. */
601
+ uuid?: string | null;
599
602
  relation_id?: string;
600
603
  form_id?: string;
601
604
  collect_pax?: number;
@@ -0,0 +1,4 @@
1
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
2
+ export declare function ensureBookingUuid<T extends Record<string, any>>(booking: T): T;
3
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
4
+ export declare function assignBookingUuid(booking: Record<string, any> | null | undefined): void;
@@ -0,0 +1,24 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { createUuidV4 } from "./orderCollectionIdentity";
8
+
9
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
10
+ export function ensureBookingUuid(booking) {
11
+ if (booking.uuid) return booking;
12
+ // Only an explicit null confirms that an existing booking needs a UUID when saved.
13
+ if (booking.uuid !== null && Number(booking.schedule_event_id || booking.id) > 0) return booking;
14
+ return _objectSpread(_objectSpread({}, booking), {}, {
15
+ uuid: createUuidV4()
16
+ });
17
+ }
18
+
19
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
20
+ export function assignBookingUuid(booking) {
21
+ if (!booking) return;
22
+ var resolved = ensureBookingUuid(booking);
23
+ if (resolved !== booking) booking.uuid = resolved.uuid;
24
+ }
@@ -36,6 +36,10 @@ export declare class VirtualCurrencyBalanceError extends Error {
36
36
  readonly code = "VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT";
37
37
  constructor(balance: string, requiredAmount: string);
38
38
  }
39
+ export declare class VirtualCurrencyCustomerRequiredError extends Error {
40
+ readonly code = "VIRTUAL_CURRENCY_CUSTOMER_REQUIRED";
41
+ constructor();
42
+ }
39
43
  export declare function getSelectedSettlementSnapshot(product: Partial<OrderProduct> | null | undefined): SelectedSettlementSnapshot | null;
40
44
  export declare function getTempOrderSettlementSnapshot(tempOrder: OrderTempOrder | null | undefined): SelectedSettlementSnapshot | null;
41
45
  export declare function isVirtualSettlementProduct(product: Partial<OrderProduct> | null | undefined): boolean;
@@ -80,6 +80,19 @@ export var VirtualCurrencyBalanceError = /*#__PURE__*/function (_Error3) {
80
80
  }
81
81
  return _createClass(VirtualCurrencyBalanceError);
82
82
  }( /*#__PURE__*/_wrapNativeSuper(Error));
83
+ export var VirtualCurrencyCustomerRequiredError = /*#__PURE__*/function (_Error4) {
84
+ _inherits(VirtualCurrencyCustomerRequiredError, _Error4);
85
+ var _super4 = _createSuper(VirtualCurrencyCustomerRequiredError);
86
+ function VirtualCurrencyCustomerRequiredError() {
87
+ var _this4;
88
+ _classCallCheck(this, VirtualCurrencyCustomerRequiredError);
89
+ _this4 = _super4.call(this, 'Select a customer before paying with virtual currency.');
90
+ _defineProperty(_assertThisInitialized(_this4), "code", 'VIRTUAL_CURRENCY_CUSTOMER_REQUIRED');
91
+ _this4.name = 'VirtualCurrencyCustomerRequiredError';
92
+ return _this4;
93
+ }
94
+ return _createClass(VirtualCurrencyCustomerRequiredError);
95
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
83
96
  export function getSelectedSettlementSnapshot(product) {
84
97
  var _product$metadata;
85
98
  var snapshot = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.selected_settlement_snapshot;
@@ -29,8 +29,10 @@ import Decimal from 'decimal.js';
29
29
  import { withOriginalBundleOptionPrices } from "./utils/weighedProduct";
30
30
  import { hasManualProductDiscountFlag } from "./utils/manualProductDiscount";
31
31
  import { getProductHolderConfig } from "../Holder/utils";
32
+ import { isPosTerminalPlatform } from "../../utils/platform";
32
33
  import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
33
34
  import { createUuidV4 } from "./utils/orderCollectionIdentity";
35
+ import { assignBookingUuid } from "./utils/bookingUuid";
34
36
  import { encodeSalesNotes } from "./salesNotes";
35
37
  import { isFulfillmentTimingBooking } from "./pickupTiming";
36
38
  import { ensureHolderRelationUuids, getProductHolderRelations, hasProductBooking, removeProductHolderRelations } from "./holderRelations";
@@ -1581,7 +1583,7 @@ export function resolveSubmitOrderType(params) {
1581
1583
  return 'virtual';
1582
1584
  }
1583
1585
  export function buildSubmitPayload(params) {
1584
- var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref44, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
1586
+ var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref44, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhance, _enhancedPayload$summ, _submitSummary$tax_fe;
1585
1587
  var tempOrder = params.tempOrder,
1586
1588
  cacheId = params.cacheId,
1587
1589
  _params$now = params.now,
@@ -1664,6 +1666,7 @@ export function buildSubmitPayload(params) {
1664
1666
  bookings: (tempOrder.bookings || []).filter(function (booking) {
1665
1667
  return isFulfillmentTimingBooking(booking) || Number(booking.parent_id) !== 0;
1666
1668
  }).map(function (booking) {
1669
+ assignBookingUuid(booking);
1667
1670
  return normalizeSubmitBooking(booking);
1668
1671
  }),
1669
1672
  payments: tempOrder.payments || [],
@@ -1695,15 +1698,17 @@ export function buildSubmitPayload(params) {
1695
1698
  }, normalizedOrderMetaList !== undefined ? {
1696
1699
  order_meta_list: normalizedOrderMetaList
1697
1700
  } : {});
1698
- if (!enhance) return payload;
1699
- var enhancedPayload = enhance(payload, {
1701
+ var enhancedPayload = (_enhance = enhance === null || enhance === void 0 ? void 0 : enhance(payload, {
1700
1702
  tempOrder: tempOrder,
1701
1703
  bookingUuid: bookingUuid,
1702
1704
  now: now
1703
- });
1705
+ })) !== null && _enhance !== void 0 ? _enhance : payload;
1706
+ var submitSummary = (_enhancedPayload$summ = enhancedPayload.summary) !== null && _enhancedPayload$summ !== void 0 ? _enhancedPayload$summ : payload.summary;
1704
1707
  return _objectSpread(_objectSpread({}, enhancedPayload), {}, {
1705
- summary: (_enhancedPayload$summ = enhancedPayload.summary) !== null && _enhancedPayload$summ !== void 0 ? _enhancedPayload$summ : payload.summary
1706
- });
1708
+ summary: submitSummary
1709
+ }, isPosTerminalPlatform(enhancedPayload.platform) ? {
1710
+ product_tax_fee: virtualSettlementMode ? '0.00' : (_submitSummary$tax_fe = submitSummary === null || submitSummary === void 0 ? void 0 : submitSummary.tax_fee) !== null && _submitSummary$tax_fe !== void 0 ? _submitSummary$tax_fe : '0.00'
1711
+ } : {});
1707
1712
  }
1708
1713
  export function mapPaymentItemToOrderPayment(paymentItem) {
1709
1714
  var _item$custom_payment_, _item$payment_time, _item$created_at, _item$amount;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "normal" | "session";
53
53
  }
@@ -1,9 +1,12 @@
1
1
  import type { RequestPlugin } from '../../plugins/request';
2
2
  import type { PaymentMethod } from '../../modules/Payment/types';
3
+ type PaymentMethodsTransport = 'remote' | 'os-server';
3
4
  /** Shared read-only transport; customer hosts route the remote path under /h5. */
4
5
  export declare function loadPaymentMethods(request: RequestPlugin, options: {
5
- transport: 'remote' | 'os-server';
6
+ transport: PaymentMethodsTransport;
6
7
  filterPaymentMethods: boolean;
7
8
  }): Promise<PaymentMethod[]>;
9
+ export declare function requirePosVirtualCurrencyPaymentMethod(methods: readonly PaymentMethod[], shopId?: string): PaymentMethod;
8
10
  /** Enrich a copy: never overwrite historical names or change payment amounts. */
9
11
  export declare function withPaymentMethodNames(order: Record<string, any>, methods: PaymentMethod[]): Record<string, any>;
12
+ export {};
@@ -2,6 +2,19 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
11
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
13
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
14
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
+ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
16
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
5
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
20
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -11,8 +24,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
11
24
  export function loadPaymentMethods(_x, _x2) {
12
25
  return _loadPaymentMethods.apply(this, arguments);
13
26
  }
14
-
15
- /** Enrich a copy: never overwrite historical names or change payment amounts. */
16
27
  function _loadPaymentMethods() {
17
28
  _loadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request, options) {
18
29
  var _response$data;
@@ -47,6 +58,28 @@ function _loadPaymentMethods() {
47
58
  }));
48
59
  return _loadPaymentMethods.apply(this, arguments);
49
60
  }
61
+ var PosVirtualCurrencyPaymentUnavailableError = /*#__PURE__*/function (_Error) {
62
+ _inherits(PosVirtualCurrencyPaymentUnavailableError, _Error);
63
+ var _super = _createSuper(PosVirtualCurrencyPaymentUnavailableError);
64
+ function PosVirtualCurrencyPaymentUnavailableError() {
65
+ var _this;
66
+ _classCallCheck(this, PosVirtualCurrencyPaymentUnavailableError);
67
+ _this = _super.call(this, 'Virtual currency payment is not enabled on this POS.');
68
+ _defineProperty(_assertThisInitialized(_this), "code", 'POS_VIRTUAL_CURRENCY_PAYMENT_UNAVAILABLE');
69
+ _this.name = 'PosVirtualCurrencyPaymentUnavailableError';
70
+ return _this;
71
+ }
72
+ return _createClass(PosVirtualCurrencyPaymentUnavailableError);
73
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
74
+ export function requirePosVirtualCurrencyPaymentMethod(methods, shopId) {
75
+ var method = methods.find(function (candidate) {
76
+ return (candidate === null || candidate === void 0 ? void 0 : candidate.code) === 'VIRTUALCURRENCY' && (!shopId || candidate.shop_id == null || String(candidate.shop_id) === shopId) && candidate.status === 1 && candidate.disable === 0 && Array.isArray(candidate.channel_application) && candidate.channel_application.includes('pos');
77
+ });
78
+ if (!method) throw new PosVirtualCurrencyPaymentUnavailableError();
79
+ return method;
80
+ }
81
+
82
+ /** Enrich a copy: never overwrite historical names or change payment amounts. */
50
83
  export function withPaymentMethodNames(order, methods) {
51
84
  if (!Array.isArray(order.payments)) return order;
52
85
  return _objectSpread(_objectSpread({}, order), {}, {
@@ -503,6 +503,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
503
503
  getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
504
504
  /** 同步读取初始化时缓存的支付方式列表。 */
505
505
  getPaymentMethods(): PaymentMethod[];
506
+ hasPosVirtualCurrencyPaymentMethod(): Promise<boolean>;
506
507
  private findCashPaymentMethod;
507
508
  private getPendingWalletPaymentAmount;
508
509
  /** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */