@pisell/pisellos 2.2.313 → 2.2.315
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/dist/modules/BookingContext/utils/productExtend.js +62 -18
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +14 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +856 -486
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +30 -2
- package/dist/modules/Order/utils.js +25 -7
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +332 -23
- package/dist/modules/ResourcePlanner/types.d.ts +29 -0
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1536 -1309
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +15 -0
- package/dist/server/modules/order/index.js +920 -688
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/test.json +1 -1
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +96 -0
- package/dist/shared/receipt/small-ticket.js +2751 -0
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +39 -16
- package/dist/solution/BaseSales/index.js +1754 -1154
- package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/dist/solution/BaseSales/pickupTiming.js +616 -0
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/BookingTicket/index.d.ts +8 -2
- package/dist/solution/BookingTicket/index.js +513 -436
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/dist/solution/OrderInvoicePreview/index.js +340 -0
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/dist/solution/UnifiedBookingSales/index.js +1714 -905
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/lib/modules/BookingContext/utils/productExtend.js +45 -2
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +14 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +240 -38
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +30 -2
- package/lib/modules/Order/utils.js +21 -5
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +252 -8
- package/lib/modules/ResourcePlanner/types.d.ts +29 -0
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +158 -37
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +15 -0
- package/lib/server/modules/order/index.js +114 -3
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/test.json +1 -1
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +96 -0
- package/lib/shared/receipt/small-ticket.js +2546 -0
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +39 -16
- package/lib/solution/BaseSales/index.js +333 -31
- package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/lib/solution/BaseSales/pickupTiming.js +290 -0
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/BookingTicket/index.d.ts +8 -2
- package/lib/solution/BookingTicket/index.js +65 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/lib/solution/OrderInvoicePreview/index.js +246 -0
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/lib/solution/UnifiedBookingSales/index.js +561 -74
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestPlugin } from '../../plugins/request';
|
|
2
|
+
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
3
|
+
/** Shared read-only transport; customer hosts route the remote path under /h5. */
|
|
4
|
+
export declare function loadPaymentMethods(request: RequestPlugin, options: {
|
|
5
|
+
transport: 'remote' | 'os-server';
|
|
6
|
+
filterPaymentMethods: boolean;
|
|
7
|
+
}): Promise<PaymentMethod[]>;
|
|
8
|
+
/** Enrich a copy: never overwrite historical names or change payment amounts. */
|
|
9
|
+
export declare function withPaymentMethodNames(order: Record<string, any>, methods: PaymentMethod[]): Record<string, any>;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 _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
|
+
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
|
+
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 _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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
/** Shared read-only transport; customer hosts route the remote path under /h5. */
|
|
11
|
+
export function loadPaymentMethods(_x, _x2) {
|
|
12
|
+
return _loadPaymentMethods.apply(this, arguments);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Enrich a copy: never overwrite historical names or change payment amounts. */
|
|
16
|
+
function _loadPaymentMethods() {
|
|
17
|
+
_loadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request, options) {
|
|
18
|
+
var _response$data;
|
|
19
|
+
var response, methods;
|
|
20
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
_context.next = 2;
|
|
24
|
+
return request.get('/pay/custom-payment/all', {
|
|
25
|
+
filterPaymentMethods: options.filterPaymentMethods
|
|
26
|
+
}, options.transport === 'os-server' ? {
|
|
27
|
+
osServer: true
|
|
28
|
+
} : {
|
|
29
|
+
manualErrorHandling: true,
|
|
30
|
+
skipErrorHandler: true
|
|
31
|
+
});
|
|
32
|
+
case 2:
|
|
33
|
+
response = _context.sent;
|
|
34
|
+
methods = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
|
|
35
|
+
if (Array.isArray(methods)) {
|
|
36
|
+
_context.next = 6;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
throw new Error('Payment methods are unavailable');
|
|
40
|
+
case 6:
|
|
41
|
+
return _context.abrupt("return", methods);
|
|
42
|
+
case 7:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return _loadPaymentMethods.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
export function withPaymentMethodNames(order, methods) {
|
|
51
|
+
if (!Array.isArray(order.payments)) return order;
|
|
52
|
+
return _objectSpread(_objectSpread({}, order), {}, {
|
|
53
|
+
payments: order.payments.map(function (payment) {
|
|
54
|
+
if (payment.name || payment.title || payment.payment_method_name || payment.method_name) return payment;
|
|
55
|
+
var id = payment.custom_payment_id;
|
|
56
|
+
var hasId = id !== undefined && id !== null && String(id).trim() !== '';
|
|
57
|
+
var code = payment.code || payment.type || payment.payment_method || payment.method;
|
|
58
|
+
var method = methods.find(function (candidate) {
|
|
59
|
+
return hasId ? String(candidate.id) === String(id) : !!code && candidate.code === code;
|
|
60
|
+
});
|
|
61
|
+
return method !== null && method !== void 0 && method.name ? _objectSpread(_objectSpread({}, payment), {}, {
|
|
62
|
+
payment_method_name: method.name
|
|
63
|
+
}) : payment;
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CustomerInvoiceLanguageCode = 'en' | 'zh_CN' | 'zh_HK' | 'ja' | 'pt' | 'cn_en';
|
|
2
|
+
export interface CustomerInvoiceLanguageOption {
|
|
3
|
+
code: CustomerInvoiceLanguageCode;
|
|
4
|
+
locales: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizeCustomerInvoiceLanguage(value: string): CustomerInvoiceLanguageCode | undefined;
|
|
7
|
+
/** Preserve configured insertion order; a print count never repeats an option. */
|
|
8
|
+
export declare function resolveCustomerInvoiceLanguages(language: Record<string, unknown>, pageLocale: string): CustomerInvoiceLanguageOption[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
var aliases = {
|
|
8
|
+
en: 'en',
|
|
9
|
+
en_us: 'en',
|
|
10
|
+
en_gb: 'en',
|
|
11
|
+
en_au: 'en',
|
|
12
|
+
cn: 'zh_CN',
|
|
13
|
+
zh: 'zh_CN',
|
|
14
|
+
zh_cn: 'zh_CN',
|
|
15
|
+
zh_hans: 'zh_CN',
|
|
16
|
+
zh_sg: 'zh_CN',
|
|
17
|
+
hk: 'zh_HK',
|
|
18
|
+
zh_hk: 'zh_HK',
|
|
19
|
+
zh_tw: 'zh_HK',
|
|
20
|
+
zh_hant: 'zh_HK',
|
|
21
|
+
ja: 'ja',
|
|
22
|
+
ja_jp: 'ja',
|
|
23
|
+
jp: 'ja',
|
|
24
|
+
pt: 'pt',
|
|
25
|
+
pt_br: 'pt',
|
|
26
|
+
pt_pt: 'pt',
|
|
27
|
+
cn_en: 'cn_en',
|
|
28
|
+
en_cn: 'cn_en'
|
|
29
|
+
};
|
|
30
|
+
export function normalizeCustomerInvoiceLanguage(value) {
|
|
31
|
+
return aliases[value.trim().toLowerCase().replace(/-/g, '_')];
|
|
32
|
+
}
|
|
33
|
+
function option(code) {
|
|
34
|
+
return {
|
|
35
|
+
code: code,
|
|
36
|
+
locales: code === 'cn_en' ? ['en', 'zh_CN'] : [code]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Preserve configured insertion order; a print count never repeats an option. */
|
|
41
|
+
export function resolveCustomerInvoiceLanguages(language, pageLocale) {
|
|
42
|
+
var options = [];
|
|
43
|
+
var seen = new Set();
|
|
44
|
+
Object.entries(language).forEach(function (_ref) {
|
|
45
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
46
|
+
key = _ref2[0],
|
|
47
|
+
count = _ref2[1];
|
|
48
|
+
if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) return;
|
|
49
|
+
var code = normalizeCustomerInvoiceLanguage(key);
|
|
50
|
+
if (!code || seen.has(code)) return;
|
|
51
|
+
seen.add(code);
|
|
52
|
+
options.push(option(code));
|
|
53
|
+
});
|
|
54
|
+
if (options.length) return options;
|
|
55
|
+
var normalized = normalizeCustomerInvoiceLanguage(pageLocale);
|
|
56
|
+
// A page locale is a single language, never a bilingual printer mode.
|
|
57
|
+
var requested = pageLocale.toLowerCase().replace(/_/g, '-');
|
|
58
|
+
var fallback = normalized && normalized !== 'cn_en' ? normalized : requested.startsWith('zh-tw') || requested.startsWith('zh-hk') ? 'zh_HK' : requested.startsWith('zh') ? 'zh_CN' : requested.startsWith('ja') ? 'ja' : requested.startsWith('pt') ? 'pt' : 'en';
|
|
59
|
+
return [option(fallback)];
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RequestPlugin } from '../../plugins/request';
|
|
2
|
+
import { type InvoiceLayoutConfig } from '../../modules/OpenData';
|
|
3
|
+
export interface PublicInvoiceDocumentResponse {
|
|
4
|
+
status: boolean;
|
|
5
|
+
code: number;
|
|
6
|
+
message?: string;
|
|
7
|
+
data: {
|
|
8
|
+
id: number;
|
|
9
|
+
data?: {
|
|
10
|
+
template_settings?: unknown;
|
|
11
|
+
} | null;
|
|
12
|
+
} | null;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomerInvoiceTemplate {
|
|
15
|
+
layout: InvoiceLayoutConfig;
|
|
16
|
+
language: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
interface TemplateScope {
|
|
19
|
+
tenantId: string | number;
|
|
20
|
+
shopId: string | number;
|
|
21
|
+
identity: string;
|
|
22
|
+
businessCode: string;
|
|
23
|
+
channel: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function loadCustomerInvoiceTemplate(request: RequestPlugin, scope: TemplateScope): Promise<CustomerInvoiceTemplate>;
|
|
26
|
+
export declare function loadCustomerInvoiceLayout(request: RequestPlugin, scope: TemplateScope): Promise<InvoiceLayoutConfig>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
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); }
|
|
10
|
+
import { getDefaultInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
11
|
+
// Page-runtime caches: also retain DEFAULT on failure, without automatic retries.
|
|
12
|
+
var caches = new WeakMap();
|
|
13
|
+
var isRecord = function isRecord(value) {
|
|
14
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
15
|
+
};
|
|
16
|
+
function documentId(value) {
|
|
17
|
+
if (typeof value !== 'string' && typeof value !== 'number') return null;
|
|
18
|
+
var text = String(value).trim();
|
|
19
|
+
if (!/^\d+$/.test(text)) return null;
|
|
20
|
+
var id = Number(text);
|
|
21
|
+
return Number.isSafeInteger(id) && id > 0 ? String(id) : null;
|
|
22
|
+
}
|
|
23
|
+
export function loadCustomerInvoiceTemplate(request, scope) {
|
|
24
|
+
var cache = caches.get(request);
|
|
25
|
+
if (!cache) {
|
|
26
|
+
cache = {
|
|
27
|
+
scopes: new Map(),
|
|
28
|
+
documents: new Map()
|
|
29
|
+
};
|
|
30
|
+
caches.set(request, cache);
|
|
31
|
+
}
|
|
32
|
+
var target = "".concat(scope.businessCode, "+").concat(scope.channel);
|
|
33
|
+
var key = JSON.stringify([scope.tenantId, scope.shopId, scope.identity, scope.businessCode, scope.channel]);
|
|
34
|
+
var cached = cache.scopes.get(key);
|
|
35
|
+
if (cached) return cached;
|
|
36
|
+
var id = null;
|
|
37
|
+
var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
38
|
+
var response, config, raw, numericLike, docKey, pending, expectedId;
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
40
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
_context2.next = 2;
|
|
43
|
+
return request.post("/open/my-pisell/".concat(encodeURIComponent(String(scope.shopId)), "/setting"), {
|
|
44
|
+
scope: 'board',
|
|
45
|
+
target: target,
|
|
46
|
+
section_code: ['documents']
|
|
47
|
+
}, {
|
|
48
|
+
pisell2: true,
|
|
49
|
+
prefix: false,
|
|
50
|
+
headers: scope.tenantId ? {
|
|
51
|
+
'Tenant-Id': String(scope.tenantId)
|
|
52
|
+
} : {},
|
|
53
|
+
manualErrorHandling: true,
|
|
54
|
+
skipErrorHandler: true,
|
|
55
|
+
timeout: 15000
|
|
56
|
+
});
|
|
57
|
+
case 2:
|
|
58
|
+
response = _context2.sent;
|
|
59
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) !== true || response.code !== 200 || !isRecord(response.data))) {
|
|
60
|
+
_context2.next = 5;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Invoice OpenData is unavailable');
|
|
64
|
+
case 5:
|
|
65
|
+
config = response.data;
|
|
66
|
+
raw = config['documents.invoice_template'];
|
|
67
|
+
id = documentId(raw);
|
|
68
|
+
if (id) {
|
|
69
|
+
_context2.next = 11;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
// Preserve the existing non-numeric legacy template / invoice_edit contract.
|
|
73
|
+
numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
74
|
+
return _context2.abrupt("return", typeof raw === 'string' && raw.trim() && !numericLike.test(raw.trim()) ? {
|
|
75
|
+
layout: normalizeInvoiceLayoutFromTemplateSettings(normalizeInvoiceTemplateSettings(config)),
|
|
76
|
+
language: readLanguage(config['documents.invoice_edit'])
|
|
77
|
+
} : defaultTemplate());
|
|
78
|
+
case 11:
|
|
79
|
+
docKey = JSON.stringify([key, id]);
|
|
80
|
+
pending = cache.documents.get(docKey);
|
|
81
|
+
if (!pending) {
|
|
82
|
+
expectedId = id;
|
|
83
|
+
pending = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
84
|
+
var result, doc, settings;
|
|
85
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
86
|
+
while (1) switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
_context.next = 2;
|
|
89
|
+
return request.get("/open/document/".concat(expectedId), {}, {
|
|
90
|
+
publicInvoiceDocument: true
|
|
91
|
+
});
|
|
92
|
+
case 2:
|
|
93
|
+
result = _context.sent;
|
|
94
|
+
if (!((result === null || result === void 0 ? void 0 : result.status) !== true || result.code !== 200)) {
|
|
95
|
+
_context.next = 5;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
throw new Error((result === null || result === void 0 ? void 0 : result.message) || 'Invoice Document request failed');
|
|
99
|
+
case 5:
|
|
100
|
+
doc = result.data;
|
|
101
|
+
if (!(!doc || documentId(doc.id) !== expectedId)) {
|
|
102
|
+
_context.next = 8;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
throw new Error('Invoice Document is unavailable or its ID does not match');
|
|
106
|
+
case 8:
|
|
107
|
+
if (!(!isRecord(doc.data) || !isRecord(doc.data.template_settings))) {
|
|
108
|
+
_context.next = 10;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
throw new Error('Invoice Document has no template_settings');
|
|
112
|
+
case 10:
|
|
113
|
+
settings = normalizeRawInvoiceTemplateSettings(doc.data.template_settings);
|
|
114
|
+
if (!(settings.modules.length === 0)) {
|
|
115
|
+
_context.next = 13;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
throw new Error('Invoice Document has no usable template modules');
|
|
119
|
+
case 13:
|
|
120
|
+
return _context.abrupt("return", {
|
|
121
|
+
layout: normalizeInvoiceLayoutFromTemplateSettings(settings),
|
|
122
|
+
language: readLanguage(doc.data.template_settings)
|
|
123
|
+
});
|
|
124
|
+
case 14:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee);
|
|
129
|
+
}))().catch(function (error) {
|
|
130
|
+
return fallback(error, target, expectedId);
|
|
131
|
+
});
|
|
132
|
+
cache.documents.set(docKey, pending);
|
|
133
|
+
}
|
|
134
|
+
return _context2.abrupt("return", pending);
|
|
135
|
+
case 15:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context2.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee2);
|
|
140
|
+
}))().catch(function (error) {
|
|
141
|
+
return fallback(error, target, id);
|
|
142
|
+
});
|
|
143
|
+
cache.scopes.set(key, task);
|
|
144
|
+
return task;
|
|
145
|
+
}
|
|
146
|
+
function fallback(error, target, id) {
|
|
147
|
+
console.warn('[OrderInvoicePreview] Template unavailable; using DEFAULT', {
|
|
148
|
+
target: target,
|
|
149
|
+
documentId: id,
|
|
150
|
+
message: error instanceof Error ? error.message : 'Template request failed'
|
|
151
|
+
});
|
|
152
|
+
return defaultTemplate();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Keep the existing layout-only API and its in-flight promise identity intact.
|
|
156
|
+
var layoutPromises = new WeakMap();
|
|
157
|
+
export function loadCustomerInvoiceLayout(request, scope) {
|
|
158
|
+
var template = loadCustomerInvoiceTemplate(request, scope);
|
|
159
|
+
var layout = layoutPromises.get(template);
|
|
160
|
+
if (!layout) {
|
|
161
|
+
layout = template.then(function (value) {
|
|
162
|
+
return value.layout;
|
|
163
|
+
});
|
|
164
|
+
layoutPromises.set(template, layout);
|
|
165
|
+
}
|
|
166
|
+
return layout;
|
|
167
|
+
}
|
|
168
|
+
function defaultTemplate() {
|
|
169
|
+
return {
|
|
170
|
+
layout: getDefaultInvoiceLayoutConfig(),
|
|
171
|
+
language: {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function readLanguage(value) {
|
|
175
|
+
var settings = value;
|
|
176
|
+
if (typeof settings === 'string') {
|
|
177
|
+
try {
|
|
178
|
+
settings = JSON.parse(settings);
|
|
179
|
+
} catch (_unused) {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return isRecord(settings) && isRecord(settings.language) ? _objectSpread({}, settings.language) : {};
|
|
184
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface SmallTicketShopInfo {
|
|
2
|
+
name?: string;
|
|
3
|
+
phone?: string;
|
|
4
|
+
address?: string;
|
|
5
|
+
address_street?: string;
|
|
6
|
+
address_detail?: string;
|
|
7
|
+
city?: string;
|
|
8
|
+
province?: string;
|
|
9
|
+
country?: string;
|
|
10
|
+
zip?: string;
|
|
11
|
+
tax_number?: string;
|
|
12
|
+
tax_title?: string;
|
|
13
|
+
is_price_include_tax?: 0 | 1 | boolean;
|
|
14
|
+
currency_symbol?: string;
|
|
15
|
+
currency_code?: string;
|
|
16
|
+
primary_locale?: string;
|
|
17
|
+
timezone?: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export interface BuildSmallTicketDataParams {
|
|
21
|
+
order: Record<string, any>;
|
|
22
|
+
shopInfo?: SmallTicketShopInfo | null;
|
|
23
|
+
locales?: string[];
|
|
24
|
+
productMap?: Record<string | number, Record<string, any>>;
|
|
25
|
+
/** Resolved template settings or layout; omitted settings preserve native compatibility. */
|
|
26
|
+
templateSettings?: unknown;
|
|
27
|
+
/** Customer preview only: stable source identities for bilingual rows. */
|
|
28
|
+
includeReceiptKeys?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface SmallTicketItem {
|
|
31
|
+
receipt_key?: string;
|
|
32
|
+
receipt_value_kind?: 'shared' | 'text';
|
|
33
|
+
receipt_item_kind?: 'shared';
|
|
34
|
+
item: string;
|
|
35
|
+
value: string;
|
|
36
|
+
size?: number;
|
|
37
|
+
align?: string;
|
|
38
|
+
product_uid?: string | number;
|
|
39
|
+
booking_uid?: string | number;
|
|
40
|
+
}
|
|
41
|
+
export interface SmallTicketProduct {
|
|
42
|
+
receipt_key?: string;
|
|
43
|
+
receipt_source_index?: number;
|
|
44
|
+
product_title: string;
|
|
45
|
+
product_quantity: number;
|
|
46
|
+
selling_price: string;
|
|
47
|
+
total_selling_price: string;
|
|
48
|
+
original_price: string;
|
|
49
|
+
base_price?: string;
|
|
50
|
+
total_original_price: string;
|
|
51
|
+
options_total_price?: string;
|
|
52
|
+
package_items_total_price?: string;
|
|
53
|
+
extension_list: any[];
|
|
54
|
+
product_uid?: string | number;
|
|
55
|
+
booking_uid?: string | number;
|
|
56
|
+
product_note?: string;
|
|
57
|
+
allergy?: string;
|
|
58
|
+
options?: Array<{
|
|
59
|
+
receipt_key?: string;
|
|
60
|
+
receipt_source_index?: number;
|
|
61
|
+
name: string;
|
|
62
|
+
num?: number;
|
|
63
|
+
price?: string;
|
|
64
|
+
total_price: string;
|
|
65
|
+
value?: string;
|
|
66
|
+
}>;
|
|
67
|
+
variant?: string;
|
|
68
|
+
combinations?: any[];
|
|
69
|
+
}
|
|
70
|
+
export type SmallTicketAppointment = SmallTicketItem[];
|
|
71
|
+
export interface SmallTicketLocaleData {
|
|
72
|
+
base_data: Record<string, any>;
|
|
73
|
+
products: SmallTicketProduct[];
|
|
74
|
+
fees: {
|
|
75
|
+
fees: SmallTicketItem[];
|
|
76
|
+
countFee: Record<string, any>;
|
|
77
|
+
};
|
|
78
|
+
customer: SmallTicketItem[];
|
|
79
|
+
appointment: SmallTicketAppointment;
|
|
80
|
+
delivery?: SmallTicketItem[];
|
|
81
|
+
resources: Array<{
|
|
82
|
+
id: string | number;
|
|
83
|
+
code: string;
|
|
84
|
+
title: string;
|
|
85
|
+
form_title: string;
|
|
86
|
+
}>;
|
|
87
|
+
payment_data: SmallTicketItem[][];
|
|
88
|
+
wallets: SmallTicketItem[][];
|
|
89
|
+
tickets: any[];
|
|
90
|
+
source_shop: any[];
|
|
91
|
+
refund_data: SmallTicketItem[][];
|
|
92
|
+
expend_data: any[];
|
|
93
|
+
}
|
|
94
|
+
export type SmallTicketData = Record<string, SmallTicketLocaleData>;
|
|
95
|
+
export declare function buildSmallTicketData(params: BuildSmallTicketDataParams): SmallTicketData;
|
|
96
|
+
export declare function hasSmallTicketData(value: any): boolean;
|