@pisell/pisellos 2.3.184 → 2.3.186

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 (78) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  6. package/dist/modules/Discount/index.js +1 -0
  7. package/dist/modules/Order/index.d.ts +25 -3
  8. package/dist/modules/Order/index.js +1770 -1311
  9. package/dist/modules/Order/types.d.ts +7 -0
  10. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  11. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  12. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  13. package/dist/modules/Order/utils.js +12 -1
  14. package/dist/modules/Product/index.d.ts +1 -1
  15. package/dist/modules/Product/types.d.ts +5 -0
  16. package/dist/modules/ProductList/index.js +33 -12
  17. package/dist/modules/Rules/index.d.ts +2 -0
  18. package/dist/modules/Rules/index.js +29 -21
  19. package/dist/solution/BaseSales/index.d.ts +18 -1
  20. package/dist/solution/BaseSales/index.js +1762 -1434
  21. package/dist/solution/BaseSales/types.d.ts +3 -0
  22. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  23. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  24. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  25. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  26. package/dist/solution/BookingByStep/index.d.ts +2 -2
  27. package/dist/solution/BookingTicket/index.d.ts +13 -1
  28. package/dist/solution/BookingTicket/index.js +197 -108
  29. package/dist/solution/BookingTicket/types.d.ts +14 -2
  30. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  31. package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
  32. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  33. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
  34. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  35. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  36. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  37. package/dist/solution/UnifiedBookingSales/index.js +102 -64
  38. package/dist/utils/platform.d.ts +2 -0
  39. package/dist/utils/platform.js +6 -0
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +12 -0
  42. package/lib/inventory/index.d.ts +92 -0
  43. package/lib/inventory/index.js +287 -0
  44. package/lib/modules/Discount/index.js +1 -0
  45. package/lib/modules/Order/index.d.ts +25 -3
  46. package/lib/modules/Order/index.js +192 -38
  47. package/lib/modules/Order/types.d.ts +7 -0
  48. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  49. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  50. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  51. package/lib/modules/Order/utils.js +13 -0
  52. package/lib/modules/Product/index.d.ts +1 -1
  53. package/lib/modules/Product/types.d.ts +5 -0
  54. package/lib/modules/ProductList/index.js +15 -0
  55. package/lib/modules/Rules/index.d.ts +2 -0
  56. package/lib/modules/Rules/index.js +6 -0
  57. package/lib/solution/BaseSales/index.d.ts +18 -1
  58. package/lib/solution/BaseSales/index.js +214 -50
  59. package/lib/solution/BaseSales/types.d.ts +3 -0
  60. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  61. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  62. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  63. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  64. package/lib/solution/BookingByStep/index.d.ts +2 -2
  65. package/lib/solution/BookingTicket/index.d.ts +13 -1
  66. package/lib/solution/BookingTicket/index.js +37 -2
  67. package/lib/solution/BookingTicket/types.d.ts +14 -2
  68. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  69. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
  70. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  71. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
  72. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  73. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  74. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  75. package/lib/solution/UnifiedBookingSales/index.js +37 -4
  76. package/lib/utils/platform.d.ts +2 -0
  77. package/lib/utils/platform.js +7 -0
  78. package/package.json +1 -1
@@ -348,6 +348,9 @@ export interface BaseSalesProductBookingPriceResult {
348
348
  unit_price: string;
349
349
  total_price: string;
350
350
  quantity: number;
351
+ pricing_method?: {
352
+ type: 'fixed_price' | 'duration_based';
353
+ };
351
354
  duration?: BaseSalesQuotationDurationConfig;
352
355
  quotation_shelf_id: number;
353
356
  segments: BaseSalesProductBookingPriceSegment[];
@@ -0,0 +1,21 @@
1
+ import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesQuotationDurationConfig } from '../types';
2
+ export interface PosDurationPricingPlan {
3
+ duration: BaseSalesQuotationDurationConfig;
4
+ segments: Array<{
5
+ start: string;
6
+ end: string;
7
+ }>;
8
+ }
9
+ export declare function durationPricingUnavailable(message: string): Error & {
10
+ code: string;
11
+ };
12
+ export declare function hasDurationBasedPricing(product: Record<string, any> | null | undefined): boolean;
13
+ /** Days/Flexible retain their existing quotation behavior. */
14
+ export declare function usesPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
15
+ /** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
16
+ export declare function hasAppliedPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
17
+ export declare function buildPosDurationPricingPlan(params: BaseSalesCalculateProductBookingPriceParams, product: Record<string, any>): PosDurationPricingPlan;
18
+ /** Never use a previously accumulated order price as one unit's fallback. */
19
+ export declare function resolveDurationPricingProduct(product: Record<string, any>, selected: Record<string, any>): Record<string, any>;
20
+ export declare function combinePosDurationPrices(plan: PosDurationPricingPlan, prices: BaseSalesProductBookingPriceResult[]): BaseSalesProductBookingPriceResult;
21
+ export declare function forEachPriceQueryGroup<T>(groups: T[], resolve: (group: T) => Promise<void>, concurrency: number): Promise<void>;
@@ -0,0 +1,174 @@
1
+ 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; }
2
+ 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); }
3
+ 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); } }
4
+ 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); }); }; }
5
+ 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; }
6
+ 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; }
7
+ 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; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ 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); }
10
+ import dayjs from 'dayjs';
11
+ import Decimal from 'decimal.js';
12
+ export function durationPricingUnavailable(message) {
13
+ return Object.assign(new Error(message), {
14
+ code: 'DURATION_PRICING_UNAVAILABLE'
15
+ });
16
+ }
17
+ export function hasDurationBasedPricing(product) {
18
+ var _product$pricing_meth;
19
+ return (product === null || product === void 0 || (_product$pricing_meth = product.pricing_method) === null || _product$pricing_meth === void 0 ? void 0 : _product$pricing_meth.type) === 'duration_based';
20
+ }
21
+
22
+ /** Days/Flexible retain their existing quotation behavior. */
23
+ export function usesPosDurationPricing(product) {
24
+ var _product$duration;
25
+ var type = String((product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.type) || '').trim().toLowerCase();
26
+ return hasDurationBasedPricing(product) && !['day', 'days', 'flexible'].includes(type);
27
+ }
28
+
29
+ /** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
30
+ export function hasAppliedPosDurationPricing(product) {
31
+ var _product$_extend, _product$_extend2;
32
+ return usesPosDurationPricing(product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bookingPriceQuote) || usesPosDurationPricing(product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 || (_product$_extend2 = _product$_extend2.bookingPrice) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.quote) || usesPosDurationPricing(product === null || product === void 0 ? void 0 : product.metadata);
33
+ }
34
+ function bookingDateTime(date, time) {
35
+ var dateText = typeof date === 'string' ? date.trim() : '';
36
+ var timeText = typeof time === 'string' ? time.trim() : '';
37
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(dateText) || !/^\d{2}:\d{2}(?::\d{2})?$/.test(timeText)) {
38
+ throw durationPricingUnavailable('A valid booking start and end are required for duration pricing.');
39
+ }
40
+ var text = "".concat(dateText, " ").concat(timeText.length === 5 ? "".concat(timeText, ":00") : timeText);
41
+ var value = dayjs(text);
42
+ if (!value.isValid() || value.format('YYYY-MM-DD HH:mm:ss') !== text) {
43
+ throw durationPricingUnavailable('The booking time is invalid for duration pricing.');
44
+ }
45
+ return value;
46
+ }
47
+ export function buildPosDurationPricingPlan(params, product) {
48
+ var _product$duration2, _product$duration3, _params$booking, _params$booking2, _params$booking3, _params$booking4;
49
+ var type = String(((_product$duration2 = product.duration) === null || _product$duration2 === void 0 ? void 0 : _product$duration2.type) || '').trim().toLowerCase();
50
+ var value = Number((_product$duration3 = product.duration) === null || _product$duration3 === void 0 ? void 0 : _product$duration3.value);
51
+ var minutes = ['hour', 'hours'].includes(type) ? value * 60 : value;
52
+ if (!['minute', 'minutes', 'hour', 'hours'].includes(type) || !Number.isFinite(minutes) || minutes <= 0) {
53
+ throw durationPricingUnavailable('A positive fixed billing duration is required.');
54
+ }
55
+ var start = bookingDateTime((_params$booking = params.booking) === null || _params$booking === void 0 ? void 0 : _params$booking.start_date, (_params$booking2 = params.booking) === null || _params$booking2 === void 0 ? void 0 : _params$booking2.start_time);
56
+ var end = bookingDateTime((_params$booking3 = params.booking) === null || _params$booking3 === void 0 ? void 0 : _params$booking3.end_date, (_params$booking4 = params.booking) === null || _params$booking4 === void 0 ? void 0 : _params$booking4.end_time);
57
+ var count = end.diff(start) / (minutes * 60000);
58
+ if (!Number.isInteger(count) || count < 1 || count > 10000) {
59
+ throw durationPricingUnavailable('The booking duration must be a whole multiple of its billing duration.');
60
+ }
61
+ return {
62
+ duration: {
63
+ type: 'minutes',
64
+ value: minutes
65
+ },
66
+ segments: Array.from({
67
+ length: count
68
+ }, function (_, index) {
69
+ return {
70
+ start: start.add(index * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss'),
71
+ end: start.add((index + 1) * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss')
72
+ };
73
+ })
74
+ };
75
+ }
76
+
77
+ /** Never use a previously accumulated order price as one unit's fallback. */
78
+ export function resolveDurationPricingProduct(product, selected) {
79
+ var _ref, _selected$product_var, _ref2, _product$product_vari, _product$_dataVariant, _ref3, _ref4, _priceSource$price;
80
+ var variantId = Number((_ref = (_selected$product_var = selected.product_variant_id) !== null && _selected$product_var !== void 0 ? _selected$product_var : selected.variant_id) !== null && _ref !== void 0 ? _ref : 0);
81
+ var authoritativeVariantId = Number((_ref2 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref2 !== void 0 ? _ref2 : 0);
82
+ var variant = variantId > 0 && Array.isArray(product.variant) ? product.variant.find(function (item) {
83
+ return Number(item === null || item === void 0 ? void 0 : item.id) === variantId;
84
+ }) : undefined;
85
+ if (variantId > 0 && !variant && authoritativeVariantId !== variantId) {
86
+ throw durationPricingUnavailable('The selected SKU is missing from the authoritative price response.');
87
+ }
88
+ var appliedFields = (_product$_dataVariant = product._dataVariant) === null || _product$_dataVariant === void 0 ? void 0 : _product$_dataVariant.appliedFields;
89
+ var hasAppliedPrice = Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(function (field) {
90
+ return appliedFields.includes(field);
91
+ });
92
+ var priceSource = variantId > 0 && authoritativeVariantId !== variantId && !hasAppliedPrice ? variant : product;
93
+ var price = (_ref3 = (_ref4 = (_priceSource$price = priceSource === null || priceSource === void 0 ? void 0 : priceSource.price) !== null && _priceSource$price !== void 0 ? _priceSource$price : priceSource === null || priceSource === void 0 ? void 0 : priceSource.selling_price) !== null && _ref4 !== void 0 ? _ref4 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.base_price) !== null && _ref3 !== void 0 ? _ref3 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.original_price;
94
+ if (!(typeof price === 'number' || typeof price === 'string' && price.trim() !== '') || !Number.isFinite(Number(price)) || Number(price) < 0) {
95
+ throw durationPricingUnavailable('An authoritative price is required for every billing unit.');
96
+ }
97
+ return _objectSpread(_objectSpread({}, product), {}, {
98
+ price: price
99
+ });
100
+ }
101
+ export function combinePosDurationPrices(plan, prices) {
102
+ var _prices$find;
103
+ if (prices.length !== plan.segments.length || prices.length === 0) {
104
+ throw durationPricingUnavailable('The duration price is incomplete.');
105
+ }
106
+ var unitPrice = prices.reduce(function (sum, price) {
107
+ return sum.plus(price.unit_price);
108
+ }, new Decimal(0));
109
+ return _objectSpread(_objectSpread({}, prices[0]), {}, {
110
+ pricing_method: {
111
+ type: 'duration_based'
112
+ },
113
+ duration: plan.duration,
114
+ unit_price: unitPrice.toFixed(2),
115
+ total_price: unitPrice.times(prices[0].quantity).toFixed(2),
116
+ quotation_shelf_id: ((_prices$find = prices.find(function (price) {
117
+ return price.quotation_shelf_id;
118
+ })) === null || _prices$find === void 0 ? void 0 : _prices$find.quotation_shelf_id) || 0,
119
+ segments: prices.map(function (price, index) {
120
+ return _objectSpread(_objectSpread({}, price.segments[0]), {}, {
121
+ start_datetime: plan.segments[index].start,
122
+ end_datetime: plan.segments[index].end,
123
+ time_point: plan.segments[index].start,
124
+ unit_price: price.unit_price,
125
+ total_price: price.unit_price,
126
+ quantity: 1
127
+ });
128
+ }),
129
+ // Options are composed by the caller; bundle pricing belongs to the first unit only.
130
+ product_bundle: prices[0].product_bundle
131
+ });
132
+ }
133
+ export function forEachPriceQueryGroup(_x, _x2, _x3) {
134
+ return _forEachPriceQueryGroup.apply(this, arguments);
135
+ }
136
+ function _forEachPriceQueryGroup() {
137
+ _forEachPriceQueryGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(groups, resolve, concurrency) {
138
+ var next;
139
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
140
+ while (1) switch (_context2.prev = _context2.next) {
141
+ case 0:
142
+ next = 0;
143
+ _context2.next = 3;
144
+ return Promise.all(Array.from({
145
+ length: Math.min(groups.length, concurrency)
146
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
147
+ var _group;
148
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
149
+ while (1) switch (_context.prev = _context.next) {
150
+ case 0:
151
+ if (!(next < groups.length)) {
152
+ _context.next = 6;
153
+ break;
154
+ }
155
+ _group = groups[next++];
156
+ _context.next = 4;
157
+ return resolve(_group);
158
+ case 4:
159
+ _context.next = 0;
160
+ break;
161
+ case 6:
162
+ case "end":
163
+ return _context.stop();
164
+ }
165
+ }, _callee);
166
+ }))));
167
+ case 3:
168
+ case "end":
169
+ return _context2.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return _forEachPriceQueryGroup.apply(this, arguments);
174
+ }
@@ -55,6 +55,8 @@ export interface TransformBaseProductToOrderProductParams {
55
55
  fallbackProductId?: number | string | null;
56
56
  sourceProduct?: ProductData | Record<string, any> | null;
57
57
  sourceItem?: ProductData | Record<string, any> | null;
58
+ /** Validated booking quote's pre-discount main price, excluding options/bundles. */
59
+ quotedSourceProductPrice?: number | string;
58
60
  }
59
61
  export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
60
62
  _origin?: Record<string, any>;
@@ -170,7 +170,7 @@ function findVariantById(origin, variantId) {
170
170
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
171
171
  */
172
172
  export function transformBaseProductToOrderProduct(params) {
173
- var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price, _ref25, _payload$line_total, _payload$_extend3, _ref26, _ref27, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref28, _ref29, _origin$base_price, _ref30, _ref31, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _find, _resolveProductHolder, _ref32, _ref33, _payload$tax_fee, _ref34, _ref35, _payload$is_charge_ta;
173
+ var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _params$quotedSourceP, _ref24, _ref25, _payload$price, _ref26, _payload$line_total, _payload$_extend3, _ref27, _ref28, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref29, _ref30, _origin$base_price, _ref31, _ref32, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _find, _resolveProductHolder, _ref33, _ref34, _payload$tax_fee, _ref35, _ref36, _payload$is_charge_ta;
174
174
  var payload = params.payload,
175
175
  _params$fallbackProdu = params.fallbackProductId,
176
176
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
@@ -193,11 +193,11 @@ export function transformBaseProductToOrderProduct(params) {
193
193
  // 售价仍由 line_total - bundle 推导。
194
194
  var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
195
195
  var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
196
- var sourceProductPrice = toPriceString(weighedSourcePrice !== null && weighedSourcePrice !== void 0 ? weighedSourcePrice : hasPriceOverride ? (_ref23 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref23 !== void 0 ? _ref23 : payload.selling_price : (_ref24 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref24 !== void 0 ? _ref24 : catalogSourcePrice, '0.00');
197
- var explicitLineTotal = (_ref25 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref25 !== void 0 ? _ref25 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
196
+ var sourceProductPrice = toPriceString((_ref23 = (_params$quotedSourceP = params.quotedSourceProductPrice) !== null && _params$quotedSourceP !== void 0 ? _params$quotedSourceP : weighedSourcePrice) !== null && _ref23 !== void 0 ? _ref23 : hasPriceOverride ? (_ref24 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref24 !== void 0 ? _ref24 : payload.selling_price : (_ref25 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref25 !== void 0 ? _ref25 : catalogSourcePrice, '0.00');
197
+ var explicitLineTotal = (_ref26 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref26 !== void 0 ? _ref26 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
198
198
  var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
199
199
  var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
200
- var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref26 = (_ref27 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref27 !== void 0 ? _ref27 : payload.options) !== null && _ref26 !== void 0 ? _ref26 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
200
+ var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref27 = (_ref28 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref28 !== void 0 ? _ref28 : payload.options) !== null && _ref27 !== void 0 ? _ref27 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
201
201
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
202
202
  // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
203
203
  // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
@@ -212,10 +212,10 @@ export function transformBaseProductToOrderProduct(params) {
212
212
  extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
213
213
  originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
214
214
  sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
215
- catalogUnitPrice: (_ref28 = (_ref29 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref28 !== void 0 ? _ref28 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
215
+ catalogUnitPrice: (_ref29 = (_ref30 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
216
216
  quantity: resolvedQuantity
217
217
  });
218
- var sellingTotal = Number((_ref30 = (_ref31 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref31 !== void 0 ? _ref31 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref30 !== void 0 ? _ref30 : lineCompositeTotal);
218
+ var sellingTotal = Number((_ref31 = (_ref32 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref32 !== void 0 ? _ref32 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref31 !== void 0 ? _ref31 : lineCompositeTotal);
219
219
  var discountReason = resolveManualDiscountReasonFromSources({
220
220
  discountReason: payload.discount_reason,
221
221
  extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
@@ -297,8 +297,8 @@ export function transformBaseProductToOrderProduct(params) {
297
297
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
298
298
  selling_price: lineCompositeTotal,
299
299
  original_price: lineOriginalPrice,
300
- tax_fee: toPriceString((_ref32 = (_ref33 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
301
- is_charge_tax: toNumber((_ref34 = (_ref35 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref34 !== void 0 ? _ref34 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
300
+ tax_fee: toPriceString((_ref33 = (_ref34 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref34 !== void 0 ? _ref34 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
301
+ is_charge_tax: toNumber((_ref35 = (_ref36 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref36 !== void 0 ? _ref36 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
302
302
  metadata: metadata
303
303
  }, holderRelations !== undefined && !isBookingProduct(origin) && !isBookingProduct(payload) ? {
304
304
  _extend: {
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
331
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
378
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -485,7 +485,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
485
485
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
486
486
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
487
487
  */
488
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
488
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
489
+ action: "reloadCatalog";
490
+ } | {
491
+ action: "add";
492
+ cacheItem: any;
493
+ } | {
494
+ action: "requiresDetail";
495
+ payload: AddProductRequiresDetailPayload;
496
+ } | {
497
+ action: "requiresBookingEdit";
498
+ cacheItem: any;
499
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
500
+ };
489
501
  /** 规格弹窗 callback 后的第二段决策。 */
490
502
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
491
503
  /**