@pisell/pisellos 2.2.259 → 2.2.260

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 (103) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
  14. package/dist/modules/Order/index.d.ts +1 -32
  15. package/dist/modules/Order/index.js +288 -615
  16. package/dist/modules/Order/types.d.ts +2 -20
  17. package/dist/modules/Order/utils.d.ts +0 -4
  18. package/dist/modules/Order/utils.js +28 -114
  19. package/dist/modules/Product/index.d.ts +1 -1
  20. package/dist/modules/Product/types.d.ts +22 -0
  21. package/dist/modules/ProductList/index.d.ts +1 -1
  22. package/dist/modules/ProductList/index.js +4 -2
  23. package/dist/modules/ProductList/types.d.ts +2 -0
  24. package/dist/modules/Rules/index.d.ts +3 -3
  25. package/dist/modules/Rules/index.js +3 -8
  26. package/dist/modules/Rules/types.d.ts +1 -2
  27. package/dist/modules/SalesSummary/index.d.ts +3 -7
  28. package/dist/modules/SalesSummary/index.js +39 -67
  29. package/dist/modules/SalesSummary/types.d.ts +0 -1
  30. package/dist/modules/SalesSummary/utils.js +1 -2
  31. package/dist/modules/SurchargeList/index.d.ts +4 -6
  32. package/dist/modules/SurchargeList/index.js +39 -62
  33. package/dist/modules/SurchargeList/types.d.ts +2 -6
  34. package/dist/server/index.d.ts +50 -3
  35. package/dist/server/index.js +1040 -1075
  36. package/dist/server/modules/order/index.d.ts +3 -22
  37. package/dist/server/modules/order/index.js +316 -398
  38. package/dist/server/modules/products/index.d.ts +26 -7
  39. package/dist/server/modules/products/index.js +166 -76
  40. package/dist/server/modules/products/types.d.ts +14 -0
  41. package/dist/solution/BaseSales/index.d.ts +2 -22
  42. package/dist/solution/BaseSales/index.js +701 -995
  43. package/dist/solution/BaseSales/types.d.ts +0 -1
  44. package/dist/solution/BaseSales/types.js +1 -2
  45. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
  46. package/dist/solution/BookingByStep/index.d.ts +1 -1
  47. package/dist/solution/BookingTicket/index.d.ts +0 -8
  48. package/dist/solution/BookingTicket/index.js +6 -153
  49. package/dist/solution/BookingTicket/types.d.ts +2 -0
  50. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  51. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  53. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  54. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  55. package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
  56. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  57. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  58. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  59. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  60. package/lib/model/strategy/adapter/index.d.ts +4 -0
  61. package/lib/model/strategy/adapter/index.js +13 -2
  62. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
  63. package/lib/modules/Order/index.d.ts +1 -32
  64. package/lib/modules/Order/index.js +64 -402
  65. package/lib/modules/Order/types.d.ts +2 -20
  66. package/lib/modules/Order/utils.d.ts +0 -4
  67. package/lib/modules/Order/utils.js +2 -84
  68. package/lib/modules/Product/index.d.ts +1 -1
  69. package/lib/modules/Product/types.d.ts +22 -0
  70. package/lib/modules/ProductList/index.d.ts +1 -1
  71. package/lib/modules/ProductList/index.js +4 -2
  72. package/lib/modules/ProductList/types.d.ts +2 -0
  73. package/lib/modules/Rules/index.d.ts +3 -3
  74. package/lib/modules/Rules/index.js +3 -4
  75. package/lib/modules/Rules/types.d.ts +1 -2
  76. package/lib/modules/SalesSummary/index.d.ts +3 -7
  77. package/lib/modules/SalesSummary/index.js +11 -28
  78. package/lib/modules/SalesSummary/types.d.ts +0 -1
  79. package/lib/modules/SalesSummary/utils.js +0 -2
  80. package/lib/modules/SurchargeList/index.d.ts +4 -6
  81. package/lib/modules/SurchargeList/index.js +21 -41
  82. package/lib/modules/SurchargeList/types.d.ts +2 -6
  83. package/lib/server/index.d.ts +50 -3
  84. package/lib/server/index.js +215 -244
  85. package/lib/server/modules/order/index.d.ts +3 -22
  86. package/lib/server/modules/order/index.js +53 -103
  87. package/lib/server/modules/products/index.d.ts +26 -7
  88. package/lib/server/modules/products/index.js +113 -35
  89. package/lib/server/modules/products/types.d.ts +14 -0
  90. package/lib/solution/BaseSales/index.d.ts +2 -22
  91. package/lib/solution/BaseSales/index.js +60 -246
  92. package/lib/solution/BaseSales/types.d.ts +0 -1
  93. package/lib/solution/BaseSales/types.js +1 -2
  94. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
  95. package/lib/solution/BookingByStep/index.d.ts +1 -1
  96. package/lib/solution/BookingTicket/index.d.ts +0 -8
  97. package/lib/solution/BookingTicket/index.js +0 -101
  98. package/lib/solution/BookingTicket/types.d.ts +2 -0
  99. package/package.json +1 -1
  100. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  101. package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
  102. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  103. package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
@@ -3,15 +3,15 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
3
3
  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."); }
4
4
  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; } }
5
5
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
10
  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
11
  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
12
  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
13
  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; }
10
14
  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; }
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
15
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
16
  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); }
17
17
  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; }
@@ -32,13 +32,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
32
32
  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); }
33
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
35
+ import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
38
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
39
39
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
40
40
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
41
- import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
42
41
  import { DiscountModule } from "../Discount";
43
42
  import { RulesModule } from "../Rules";
44
43
  import { UnavailableReason } from "../Rules/types";
@@ -65,23 +64,6 @@ function isManualProductDiscountProduct(product) {
65
64
  return (item === null || item === void 0 ? void 0 : item.type) === 'product';
66
65
  });
67
66
  }
68
- var ORDER_PAYMENT_STATUS_PAID = 'paid';
69
- var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
70
- function isVoucherPaymentRecord(payment) {
71
- return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
72
- }
73
- function hasSyncedOrderPaymentRecord(payment) {
74
- return (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && payment.order_payment_id !== null;
75
- }
76
- function isPendingVoucherPaymentRecord(payment) {
77
- return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PENDING;
78
- }
79
- function isPaidPaymentRecord(payment) {
80
- return (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PAID;
81
- }
82
- function isCommittedVoucherPaymentRecord(payment) {
83
- return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
84
- }
85
67
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
86
68
  _inherits(OrderModule, _BaseModule);
87
69
  var _super = _createSuper(OrderModule);
@@ -126,7 +108,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
126
108
  key: "collectHydratedEditDiscounts",
127
109
  value: function collectHydratedEditDiscounts(products) {
128
110
  var discountMap = new Map();
129
- var _iterator = _createForOfIteratorHelper(expandHydratedProductsForDiscountCollection(products)),
111
+ var _iterator = _createForOfIteratorHelper(products || []),
130
112
  _step;
131
113
  try {
132
114
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -156,15 +138,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
156
138
  discount: item === null || item === void 0 ? void 0 : item.discount,
157
139
  _num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
158
140
  };
159
- var existed = discountMap.get(key);
160
- if (existed) {
161
- existed.amount = Number(existed.amount || 0) + amount;
162
- existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
163
- existed.balance = String(Number(existed.balance || 0) + amount);
164
- existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
165
- existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
166
- continue;
167
- }
168
141
  discountMap.set(key, {
169
142
  id: key,
170
143
  product_name: '',
@@ -251,19 +224,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
251
224
  product.metadata.main_product_selling_price = newMainSellingPrice;
252
225
  product.metadata.price_schema_version = 2;
253
226
  }
254
- if (Array.isArray(product.product_bundle)) {
255
- product.product_bundle = product.product_bundle.map(function (bundle) {
256
- var _ref12, _bundle$original_pric;
257
- var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
258
- if (hasBundleDiscount) return bundle;
259
- var restoredPrice = (_ref12 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
260
- if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
261
- return _objectSpread(_objectSpread({}, bundle), {}, {
262
- price: restoredPrice,
263
- bundle_selling_price: restoredPrice
264
- });
265
- });
266
- }
267
227
  product.selling_price = composeLinePrice({
268
228
  mainPrice: newMainSellingPrice,
269
229
  bundle: product.product_bundle
@@ -593,8 +553,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
593
553
  key: "scanCode",
594
554
  value: function () {
595
555
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
596
- var _this$store$discount7, _tempOrder$holder, _this$store$summary;
597
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
556
+ var _this$store$discount7, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
557
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
598
558
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
599
559
  while (1) switch (_context5.prev = _context5.next) {
600
560
  case 0:
@@ -664,20 +624,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
664
624
  });
665
625
  case 16:
666
626
  tempOrder = this.store.tempOrder;
667
- holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
668
- _ref13 = rulesModule.isDiscountListAvailable({
627
+ holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
628
+ form_record_id: tempOrder.holder.form_record_id
629
+ }] : [];
630
+ _ref12 = rulesModule.isDiscountListAvailable({
669
631
  productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
670
632
  oldDiscountList: this.getDiscountList(),
671
633
  newDiscountList: withScanList,
672
634
  orderTotalAmount: Number(((_this$store$summary = this.store.summary) === null || _this$store$summary === void 0 ? void 0 : _this$store$summary.total_amount) || 0),
673
635
  holders: holders,
674
- isFormSubject: function isFormSubject(product) {
675
- return resolveIsFormSubject(tempOrder, product);
676
- }
636
+ isFormSubject: !!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
677
637
  }) || {
678
638
  isAvailable: false,
679
639
  discountList: this.getDiscountList()
680
- }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
640
+ }, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, unavailableReason = _ref12.unavailableReason;
681
641
  if (isAvailable && newDiscountList) {
682
642
  (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
683
643
  this.applyDiscount();
@@ -704,7 +664,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
704
664
  key: "applyDiscount",
705
665
  value: function applyDiscount() {
706
666
  var _this$store$discount9,
707
- _tempOrder$holder2,
667
+ _tempOrder$holder3,
668
+ _tempOrder$holder4,
708
669
  _this$store$summary2,
709
670
  _this2 = this;
710
671
  var tempOrder = this.store.tempOrder;
@@ -712,29 +673,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
712
673
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
713
674
  // appliedProductDetails / savedAmount 复位。
714
675
  if (!tempOrder) return;
715
- this.syncLinkedBookingHoldersToProducts(tempOrder);
716
676
  delete tempOrder.discount_list;
717
- var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
718
- var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
719
- if (shouldSkipDiscountCalculation) return;
677
+ if (this.shouldSkipDiscountCalculation(tempOrder)) return;
720
678
  var rulesModule = this.store.rules;
721
679
  if (!rulesModule) return;
722
- var holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
680
+ var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
681
+ var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
682
+ form_record_id: tempOrder.holder.form_record_id
683
+ }] : [];
723
684
  var result = rulesModule.calcDiscount({
724
685
  productList: tempOrder.products,
725
686
  discountList: discountList,
726
687
  holders: holders,
727
- isFormSubject: function isFormSubject(product) {
728
- return resolveIsFormSubject(tempOrder, product);
729
- },
688
+ isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
730
689
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
731
690
  });
732
691
  if (result !== null && result !== void 0 && result.productList) {
733
692
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
734
693
  tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
735
- var _ref14;
694
+ var _ref13;
736
695
  var uid = getOrderProductLineUid(product);
737
- var previous = (_ref14 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref14 !== void 0 ? _ref14 : previousProductsByUid.get("__index__:".concat(index));
696
+ var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
738
697
  if (isManualProductDiscountProduct(previous)) {
739
698
  return previous;
740
699
  }
@@ -1259,15 +1218,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1259
1218
  }, {
1260
1219
  key: "extractOrderIdFromSubmitResult",
1261
1220
  value: function extractOrderIdFromSubmitResult(result) {
1262
- var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
1263
- return (_ref15 = (_ref16 = (_ref17 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref17 !== void 0 ? _ref17 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref15 !== void 0 ? _ref15 : null;
1221
+ var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
1222
+ return (_ref14 = (_ref15 = (_ref16 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
1264
1223
  }
1265
1224
  }, {
1266
1225
  key: "calculatePaymentEffectiveAmount",
1267
1226
  value: function calculatePaymentEffectiveAmount(payment) {
1268
- var _ref18, _payment$origin_amoun;
1227
+ var _ref17, _payment$origin_amoun;
1269
1228
  var amount = new Decimal(payment.amount || 0);
1270
- var originAmount = new Decimal((_ref18 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref18 !== void 0 ? _ref18 : 0);
1229
+ var originAmount = new Decimal((_ref17 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref17 !== void 0 ? _ref17 : 0);
1271
1230
  var serviceFee = new Decimal(payment.service_fee || 0);
1272
1231
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1273
1232
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1281,7 +1240,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1281
1240
  return mapPaymentItemsToOrderPayments(payments, {
1282
1241
  includeVoided: false
1283
1242
  }).reduce(function (sum, payment) {
1284
- if (!isPaidPaymentRecord(payment)) return sum;
1285
1243
  return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1286
1244
  }, new Decimal(0));
1287
1245
  }
@@ -1295,35 +1253,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1295
1253
  value: function normalizeDepositAmount(amount) {
1296
1254
  return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
1297
1255
  }
1298
- }, {
1299
- key: "getLastOrderDepositSnapshot",
1300
- value: function getLastOrderDepositSnapshot() {
1301
- var _lastOrderInfo$deposi, _lastOrderInfo$summar;
1302
- var lastOrderInfo = this.store.lastOrderInfo;
1303
- if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return null;
1304
- var rawDepositAmount = (_lastOrderInfo$deposi = lastOrderInfo.deposit_amount) !== null && _lastOrderInfo$deposi !== void 0 ? _lastOrderInfo$deposi : (_lastOrderInfo$summar = lastOrderInfo.summary) === null || _lastOrderInfo$summar === void 0 ? void 0 : _lastOrderInfo$summar.deposit_amount;
1305
- var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
1306
- var hasDepositAmount = new Decimal(depositAmount).gt(0);
1307
- var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
1308
- if (!isDeposit || !hasDepositAmount) return null;
1309
- return {
1310
- isDeposit: 1,
1311
- depositAmount: depositAmount
1312
- };
1313
- }
1314
- }, {
1315
- key: "getLastOrderSubmitSnapshot",
1316
- value: function getLastOrderSubmitSnapshot() {
1317
- var lastOrderInfo = this.store.lastOrderInfo;
1318
- if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return {};
1319
- var businessCode = lastOrderInfo.business_code;
1320
- var type = lastOrderInfo.type;
1321
- return _objectSpread(_objectSpread({}, typeof businessCode === 'string' && businessCode ? {
1322
- businessCode: businessCode
1323
- } : {}), typeof type === 'string' && type ? {
1324
- type: type
1325
- } : {});
1326
- }
1327
1256
  }, {
1328
1257
  key: "applyDepositAmountToSummary",
1329
1258
  value: function applyDepositAmountToSummary(tempOrder, summary, amount) {
@@ -1342,28 +1271,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1342
1271
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
1343
1272
  return nextSummary;
1344
1273
  }
1345
- }, {
1346
- key: "applyLastOrderDepositSnapshot",
1347
- value: function applyLastOrderDepositSnapshot(tempOrder, summary) {
1348
- var snapshot = this.getLastOrderDepositSnapshot();
1349
- if (!snapshot) return summary;
1350
- var existedDeposit = summary.deposit && _typeof(summary.deposit) === 'object' ? summary.deposit : undefined;
1351
- var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
1352
- deposit_amount: snapshot.depositAmount,
1353
- deposit: _objectSpread(_objectSpread({}, existedDeposit || {}), {}, {
1354
- total: snapshot.depositAmount,
1355
- deposit_policy_ids: (existedDeposit === null || existedDeposit === void 0 ? void 0 : existedDeposit.deposit_policy_ids) || [],
1356
- hasDeposit: true
1357
- })
1358
- });
1359
- tempOrder.deposit_amount = snapshot.depositAmount;
1360
- tempOrder.is_deposit = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
1361
- return nextSummary;
1362
- }
1363
1274
  }, {
1364
1275
  key: "isDepositOrder",
1365
1276
  value: function isDepositOrder(tempOrder, depositAmount) {
1366
- return tempOrder.is_deposit === 1 && depositAmount.gt(0);
1277
+ return tempOrder.is_deposit === 1 || depositAmount.gt(0);
1367
1278
  }
1368
1279
  }, {
1369
1280
  key: "getOrderExpectedAmount",
@@ -1378,39 +1289,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1378
1289
  if (depositAmount.lte(0)) return false;
1379
1290
  return params.paidAmount.gte(depositAmount);
1380
1291
  }
1381
- }, {
1382
- key: "getPaymentCompletion",
1383
- value: function getPaymentCompletion(payments) {
1384
- var tempOrder = this.ensureTempOrder();
1385
- var summary = this.store.summary || createEmptySummary();
1386
- var paymentList = payments || tempOrder.payments || [];
1387
- var refundAmount = this.getSummaryRefundAmount(summary);
1388
- var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1389
- var depositAmount = this.getDepositAmount(tempOrder, summary);
1390
- var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1391
- var isDepositFullyPaid = this.isDepositCovered({
1392
- tempOrder: tempOrder,
1393
- summary: summary,
1394
- paidAmount: netPaidAmount
1395
- });
1396
- var isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
1397
- var paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? 'deposit' : 'normal';
1398
- return {
1399
- isFullyPaid: isOrderFullyPaid,
1400
- isOrderFullyPaid: isOrderFullyPaid,
1401
- isDepositFullyPaid: isDepositFullyPaid,
1402
- paymentStage: paymentStage,
1403
- depositAmount: depositAmount.toFixed(2),
1404
- orderExpectedAmount: orderExpectedAmount.toFixed(2)
1405
- };
1406
- }
1407
1292
  }, {
1408
1293
  key: "calculateDepositPaidAmount",
1409
1294
  value: function calculateDepositPaidAmount(payments) {
1410
1295
  var _this5 = this;
1411
1296
  return (payments || []).reduce(function (sum, payment) {
1412
1297
  var paymentRecord = payment;
1413
- if (!isPaidPaymentRecord(paymentRecord)) return sum;
1298
+ if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return sum;
1414
1299
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1415
1300
  if (!isDepositPayment) return sum;
1416
1301
  if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
@@ -1432,7 +1317,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1432
1317
  }, {
1433
1318
  key: "normalizePaymentSource",
1434
1319
  value: function normalizePaymentSource(payment, options) {
1435
- var _ref19, _paymentRecord$origin;
1320
+ var _ref18, _paymentRecord$origin;
1436
1321
  var paymentRecord = payment;
1437
1322
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1438
1323
  if (!metadata.unique_payment_number) {
@@ -1440,7 +1325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1440
1325
  }
1441
1326
  var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1442
1327
  metadata: metadata,
1443
- origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
1328
+ origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
1444
1329
  });
1445
1330
  if (paymentRecord.status !== undefined) {
1446
1331
  normalized.status = paymentRecord.status;
@@ -1561,7 +1446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1561
1446
  var _this6 = this;
1562
1447
  return (payments || []).reduce(function (summary, payment) {
1563
1448
  var paymentRecord = payment;
1564
- if (!isPaidPaymentRecord(paymentRecord)) return summary;
1449
+ if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
1565
1450
  return {
1566
1451
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1567
1452
  orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
@@ -1773,7 +1658,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1773
1658
  _product$payment_pric,
1774
1659
  _sku$code,
1775
1660
  _sku$barcode,
1776
- _ref20,
1661
+ _ref19,
1777
1662
  _sku$variant_id,
1778
1663
  _this8 = this;
1779
1664
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1800,24 +1685,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1800
1685
  product_sku: this.normalizeFingerprintValue({
1801
1686
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
1802
1687
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
1803
- variant_id: (_ref20 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
1688
+ variant_id: (_ref19 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref19 !== void 0 ? _ref19 : 0,
1804
1689
  variant: sku.variant || [],
1805
1690
  option: getProductSkuOptions(product || {}).map(function (option) {
1806
- var _ref21, _option$id, _option$option_group_, _ref22, _option$option_group_2, _option$num, _option$add_price;
1691
+ var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
1807
1692
  return {
1808
- id: (_ref21 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref21 !== void 0 ? _ref21 : null,
1693
+ id: (_ref20 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref20 !== void 0 ? _ref20 : null,
1809
1694
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1810
- option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1695
+ option_group_item_id: (_ref21 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref21 !== void 0 ? _ref21 : null,
1811
1696
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1812
1697
  add_price: _this8.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1813
1698
  };
1814
1699
  })
1815
1700
  }),
1816
1701
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1817
- var _ref23, _ref24, _bundle$bundle_produc, _ref25, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1702
+ var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1818
1703
  return {
1819
- bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
1820
- bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
1704
+ bundle_product_id: (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
1705
+ bundle_variant_id: (_ref24 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0,
1821
1706
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1822
1707
  price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1823
1708
  bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
@@ -1826,10 +1711,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1826
1711
  };
1827
1712
  })),
1828
1713
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1829
- var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
1714
+ var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
1830
1715
  return {
1831
- type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
1832
- discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
1716
+ type: (_ref25 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref25 !== void 0 ? _ref25 : '',
1717
+ discount_id: (_ref26 = (_ref27 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
1833
1718
  amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1834
1719
  };
1835
1720
  }))
@@ -1853,14 +1738,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1853
1738
  var _product$product_id3,
1854
1739
  _product$product_vari2,
1855
1740
  _product$num2,
1856
- _ref29,
1741
+ _ref28,
1857
1742
  _metadata$unique_iden,
1858
1743
  _metadata$price_overr,
1859
1744
  _metadata$is_manual_d,
1860
1745
  _metadata$product_dis,
1861
1746
  _sku$code2,
1862
1747
  _sku$barcode2,
1863
- _ref30,
1748
+ _ref29,
1864
1749
  _sku$variant_id2,
1865
1750
  _this10 = this;
1866
1751
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1876,7 +1761,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1876
1761
  extension_type: extensionType,
1877
1762
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
1878
1763
  metadata: {
1879
- unique_identification_number: (_ref29 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref29 !== void 0 ? _ref29 : '',
1764
+ unique_identification_number: (_ref28 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref28 !== void 0 ? _ref28 : '',
1880
1765
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
1881
1766
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
1882
1767
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -1884,35 +1769,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1884
1769
  product_sku: this.normalizeFingerprintValue({
1885
1770
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
1886
1771
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
1887
- variant_id: (_ref30 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref30 !== void 0 ? _ref30 : 0,
1772
+ variant_id: (_ref29 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref29 !== void 0 ? _ref29 : 0,
1888
1773
  variant: sku.variant || [],
1889
1774
  option: getProductSkuOptions(product || {}).map(function (option) {
1890
- var _ref31, _option$id2, _option$option_group_3, _ref32, _option$option_group_4, _option$num2, _option$add_price2;
1775
+ var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
1891
1776
  return {
1892
- id: (_ref31 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref31 !== void 0 ? _ref31 : null,
1777
+ id: (_ref30 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref30 !== void 0 ? _ref30 : null,
1893
1778
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
1894
- option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
1779
+ option_group_item_id: (_ref31 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref31 !== void 0 ? _ref31 : null,
1895
1780
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1896
1781
  add_price: _this10.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1897
1782
  };
1898
1783
  })
1899
1784
  }),
1900
1785
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1901
- var _ref33, _bundle$bundle_id, _ref34, _bundle$bundle_group_, _ref35, _ref36, _bundle$bundle_produc2, _ref37, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
1786
+ var _ref32, _bundle$bundle_id, _ref33, _bundle$bundle_group_, _ref34, _ref35, _bundle$bundle_produc2, _ref36, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
1902
1787
  return {
1903
- bundle_id: (_ref33 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref33 !== void 0 ? _ref33 : null,
1904
- bundle_group_id: (_ref34 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref34 !== void 0 ? _ref34 : null,
1905
- bundle_product_id: (_ref35 = (_ref36 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref36 !== void 0 ? _ref36 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref35 !== void 0 ? _ref35 : null,
1906
- bundle_variant_id: (_ref37 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref37 !== void 0 ? _ref37 : 0,
1788
+ bundle_id: (_ref32 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref32 !== void 0 ? _ref32 : null,
1789
+ bundle_group_id: (_ref33 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref33 !== void 0 ? _ref33 : null,
1790
+ bundle_product_id: (_ref34 = (_ref35 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref34 !== void 0 ? _ref34 : null,
1791
+ bundle_variant_id: (_ref36 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
1907
1792
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1908
1793
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1909
1794
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
1910
1795
  option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1911
- var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
1796
+ var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
1912
1797
  return {
1913
- id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
1798
+ id: (_ref37 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
1914
1799
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
1915
- option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
1800
+ option_group_item_id: (_ref38 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
1916
1801
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1917
1802
  add_price: _this10.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
1918
1803
  };
@@ -1920,10 +1805,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1920
1805
  };
1921
1806
  })),
1922
1807
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1923
- var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
1808
+ var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
1924
1809
  return {
1925
- type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
1926
- discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
1810
+ type: (_ref39 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref39 !== void 0 ? _ref39 : '',
1811
+ discount_id: (_ref40 = (_ref41 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
1927
1812
  amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1928
1813
  };
1929
1814
  }))
@@ -1995,20 +1880,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1995
1880
  });
1996
1881
  return currentAmountGap === snapshotAmountGap;
1997
1882
  }
1998
- }, {
1999
- key: "hasShopDiscountChangedFromSnapshot",
2000
- value: function hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
2001
- var _snapshot$shop_discou;
2002
- var snapshotSummary = snapshot.summary && _typeof(snapshot.summary) === 'object' ? snapshot.summary : {};
2003
- var snapshotShopDiscount = (_snapshot$shop_discou = snapshot.shop_discount) !== null && _snapshot$shop_discou !== void 0 ? _snapshot$shop_discou : snapshotSummary.shop_discount;
2004
- if (snapshotShopDiscount === undefined || snapshotShopDiscount === null || snapshotShopDiscount === '') {
2005
- return !new Decimal(tempOrder.shop_discount || 0).equals(0);
2006
- }
2007
- return !new Decimal(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
2008
- }
2009
1883
  }, {
2010
1884
  key: "restoreOriginalSnapshotIfProductsUnchanged",
2011
- value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
1885
+ value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder) {
1886
+ var snapshot = this.getOriginalSalesSnapshot(tempOrder);
1887
+ if (!snapshot) return null;
2012
1888
  var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
2013
1889
  if (currentFingerprint !== snapshot.productFingerprint) {
2014
1890
  var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
@@ -2139,7 +2015,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2139
2015
  key: "restoreOrder",
2140
2016
  value: function restoreOrder() {
2141
2017
  var _this$store$discount11, _this$store$discount12;
2142
- this.logInfo('restoreOrder start', {});
2143
2018
  var freshTempOrder = this.createDefaultTempOrderInstance();
2144
2019
  this.ensureExternalSaleNumber(freshTempOrder);
2145
2020
  this.store.tempOrder = freshTempOrder;
@@ -2213,11 +2088,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2213
2088
  }, {
2214
2089
  key: "getOrderIdentity",
2215
2090
  value: function getOrderIdentity() {
2216
- var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
2091
+ var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2217
2092
  var tempOrder = this.store.tempOrder;
2218
2093
  if (!tempOrder) return null;
2219
2094
  var lastOrderInfo = this.store.lastOrderInfo || {};
2220
- var orderId = (_ref43 = (_ref44 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref44 !== void 0 ? _ref44 : lastOrderInfo.id) !== null && _ref43 !== void 0 ? _ref43 : null;
2095
+ var orderId = (_ref42 = (_ref43 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref43 !== void 0 ? _ref43 : lastOrderInfo.id) !== null && _ref42 !== void 0 ? _ref42 : null;
2221
2096
  return {
2222
2097
  localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2223
2098
  orderId: orderId,
@@ -2252,7 +2127,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2252
2127
  orderPaidAmount: paidPaymentSummary.gapPaidAmount
2253
2128
  });
2254
2129
  return {
2255
- isDeposit: tempOrder.is_deposit === 1,
2130
+ isDeposit: tempOrder.is_deposit === 1 || depositAmount !== '0.00',
2256
2131
  depositAmount: depositAmount,
2257
2132
  expectAmount: summary.expect_amount || '0.00',
2258
2133
  totalAmount: summary.total_amount || '0.00',
@@ -2370,11 +2245,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2370
2245
  }, {
2371
2246
  key: "captureProductRuntime",
2372
2247
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2373
- var _extend$productsByUid, _ref45, _rawProduct$_origin;
2248
+ var _extend$productsByUid, _ref44, _rawProduct$_origin;
2374
2249
  var uid = existedUid || this.getProductUid(normalizedProduct);
2375
2250
  var extend = this.ensureExtend(tempOrder);
2376
2251
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2377
- var origin = (_ref45 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref45 !== void 0 ? _ref45 : existed.origin;
2252
+ var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
2378
2253
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2379
2254
  origin: origin
2380
2255
  } : {});
@@ -2441,48 +2316,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2441
2316
  return record !== undefined && record !== null && record !== '';
2442
2317
  });
2443
2318
  }
2444
- }, {
2445
- key: "setProductHolderFromBooking",
2446
- value: function setProductHolderFromBooking(product, booking) {
2447
- if (!product || !booking) return;
2448
- var holderRecords = this.collectBookingHolderRecords(booking);
2449
- if (!product.metadata || _typeof(product.metadata) !== 'object') {
2450
- product.metadata = {};
2451
- }
2452
- product.metadata.holder_id = holderRecords.length > 0 ? holderRecords : null;
2453
- }
2454
- }, {
2455
- key: "syncLinkedBookingHoldersToProducts",
2456
- value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2457
- var _this13 = this;
2458
- var bookings = tempOrder.bookings || [];
2459
- var products = tempOrder.products || [];
2460
- if (!bookings.length || !products.length) return;
2461
- var bookingByProductUid = new Map();
2462
- var bookingByBookingUid = new Map();
2463
- bookings.forEach(function (booking) {
2464
- var _booking$metadata2, _booking$metadata3;
2465
- if (!booking || _typeof(booking) !== 'object') return;
2466
- var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
2467
- if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
2468
- bookingByProductUid.set(String(productUid), booking);
2469
- }
2470
- var bookingUid = ((_booking$metadata3 = booking.metadata) === null || _booking$metadata3 === void 0 ? void 0 : _booking$metadata3.unique_identification_number) || booking.booking_uid;
2471
- if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
2472
- bookingByBookingUid.set(String(bookingUid), booking);
2473
- }
2474
- });
2475
- products.forEach(function (product) {
2476
- var _product$metadata5, _product$metadata6;
2477
- if (!product || _typeof(product) !== 'object') return;
2478
- var productUid = ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || product.unique_identification_number;
2479
- var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2480
- var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2481
- if (linkedBooking) {
2482
- _this13.setProductHolderFromBooking(product, linkedBooking);
2483
- }
2484
- });
2485
- }
2486
2319
 
2487
2320
  /**
2488
2321
  * 按 form_record 顺序读取 booking holder 的主字段名称。
@@ -2517,7 +2350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2517
2350
  }, {
2518
2351
  key: "buildTempOrderHolderFromBookings",
2519
2352
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2520
- var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder3, _baseHolder3, _this$otherParams;
2353
+ var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder5, _baseHolder3, _this$otherParams;
2521
2354
  var holderRecords = [];
2522
2355
  var holderNames = [];
2523
2356
  var baseHolder = null;
@@ -2564,7 +2397,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2564
2397
  }
2565
2398
  var nextHolder = {
2566
2399
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
2567
- form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
2400
+ form_id: (_ref45 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder5 = tempOrder.holder) === null || _tempOrder$holder5 === void 0 ? void 0 : _tempOrder$holder5.form_id) !== null && _ref45 !== void 0 ? _ref45 : 0,
2568
2401
  form_record: holderRecords
2569
2402
  };
2570
2403
  if (holderNames.length) {
@@ -2587,42 +2420,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2587
2420
  value: function syncTempOrderHolderFromBookings(tempOrder) {
2588
2421
  var bookings = tempOrder.bookings || [];
2589
2422
  var hasHolderSource = bookings.some(function (booking) {
2590
- var _booking$metadata4;
2591
- return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata4 = booking.metadata) === null || _booking$metadata4 === void 0 ? void 0 : _booking$metadata4.holder_id) !== undefined;
2423
+ var _booking$metadata2;
2424
+ return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== undefined;
2592
2425
  });
2593
2426
  var nextHolder = this.buildTempOrderHolderFromBookings(tempOrder);
2594
2427
  if (nextHolder || hasHolderSource || bookings.length === 0) {
2595
2428
  tempOrder.holder = nextHolder;
2596
2429
  }
2597
- this.syncLinkedBookingHoldersToProducts(tempOrder);
2598
2430
  }
2599
2431
  }, {
2600
2432
  key: "getBookingUniqueIdentificationNumber",
2601
2433
  value: function getBookingUniqueIdentificationNumber(booking) {
2602
- var _booking$metadata5;
2603
- var uid = booking === null || booking === void 0 || (_booking$metadata5 = booking.metadata) === null || _booking$metadata5 === void 0 ? void 0 : _booking$metadata5.unique_identification_number;
2434
+ var _booking$metadata3;
2435
+ var uid = booking === null || booking === void 0 || (_booking$metadata3 = booking.metadata) === null || _booking$metadata3 === void 0 ? void 0 : _booking$metadata3.unique_identification_number;
2604
2436
  if (uid === undefined || uid === null || uid === '') return null;
2605
2437
  return String(uid);
2606
2438
  }
2607
2439
  }, {
2608
2440
  key: "findBookingIndexByUniqueIdentificationNumber",
2609
2441
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2610
- var _this14 = this;
2442
+ var _this13 = this;
2611
2443
  return (tempOrder.bookings || []).findIndex(function (booking) {
2612
- return _this14.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2444
+ return _this13.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2613
2445
  });
2614
2446
  }
2615
2447
  }, {
2616
2448
  key: "removeLinkedBookingsForProduct",
2617
2449
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2618
- var _product$metadata7,
2619
- _product$metadata8,
2620
- _this15 = this;
2621
- var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2622
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2450
+ var _product$metadata5,
2451
+ _product$metadata6,
2452
+ _this14 = this;
2453
+ var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2454
+ var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2623
2455
  if (!productUid && !bookingUid) return;
2624
2456
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2625
- var currentBookingUid = _this15.getBookingUniqueIdentificationNumber(booking);
2457
+ var currentBookingUid = _this14.getBookingUniqueIdentificationNumber(booking);
2626
2458
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2627
2459
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2628
2460
  return true;
@@ -2660,17 +2492,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2660
2492
  hasDeposit: true
2661
2493
  } : undefined
2662
2494
  });
2663
- var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
2664
2495
  tempOrder.deposit_amount = depositAmount;
2665
- tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
2666
- return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
2496
+ tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
2497
+ return nextSummary;
2667
2498
  }
2668
2499
  }, {
2669
2500
  key: "recalculateSummary",
2670
2501
  value: function () {
2671
2502
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2672
- var _this$otherParams2, _ref47, _salesSummaryResult$e;
2673
- var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2503
+ var _ref46, _salesSummaryResult$e;
2504
+ var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2674
2505
  return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2675
2506
  while (1) switch (_context13.prev = _context13.next) {
2676
2507
  case 0:
@@ -2682,17 +2513,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2682
2513
  return _context13.abrupt("return", null);
2683
2514
  case 3:
2684
2515
  this.sanitizeTempOrderProducts(tempOrder);
2685
- originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
2686
- hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
2687
- shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2688
- snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2516
+ snapshotSummary = this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder);
2689
2517
  if (!snapshotSummary) {
2690
- _context13.next = 10;
2518
+ _context13.next = 7;
2691
2519
  break;
2692
2520
  }
2693
2521
  return _context13.abrupt("return", snapshotSummary);
2694
- case 10:
2695
- shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2522
+ case 7:
2523
+ shouldFullRecalculateFromSnapshot = Boolean(this.getOriginalSalesSnapshot(tempOrder));
2696
2524
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
2697
2525
  if (shouldFullRecalculateFromSnapshot) {
2698
2526
  this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
@@ -2702,7 +2530,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2702
2530
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2703
2531
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2704
2532
  if (salesSummary) {
2705
- _context13.next = 26;
2533
+ _context13.next = 23;
2706
2534
  break;
2707
2535
  }
2708
2536
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2729,16 +2557,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2729
2557
  summary: emptySummary
2730
2558
  });
2731
2559
  return _context13.abrupt("return", this.store.summary);
2732
- case 26:
2733
- _context13.next = 28;
2734
- return salesSummary.getSummary(_objectSpread({
2560
+ case 23:
2561
+ _context13.next = 25;
2562
+ return salesSummary.getSummary({
2735
2563
  products: summaryProducts,
2736
2564
  isPriceIncludeTax: tempOrder.is_price_include_tax,
2737
2565
  shopDiscount: tempOrder.shop_discount
2738
- }, (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.channel ? {
2739
- channel: this.otherParams.channel
2740
- } : {}));
2741
- case 28:
2566
+ });
2567
+ case 25:
2742
2568
  salesSummaryResult = _context13.sent;
2743
2569
  if (shouldFullRecalculateFromSnapshot) {
2744
2570
  tempOrder.products = summaryProducts;
@@ -2747,7 +2573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2747
2573
  roundingAmount = paidPaymentSummary.roundingAmount;
2748
2574
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2749
2575
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2750
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref47 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref47 !== void 0 ? _ref47 : 0) : null;
2576
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref46 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref46 !== void 0 ? _ref46 : 0) : null;
2751
2577
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2752
2578
  rounding_amount: roundingAmount.toFixed(2)
2753
2579
  }, expectAmount ? {
@@ -2785,7 +2611,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2785
2611
  summary: summary
2786
2612
  });
2787
2613
  return _context13.abrupt("return", this.store.summary);
2788
- case 46:
2614
+ case 43:
2789
2615
  case "end":
2790
2616
  return _context13.stop();
2791
2617
  }
@@ -2925,17 +2751,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2925
2751
  }, {
2926
2752
  key: "buildTempOrderCustomer",
2927
2753
  value: function buildTempOrderCustomer(params) {
2928
- var _ref48, _ref49, _ref50, _source$name, _ref51, _ref52, _ref53, _source$customer_name, _source$id, _source$customer_id, _ref54, _source$country_calli, _source$phone, _source$email;
2754
+ var _ref47, _ref48, _ref49, _source$name, _ref50, _ref51, _ref52, _source$customer_name, _source$id, _source$customer_id, _ref53, _source$country_calli, _source$phone, _source$email;
2929
2755
  if (!params.customerId) return null;
2930
2756
  var source = params.source ? cloneDeep(params.source) : {};
2931
- var name = (_ref48 = (_ref49 = (_ref50 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.customerName) !== null && _ref49 !== void 0 ? _ref49 : source.customer_name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
2932
- var customerName = (_ref51 = (_ref52 = (_ref53 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref53 !== void 0 ? _ref53 : source.display_name) !== null && _ref52 !== void 0 ? _ref52 : source.name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
2757
+ var name = (_ref47 = (_ref48 = (_ref49 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.customerName) !== null && _ref48 !== void 0 ? _ref48 : source.customer_name) !== null && _ref47 !== void 0 ? _ref47 : params.customerName;
2758
+ var customerName = (_ref50 = (_ref51 = (_ref52 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.display_name) !== null && _ref51 !== void 0 ? _ref51 : source.name) !== null && _ref50 !== void 0 ? _ref50 : params.customerName;
2933
2759
  return _objectSpread(_objectSpread({}, source), {}, {
2934
2760
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
2935
2761
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
2936
2762
  name: String(name || ''),
2937
2763
  customer_name: String(customerName || ''),
2938
- country_calling_code: String((_ref54 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref54 !== void 0 ? _ref54 : params.countryCallingCode),
2764
+ country_calling_code: String((_ref53 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref53 !== void 0 ? _ref53 : params.countryCallingCode),
2939
2765
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
2940
2766
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
2941
2767
  });
@@ -2950,15 +2776,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2950
2776
  }, {
2951
2777
  key: "productHasCustomerBoundDiscount",
2952
2778
  value: function productHasCustomerBoundDiscount(product) {
2953
- var _this16 = this;
2779
+ var _this15 = this;
2954
2780
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
2955
- return _this16.isCustomerBoundDiscount(discount);
2781
+ return _this15.isCustomerBoundDiscount(discount);
2956
2782
  })) {
2957
2783
  return true;
2958
2784
  }
2959
2785
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
2960
2786
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
2961
- return _this16.isCustomerBoundDiscount(discount);
2787
+ return _this15.isCustomerBoundDiscount(discount);
2962
2788
  });
2963
2789
  });
2964
2790
  }
@@ -2967,18 +2793,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2967
2793
  value: function shouldSkipDiscountCalculation(tempOrder) {
2968
2794
  var _this$store$discount13,
2969
2795
  _this$store$discount14,
2970
- _this17 = this;
2796
+ _this16 = this;
2971
2797
  if (this.hasActiveCustomerBoundDiscount) return false;
2972
2798
  var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
2973
2799
  if (discountList.length > 0) return false;
2974
2800
  return !(tempOrder.products || []).some(function (product) {
2975
- return _this17.productHasCustomerBoundDiscount(product);
2801
+ return _this16.productHasCustomerBoundDiscount(product);
2976
2802
  });
2977
2803
  }
2978
2804
  }, {
2979
2805
  key: "clearCustomerBoundDiscounts",
2980
2806
  value: function clearCustomerBoundDiscounts(tempOrder) {
2981
- var _this18 = this,
2807
+ var _this17 = this,
2982
2808
  _discountModule$getDi,
2983
2809
  _discountModule$getOr,
2984
2810
  _discountModule$setDi,
@@ -2987,7 +2813,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2987
2813
  var filterDiscountList = function filterDiscountList(discountList) {
2988
2814
  if (!Array.isArray(discountList)) return [];
2989
2815
  return discountList.filter(function (discount) {
2990
- var shouldRemove = _this18.isCustomerBoundDiscount(discount);
2816
+ var shouldRemove = _this17.isCustomerBoundDiscount(discount);
2991
2817
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
2992
2818
  return !shouldRemove;
2993
2819
  });
@@ -3015,11 +2841,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3015
2841
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3016
2842
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3017
2843
  if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
3018
- return !_this18.isCustomerBoundDiscount(discount);
2844
+ return !_this17.isCustomerBoundDiscount(discount);
3019
2845
  });
3020
2846
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3021
2847
  if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
3022
- return !_this18.isCustomerBoundDiscount(discount);
2848
+ return !_this17.isCustomerBoundDiscount(discount);
3023
2849
  });
3024
2850
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3025
2851
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3034,14 +2860,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3034
2860
  }, {
3035
2861
  key: "updateTempOrderCustomer",
3036
2862
  value: function updateTempOrderCustomer(customer) {
3037
- var _tempOrder$customer_i2, _ref55, _ref56, _customer$customer_id, _ref57, _ref58, _ref59, _customer$customer_na, _ref60, _customer$country_cal, _tempOrder$customer_i3;
2863
+ var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
3038
2864
  var tempOrder = this.ensureTempOrder();
3039
2865
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
3040
- var customerId = (_ref55 = (_ref56 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref56 !== void 0 ? _ref56 : customer.id) !== null && _ref55 !== void 0 ? _ref55 : null;
3041
- var customerName = (_ref57 = (_ref58 = (_ref59 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref59 !== void 0 ? _ref59 : customer.display_name) !== null && _ref58 !== void 0 ? _ref58 : customer.name) !== null && _ref57 !== void 0 ? _ref57 : '';
2866
+ var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
2867
+ var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
3042
2868
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
3043
2869
  tempOrder.customer_name = String(customerName || '');
3044
- tempOrder.country_calling_code = String((_ref60 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : '');
2870
+ tempOrder.country_calling_code = String((_ref59 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref59 !== void 0 ? _ref59 : '');
3045
2871
  tempOrder.phone = String(customer.phone || '');
3046
2872
  tempOrder.email = String(customer.email || '');
3047
2873
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3092,7 +2918,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3092
2918
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3093
2919
  clearTempOrderHolderAssignments(tempOrder);
3094
2920
  this.clearCustomerBoundDiscounts(tempOrder);
3095
- this.applyDiscount();
3096
2921
  }
3097
2922
  this.persistTempOrder();
3098
2923
  this.saveDraftInBackground();
@@ -3187,7 +3012,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3187
3012
  }, {
3188
3013
  key: "addOrderPayment",
3189
3014
  value: function addOrderPayment(payment) {
3190
- var _this19 = this;
3015
+ var _this18 = this;
3191
3016
  this.logInfo('addOrderPayment', {
3192
3017
  payment: payment
3193
3018
  });
@@ -3204,7 +3029,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3204
3029
  void this.recalculateSummary({
3205
3030
  createIfMissing: true
3206
3031
  }).catch(function (error) {
3207
- _this19.logError('recalculate summary after addOrderPayment failed', {
3032
+ _this18.logError('recalculate summary after addOrderPayment failed', {
3208
3033
  error: error instanceof Error ? error.message : String(error)
3209
3034
  });
3210
3035
  });
@@ -3259,77 +3084,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3259
3084
  this.persistTempOrder();
3260
3085
  return tempOrder.payments;
3261
3086
  }
3262
- }, {
3263
- key: "confirmPendingVoucherPaymentsInList",
3264
- value: function confirmPendingVoucherPaymentsInList(payments) {
3265
- return (payments || []).map(function (payment) {
3266
- if (!isPendingVoucherPaymentRecord(payment)) return payment;
3267
- return _objectSpread(_objectSpread({}, payment), {}, {
3268
- status: ORDER_PAYMENT_STATUS_PAID
3269
- });
3270
- });
3271
- }
3272
- }, {
3273
- key: "discardPendingVoucherPaymentsFromList",
3274
- value: function discardPendingVoucherPaymentsFromList(payments) {
3275
- return (payments || []).filter(function (payment) {
3276
- return !isPendingVoucherPaymentRecord(payment);
3277
- });
3278
- }
3279
- }, {
3280
- key: "prepareVoucherPaymentsForSubmit",
3281
- value: function prepareVoucherPaymentsForSubmit(payments) {
3282
- var confirmPendingVoucherPayments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3283
- var mappedPayments = mapPaymentItemsToOrderPayments(payments || []);
3284
- return confirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : this.discardPendingVoucherPaymentsFromList(mappedPayments);
3285
- }
3286
- }, {
3287
- key: "applyPaymentLifecycleChange",
3288
- value: function applyPaymentLifecycleChange(tempOrder, options) {
3289
- var _this20 = this;
3290
- this.updateTempOrderPaymentStatus(tempOrder);
3291
- if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3292
- this.persistTempOrder();
3293
- }
3294
- if ((options === null || options === void 0 ? void 0 : options.recalculateSummary) === false) return;
3295
- var logContext = (options === null || options === void 0 ? void 0 : options.logContext) || 'payment lifecycle change';
3296
- void this.recalculateSummary({
3297
- createIfMissing: true
3298
- }).catch(function (error) {
3299
- _this20.logError("recalculate summary after ".concat(logContext, " failed"), {
3300
- error: error instanceof Error ? error.message : String(error)
3301
- });
3302
- });
3303
- }
3304
- }, {
3305
- key: "confirmPendingVoucherPayments",
3306
- value: function confirmPendingVoucherPayments(options) {
3307
- var tempOrder = this.ensureTempOrder();
3308
- var payments = tempOrder.payments || [];
3309
- var hasPendingVoucher = payments.some(function (payment) {
3310
- return isPendingVoucherPaymentRecord(payment);
3311
- });
3312
- if (!hasPendingVoucher) return payments;
3313
- tempOrder.payments = this.confirmPendingVoucherPaymentsInList(payments);
3314
- this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
3315
- logContext: 'confirmPendingVoucherPayments'
3316
- }));
3317
- // this.recalculateSummary();
3318
- return tempOrder.payments;
3319
- }
3320
- }, {
3321
- key: "discardPendingVoucherPayments",
3322
- value: function discardPendingVoucherPayments(options) {
3323
- var tempOrder = this.ensureTempOrder();
3324
- var payments = tempOrder.payments || [];
3325
- var nextPayments = this.discardPendingVoucherPaymentsFromList(payments);
3326
- if (nextPayments.length === payments.length) return payments;
3327
- tempOrder.payments = nextPayments;
3328
- this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
3329
- logContext: 'discardPendingVoucherPayments'
3330
- }));
3331
- return tempOrder.payments;
3332
- }
3333
3087
 
3334
3088
  /**
3335
3089
  * 覆盖当前订单中的 wallet pass 支付项。
@@ -3339,92 +3093,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3339
3093
  */
3340
3094
  }, {
3341
3095
  key: "updateVoucherOrderPayments",
3342
- value: function updateVoucherOrderPayments(payments, options) {
3343
- var _this21 = this;
3096
+ value: function updateVoucherOrderPayments(payments) {
3097
+ var _this19 = this;
3344
3098
  var tempOrder = this.ensureTempOrder();
3345
- var isOrderPaymentType = function isOrderPaymentType(value) {
3346
- return value === 'normal' || value === 'deposit';
3347
- };
3348
- var voucherOrderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
3349
- var withVoucherPaymentType = function withVoucherPaymentType(payment) {
3350
- var paymentRecord = payment;
3351
- if (!isVoucherPaymentRecord(paymentRecord)) return payment;
3352
- var explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : undefined;
3353
- var nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
3354
- var shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === undefined && paymentRecord.type !== undefined && !isOrderPaymentType(paymentRecord.type);
3355
- return _objectSpread(_objectSpread(_objectSpread({}, paymentRecord), shouldPreserveCustomPaymentType ? {
3356
- custom_payment_type: paymentRecord.type
3357
- } : {}), {}, {
3358
- type: nextPaymentType,
3359
- order_payment_type: nextPaymentType
3360
- });
3099
+ var isVoucherPayment = function isVoucherPayment(payment) {
3100
+ return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
3361
3101
  };
3362
- var normalizeVoucherPaymentStatus = function normalizeVoucherPaymentStatus(payment) {
3363
- var paymentRecord = payment;
3364
- if (!isVoucherPaymentRecord(paymentRecord)) return payment;
3365
- if (hasSyncedOrderPaymentRecord(paymentRecord) && (paymentRecord.status === undefined || paymentRecord.status === 'active')) {
3366
- return _objectSpread(_objectSpread({}, paymentRecord), {}, {
3367
- status: ORDER_PAYMENT_STATUS_PAID
3368
- });
3369
- }
3370
- if (paymentRecord.status !== undefined && paymentRecord.status !== 'active') {
3371
- return payment;
3372
- }
3373
- return _objectSpread(_objectSpread({}, paymentRecord), {}, {
3374
- status: (options === null || options === void 0 ? void 0 : options.status) || ORDER_PAYMENT_STATUS_PENDING
3375
- });
3102
+ var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
3103
+ return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
3376
3104
  };
3105
+ // const normalizeVoucherPaymentStatus = (payment: OrderPaymentSource): OrderPaymentSource => {
3106
+ // const paymentRecord = payment as Record<string, any>;
3107
+ // // if (paymentRecord.status !== 'active') return payment;
3108
+ // // return {
3109
+ // // ...paymentRecord,
3110
+ // // status: 'paid',
3111
+ // // };
3112
+ // if (paymentRecord.status === 'active') {
3113
+ // paymentRecord.status = 'paid'
3114
+ // }
3115
+ // return paymentRecord
3116
+ // };
3377
3117
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3378
- return _this21.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3379
- defaultPaid: false
3118
+ return _this19.normalizePaymentSource(payment, {
3119
+ defaultPaid: true
3380
3120
  });
3381
3121
  })).filter(function (payment) {
3382
- return isVoucherPaymentRecord(payment);
3122
+ return isVoucherPayment(payment);
3383
3123
  });
3384
3124
  var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3385
- return !isVoucherPaymentRecord(payment);
3125
+ return !isVoucherPayment(payment);
3386
3126
  });
3387
- var normalizeCommittedVoucherPayment = function normalizeCommittedVoucherPayment(payment) {
3388
- if (hasSyncedOrderPaymentRecord(payment) && (payment.status === undefined || payment.status === 'active')) {
3389
- return _objectSpread(_objectSpread({}, payment), {}, {
3390
- status: ORDER_PAYMENT_STATUS_PAID
3391
- });
3392
- }
3393
- return payment;
3394
- };
3395
- var committedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3396
- return isCommittedVoucherPaymentRecord(payment);
3397
- }).map(function (payment) {
3398
- return normalizeCommittedVoucherPayment(payment);
3127
+ var syncedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3128
+ return isVoucherPayment(payment) && hasSyncedOrderPayment(payment);
3399
3129
  });
3400
- var committedVoucherPaymentIds = new Set(committedVoucherPayments.filter(function (payment) {
3401
- return hasSyncedOrderPaymentRecord(payment);
3402
- }).map(function (payment) {
3130
+ var syncedVoucherPaymentIds = new Set(syncedVoucherPayments.map(function (payment) {
3403
3131
  return String(payment.order_payment_id);
3404
3132
  }));
3405
- var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
3406
- return String(payment.voucher_id);
3407
- }));
3408
3133
  var replaceableVouchers = mappedVouchers.filter(function (payment) {
3409
- if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
3410
- return false;
3411
- }
3412
- if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
3413
- return false;
3414
- }
3415
- return true;
3134
+ if (!hasSyncedOrderPayment(payment)) return true;
3135
+ return !syncedVoucherPaymentIds.has(String(payment.order_payment_id));
3416
3136
  });
3417
3137
  var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
3418
3138
  vouchers: replaceableVouchers,
3419
- nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments))
3139
+ nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments))
3420
3140
  });
3421
- tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments), _toConsumableArray(cappedVouchers));
3141
+ tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments), _toConsumableArray(cappedVouchers));
3422
3142
  this.updateTempOrderPaymentStatus(tempOrder);
3423
3143
  this.persistTempOrder();
3424
3144
  void this.recalculateSummary({
3425
3145
  createIfMissing: true
3426
3146
  }).catch(function (error) {
3427
- _this21.logError('recalculate summary after updateVoucherOrderPayments failed', {
3147
+ _this19.logError('recalculate summary after updateVoucherOrderPayments failed', {
3428
3148
  error: error instanceof Error ? error.message : String(error)
3429
3149
  });
3430
3150
  });
@@ -3491,8 +3211,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3491
3211
  }, {
3492
3212
  key: "hasLinkedBookingUid",
3493
3213
  value: function hasLinkedBookingUid(product) {
3494
- var _product$booking_uid, _product$metadata9;
3495
- var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
3214
+ var _product$booking_uid, _product$metadata7;
3215
+ var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid;
3496
3216
  return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
3497
3217
  }
3498
3218
 
@@ -3560,7 +3280,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3560
3280
  var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3561
3281
  var _booking_uid,
3562
3282
  _metadata,
3563
- _this22 = this;
3283
+ _this20 = this;
3564
3284
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3565
3285
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3566
3286
  while (1) switch (_context18.prev = _context18.next) {
@@ -3585,8 +3305,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3585
3305
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3586
3306
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3587
3307
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3588
- if (_this22.hasGoodPassDiscount(item)) return false;
3589
- if (_this22.hasOrderProductLineNote(item)) return false;
3308
+ if (_this20.hasGoodPassDiscount(item)) return false;
3309
+ if (_this20.hasOrderProductLineNote(item)) return false;
3590
3310
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3591
3311
  if (item.product_id !== productToAdd.product_id) return false;
3592
3312
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -3692,52 +3412,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3692
3412
  key: "addProductToOrder",
3693
3413
  value: (function () {
3694
3414
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3695
- var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3415
+ var tempOrder, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
3696
3416
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3697
3417
  while (1) switch (_context19.prev = _context19.next) {
3698
3418
  case 0:
3699
3419
  tempOrder = this.ensureTempOrder();
3420
+ debugger;
3700
3421
  if (!booking) {
3701
- _context19.next = 18;
3422
+ _context19.next = 19;
3702
3423
  break;
3703
3424
  }
3704
3425
  productRecord = product;
3705
- splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3426
+ splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
3706
3427
  if (!(splitCount > 1)) {
3707
- _context19.next = 18;
3428
+ _context19.next = 19;
3708
3429
  break;
3709
3430
  }
3710
3431
  i = 0;
3711
- case 6:
3432
+ case 7:
3712
3433
  if (!(i < splitCount)) {
3713
- _context19.next = 15;
3434
+ _context19.next = 16;
3714
3435
  break;
3715
3436
  }
3716
3437
  singleLine = cloneDeep(productRecord);
3717
3438
  singleLine.num = 1;
3718
3439
  delete singleLine.product_quantity;
3719
- _context19.next = 12;
3440
+ _context19.next = 13;
3720
3441
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3721
- case 12:
3442
+ case 13:
3722
3443
  i += 1;
3723
- _context19.next = 6;
3444
+ _context19.next = 7;
3724
3445
  break;
3725
- case 15:
3726
- _context19.next = 17;
3446
+ case 16:
3447
+ _context19.next = 18;
3727
3448
  return this.finalizeProductOrderMutation(tempOrder);
3728
- case 17:
3729
- return _context19.abrupt("return", tempOrder.products);
3730
3449
  case 18:
3731
- _context19.next = 20;
3450
+ return _context19.abrupt("return", tempOrder.products);
3451
+ case 19:
3452
+ _context19.next = 21;
3732
3453
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3733
- case 20:
3734
- _context19.next = 22;
3454
+ case 21:
3455
+ _context19.next = 23;
3735
3456
  return this.finalizeProductOrderMutation(tempOrder);
3736
- case 22:
3737
- this.logInfo('addProductToOrder success', {
3738
- product_id: product.product_id,
3739
- with_booking: !!booking
3740
- });
3457
+ case 23:
3741
3458
  return _context19.abrupt("return", tempOrder.products);
3742
3459
  case 24:
3743
3460
  case "end":
@@ -3764,7 +3481,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3764
3481
  key: "addProductsToOrder",
3765
3482
  value: (function () {
3766
3483
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3767
- var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3484
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine;
3768
3485
  return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3769
3486
  while (1) switch (_context20.prev = _context20.next) {
3770
3487
  case 0:
@@ -3796,7 +3513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3796
3513
  break;
3797
3514
  }
3798
3515
  productRecord = product;
3799
- splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3516
+ splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3800
3517
  if (!(splitCount > 1)) {
3801
3518
  _context20.next = 26;
3802
3519
  break;
@@ -3839,11 +3556,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3839
3556
  _context20.next = 40;
3840
3557
  return this.finalizeProductOrderMutation(tempOrder, options);
3841
3558
  case 40:
3842
- this.logInfo('addProductsToOrder success', {
3843
- itemsCount: items.length
3844
- });
3845
3559
  return _context20.abrupt("return", tempOrder.products);
3846
- case 42:
3560
+ case 41:
3847
3561
  case "end":
3848
3562
  return _context20.stop();
3849
3563
  }
@@ -3876,24 +3590,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3876
3590
  }, {
3877
3591
  key: "getBundleRuntimeIdentity",
3878
3592
  value: function getBundleRuntimeIdentity(bundle) {
3879
- var _ref63, _bundle$bundle_id2, _ref64, _bundle$bundle_group_2, _ref65, _ref66, _bundle$bundle_produc3, _ref67, _bundle$bundle_varian3;
3593
+ var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
3880
3594
  if (!bundle || _typeof(bundle) !== 'object') return '';
3881
- return [(_ref63 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref65 = (_ref66 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle.product_id) !== null && _ref65 !== void 0 ? _ref65 : '', (_ref67 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref67 !== void 0 ? _ref67 : 0].join('|');
3595
+ return [(_ref62 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_ref65 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref65 !== void 0 ? _ref65 : bundle.product_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref66 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref66 !== void 0 ? _ref66 : 0].join('|');
3882
3596
  }
3883
3597
  }, {
3884
3598
  key: "preservePersistedBundlePriceFields",
3885
3599
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3886
- var _this23 = this;
3600
+ var _this21 = this;
3887
3601
  if (!Array.isArray(nextBundles)) return nextBundles;
3888
3602
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3889
3603
  var previousByIdentity = new Map();
3890
3604
  previousBundles.forEach(function (bundle) {
3891
- var identity = _this23.getBundleRuntimeIdentity(bundle);
3605
+ var identity = _this21.getBundleRuntimeIdentity(bundle);
3892
3606
  if (identity) previousByIdentity.set(identity, bundle);
3893
3607
  });
3894
3608
  return nextBundles.map(function (bundle, index) {
3895
3609
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3896
- var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3610
+ var previous = previousByIdentity.get(_this21.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3897
3611
  if (!previous || _typeof(previous) !== 'object') return bundle;
3898
3612
  return _objectSpread(_objectSpread({}, bundle), {}, {
3899
3613
  price: previous.price,
@@ -4061,11 +3775,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4061
3775
  });
4062
3776
  case 8:
4063
3777
  this.persistTempOrder();
4064
- this.logInfo('updateOrderProduct success', {
4065
- params: params
4066
- });
4067
3778
  return _context21.abrupt("return", tempOrder.products);
4068
- case 11:
3779
+ case 10:
4069
3780
  case "end":
4070
3781
  return _context21.stop();
4071
3782
  }
@@ -4080,7 +3791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4080
3791
  key: "updateOrderProducts",
4081
3792
  value: function () {
4082
3793
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4083
- var _this24 = this;
3794
+ var _this22 = this;
4084
3795
  var tempOrder;
4085
3796
  return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4086
3797
  while (1) switch (_context22.prev = _context22.next) {
@@ -4093,16 +3804,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4093
3804
  return _context22.abrupt("return", tempOrder.products);
4094
3805
  case 3:
4095
3806
  paramsList.forEach(function (params) {
4096
- _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
3807
+ _this22.applyOrderProductUpdateToTempOrder(tempOrder, params);
4097
3808
  });
4098
3809
  _context22.next = 6;
4099
3810
  return this.finalizeAfterProductsMutation(tempOrder);
4100
3811
  case 6:
4101
- this.logInfo('updateOrderProduct success', {
4102
- paramsList: paramsList
4103
- });
4104
3812
  return _context22.abrupt("return", tempOrder.products);
4105
- case 8:
3813
+ case 7:
4106
3814
  case "end":
4107
3815
  return _context22.stop();
4108
3816
  }
@@ -4174,11 +3882,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4174
3882
  });
4175
3883
  case 22:
4176
3884
  this.persistTempOrder();
4177
- this.logInfo('updateOrderProductQuantity success', {
4178
- params: params
4179
- });
4180
3885
  return _context23.abrupt("return", tempOrder.products);
4181
- case 25:
3886
+ case 24:
4182
3887
  case "end":
4183
3888
  return _context23.stop();
4184
3889
  }
@@ -4263,7 +3968,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4263
3968
  key: "removeProductsFromOrder",
4264
3969
  value: (function () {
4265
3970
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4266
- var _this25 = this;
3971
+ var _this23 = this;
4267
3972
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4268
3973
  return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4269
3974
  while (1) switch (_context26.prev = _context26.next) {
@@ -4318,7 +4023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4318
4023
  }
4319
4024
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4320
4025
  bookingsBeforeRemove.forEach(function (booking) {
4321
- var bookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
4026
+ var bookingUid = _this23.getBookingUniqueIdentificationNumber(booking);
4322
4027
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4323
4028
  linkedBookingUidsToRemove.add(bookingUid);
4324
4029
  }
@@ -4370,11 +4075,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4370
4075
  _context26.next = 31;
4371
4076
  return this.finalizeAfterProductsMutation(tempOrder);
4372
4077
  case 31:
4373
- this.logInfo('removeProductsFromOrder success', {
4374
- identities: identities
4375
- });
4376
4078
  return _context26.abrupt("return", tempOrder.products);
4377
- case 33:
4079
+ case 32:
4378
4080
  case "end":
4379
4081
  return _context26.stop();
4380
4082
  }
@@ -4436,9 +4138,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4436
4138
  });
4437
4139
  case 11:
4438
4140
  this.persistTempOrder();
4439
- this.logInfo('clearOrderCartLines success', {});
4440
4141
  return _context28.abrupt("return", tempOrder);
4441
- case 14:
4142
+ case 13:
4442
4143
  case "end":
4443
4144
  return _context28.stop();
4444
4145
  }
@@ -4453,23 +4154,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4453
4154
  }, {
4454
4155
  key: "buildCurrentSubmitPayloadForLocalPrint",
4455
4156
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4456
- var _params$cacheId, _this$otherParams3, _ref68, _params$businessCode, _this$otherParams4, _this$otherParams5;
4157
+ var _params$cacheId, _this$otherParams2, _ref67, _params$businessCode, _this$otherParams3, _this$otherParams4;
4457
4158
  var tempOrder = this.ensureTempOrder();
4458
4159
  this.persistTempOrder();
4459
4160
  var payload = buildSubmitPayload({
4460
4161
  tempOrder: tempOrder,
4461
4162
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4462
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
4463
- businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4163
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
4164
+ businessCode: (_ref67 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref67 !== void 0 ? _ref67 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
4464
4165
  channel: params === null || params === void 0 ? void 0 : params.channel,
4465
4166
  type: params === null || params === void 0 ? void 0 : params.type,
4466
4167
  summary: this.store.summary || createEmptySummary(),
4467
4168
  enhance: function enhance(nextPayload) {
4468
- var _ref69, _tempOrder$order_numb, _ref70, _tempOrder$shop_order, _ref71, _tempOrder$shop_full_;
4169
+ var _ref68, _tempOrder$order_numb, _ref69, _tempOrder$shop_order, _ref70, _tempOrder$shop_full_;
4469
4170
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4470
- order_number: (_ref69 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
4471
- shop_order_number: (_ref70 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4472
- shop_full_order_number: (_ref71 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4171
+ order_number: (_ref68 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
4172
+ shop_order_number: (_ref69 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
4173
+ shop_full_order_number: (_ref70 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4473
4174
  small_ticket_data_flag: 1
4474
4175
  });
4475
4176
  }
@@ -4566,56 +4267,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4566
4267
  key: "runSubmitTempOrder",
4567
4268
  value: function () {
4568
4269
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4569
- var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4570
- var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4270
+ var _params$cacheId2, _this$otherParams5, _ref71, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4271
+ var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4571
4272
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4572
4273
  while (1) switch (_context32.prev = _context32.next) {
4573
4274
  case 0:
4574
4275
  tempOrder = this.ensureTempOrder();
4575
- shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
4576
- hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
4577
- preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments) : undefined;
4578
- if (!hasPaymentOverride) {
4579
- if (shouldConfirmPendingVoucherPayments) {
4580
- this.confirmPendingVoucherPayments({
4581
- persist: false,
4582
- recalculateSummary: false
4583
- });
4584
- } else {
4585
- this.discardPendingVoucherPayments({
4586
- persist: false,
4587
- recalculateSummary: false
4588
- });
4589
- }
4590
- }
4591
4276
  this.persistTempOrder();
4592
- _context32.next = 8;
4277
+ _context32.next = 4;
4593
4278
  return this.recalculateSummary({
4594
4279
  createIfMissing: true
4595
4280
  });
4596
- case 8:
4281
+ case 4:
4597
4282
  _context32.t1 = _context32.sent;
4598
4283
  if (_context32.t1) {
4599
- _context32.next = 11;
4284
+ _context32.next = 7;
4600
4285
  break;
4601
4286
  }
4602
4287
  _context32.t1 = this.store.summary;
4603
- case 11:
4288
+ case 7:
4604
4289
  _context32.t0 = _context32.t1;
4605
4290
  if (_context32.t0) {
4606
- _context32.next = 14;
4291
+ _context32.next = 10;
4607
4292
  break;
4608
4293
  }
4609
4294
  _context32.t0 = createEmptySummary();
4610
- case 14:
4295
+ case 10:
4611
4296
  latestSummary = _context32.t0;
4612
4297
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4298
+ hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
4613
4299
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4614
4300
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
4615
4301
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
4616
4302
  var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
4617
- payments: preparedPaymentOverride || []
4618
- } : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
4303
+ payments: mapPaymentItemsToOrderPayments((params === null || params === void 0 ? void 0 : params.payments) || [])
4304
+ } : {}), hasPaymentStatusOverride ? {
4619
4305
  payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
4620
4306
  } : {}), hasSmallTicketDataFlagOverride ? {
4621
4307
  small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
@@ -4623,19 +4309,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4623
4309
  var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
4624
4310
  return enhancedPayload;
4625
4311
  } : undefined;
4626
- submitSnapshot = this.getLastOrderSubmitSnapshot();
4627
4312
  payload = buildSubmitPayload({
4628
4313
  tempOrder: tempOrder,
4629
4314
  cacheId: effectiveCacheId,
4630
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4631
- businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4315
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
4316
+ businessCode: (_ref71 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4632
4317
  channel: params === null || params === void 0 ? void 0 : params.channel,
4633
- type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4318
+ type: params === null || params === void 0 ? void 0 : params.type,
4634
4319
  summary: latestSummary,
4635
4320
  request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
4636
4321
  enhance: enhancePayload
4637
4322
  });
4638
- console.log('[Order.runSubmitTempOrder.payload]', payload);
4639
4323
  if (params !== null && params !== void 0 && params.syncMode) {
4640
4324
  payload.sync_mode = true;
4641
4325
  }
@@ -4643,10 +4327,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4643
4327
  if (!payload.created_at) {
4644
4328
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4645
4329
  }
4646
- _context32.next = 26;
4330
+ _context32.next = 21;
4647
4331
  return this.saveDraft();
4648
- case 26:
4649
- _context32.prev = 26;
4332
+ case 21:
4333
+ _context32.prev = 21;
4650
4334
  this.logInfo('submitTempOrder calling sales checkout', {
4651
4335
  orderId: payload.order_id,
4652
4336
  externalSaleNumber: payload.external_sale_number,
@@ -4656,26 +4340,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4656
4340
  smallTicketDataFlag: payload.small_ticket_data_flag,
4657
4341
  syncMode: payload.sync_mode
4658
4342
  });
4659
- _context32.next = 30;
4343
+ _context32.next = 25;
4660
4344
  return this.submitSalesOrder({
4661
4345
  query: payload
4662
4346
  });
4663
- case 30:
4347
+ case 25:
4664
4348
  result = _context32.sent;
4665
- _context32.next = 43;
4349
+ _context32.next = 38;
4666
4350
  break;
4667
- case 33:
4668
- _context32.prev = 33;
4669
- _context32.t2 = _context32["catch"](26);
4351
+ case 28:
4352
+ _context32.prev = 28;
4353
+ _context32.t2 = _context32["catch"](21);
4670
4354
  backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4671
4355
  if (!backendErrorResponse) {
4672
- _context32.next = 40;
4356
+ _context32.next = 35;
4673
4357
  break;
4674
4358
  }
4675
4359
  this.store.syncState = 'failed';
4676
4360
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4677
4361
  return _context32.abrupt("return", backendErrorResponse);
4678
- case 40:
4362
+ case 35:
4679
4363
  this.store.syncState = 'failed';
4680
4364
  this.logError('submitTempOrder failed', {
4681
4365
  error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
@@ -4685,47 +4369,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4685
4369
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4686
4370
  });
4687
4371
  throw _context32.t2;
4688
- case 43:
4372
+ case 38:
4689
4373
  if (!this.isSubmitResponseRejected(result)) {
4690
- _context32.next = 47;
4374
+ _context32.next = 42;
4691
4375
  break;
4692
4376
  }
4693
4377
  this.store.syncState = 'failed';
4694
4378
  this.logSubmitBackendRejected(result, payload);
4695
4379
  return _context32.abrupt("return", result);
4696
- case 47:
4380
+ case 42:
4697
4381
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4698
4382
  this.logInfo('runSubmitTempOrder: 提交成功', {
4699
4383
  submittedOrderId: submittedOrderId,
4700
4384
  result: result,
4701
- tempOrder: _objectSpread(_objectSpread({}, tempOrder), {}, {
4702
- _extend: undefined
4703
- })
4385
+ tempOrder: tempOrder
4704
4386
  });
4705
4387
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4706
- _context32.next = 56;
4388
+ _context32.next = 51;
4707
4389
  break;
4708
4390
  }
4709
4391
  tempOrder.order_id = submittedOrderId;
4710
4392
  resultRecord = result;
4711
- _context32.next = 54;
4393
+ _context32.next = 49;
4712
4394
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4713
- case 54:
4714
- _context32.next = 57;
4395
+ case 49:
4396
+ _context32.next = 52;
4715
4397
  break;
4716
- case 56:
4398
+ case 51:
4717
4399
  if (this.isLocalPendingSubmitResult(result)) {
4718
4400
  this.store.syncState = 'local';
4719
4401
  } else {
4720
4402
  this.store.syncState = 'submitted';
4721
4403
  }
4722
- case 57:
4404
+ case 52:
4723
4405
  return _context32.abrupt("return", result);
4724
- case 58:
4406
+ case 53:
4725
4407
  case "end":
4726
4408
  return _context32.stop();
4727
4409
  }
4728
- }, _callee29, this, [[26, 33]]);
4410
+ }, _callee29, this, [[21, 28]]);
4729
4411
  }));
4730
4412
  function runSubmitTempOrder(_x32) {
4731
4413
  return _runSubmitTempOrder.apply(this, arguments);
@@ -4797,10 +4479,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4797
4479
  value: function extractSubmitErrorResponse(error) {
4798
4480
  var _error$response,
4799
4481
  _error$response2,
4800
- _this26 = this;
4482
+ _this24 = this;
4801
4483
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4802
4484
  return candidates.find(function (candidate) {
4803
- return _this26.isSubmitErrorResponse(candidate);
4485
+ return _this24.isSubmitErrorResponse(candidate);
4804
4486
  }) || null;
4805
4487
  }
4806
4488
  }, {
@@ -4828,46 +4510,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4828
4510
  key: "syncPaymentsToOrder",
4829
4511
  value: function () {
4830
4512
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4831
- var _params$confirmPendin;
4832
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4513
+ var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4833
4514
  return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4834
4515
  while (1) switch (_context34.prev = _context34.next) {
4835
4516
  case 0:
4836
4517
  tempOrder = this.ensureTempOrder();
4837
4518
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
4838
- shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
4839
- effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
4840
- completion = this.getPaymentCompletion(effectivePayments);
4841
- paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
4842
- paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4843
- tempOrder.payments = effectivePayments;
4519
+ paymentTotal = this.calculatePaymentTotal(mappedPayments);
4520
+ targetAmount = this.getPaymentTargetAmount();
4521
+ isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
4522
+ paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
4523
+ tempOrder.payments = mappedPayments;
4844
4524
  tempOrder.payment_status = paymentStatus;
4845
4525
  this.persistTempOrder();
4846
- _context34.next = 12;
4526
+ _context34.next = 11;
4847
4527
  return this.saveDraft();
4848
- case 12:
4528
+ case 11:
4849
4529
  if (params.submitWhenPaid) {
4850
- _context34.next = 14;
4530
+ _context34.next = 13;
4851
4531
  break;
4852
4532
  }
4853
- return _context34.abrupt("return", completion);
4854
- case 14:
4533
+ return _context34.abrupt("return", {
4534
+ isFullyPaid: isFullyPaid
4535
+ });
4536
+ case 13:
4855
4537
  if (!(this.store.syncState === 'submitting')) {
4856
- _context34.next = 16;
4538
+ _context34.next = 15;
4857
4539
  break;
4858
4540
  }
4859
- return _context34.abrupt("return", completion);
4860
- case 16:
4541
+ return _context34.abrupt("return", {
4542
+ isFullyPaid: isFullyPaid
4543
+ });
4544
+ case 15:
4861
4545
  this.store.syncState = 'submitting';
4862
- paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4863
- _context34.next = 20;
4546
+ paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4547
+ _context34.next = 19;
4864
4548
  return this.submitTempOrder({
4865
- payments: effectivePayments,
4549
+ payments: mappedPayments,
4866
4550
  paymentStatus: paymentStatus,
4867
4551
  smallTicketDataFlag: params.smallTicketDataFlag,
4868
4552
  businessCode: params.businessCode,
4869
4553
  channel: params.channel,
4870
- confirmPendingVoucherPayments: true,
4871
4554
  enhancePayload: function enhancePayload(payload) {
4872
4555
  var nextPayload = _objectSpread(_objectSpread({}, payload), {}, {
4873
4556
  request_unique_idempotency_token: paymentSyncIdempotencyToken
@@ -4875,12 +4558,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4875
4558
  return nextPayload;
4876
4559
  }
4877
4560
  });
4878
- case 20:
4561
+ case 19:
4879
4562
  submitResult = _context34.sent;
4880
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4563
+ return _context34.abrupt("return", {
4564
+ isFullyPaid: isFullyPaid,
4881
4565
  submitResult: submitResult
4882
- }));
4883
- case 22:
4566
+ });
4567
+ case 21:
4884
4568
  case "end":
4885
4569
  return _context34.stop();
4886
4570
  }
@@ -5385,7 +5069,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5385
5069
  products: cloneDeep(nextTempOrder.products || []),
5386
5070
  payments: cloneDeep(nextTempOrder.payments || []),
5387
5071
  surcharges: cloneDeep(nextTempOrder.surcharges || []),
5388
- shop_discount: nextTempOrder.shop_discount || '0.00',
5389
5072
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5390
5073
  }
5391
5074
  });
@@ -5394,28 +5077,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5394
5077
  currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5395
5078
  shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5396
5079
  if (shouldSkipEmptyDiscountSync) {
5397
- _context42.next = 17;
5080
+ _context42.next = 16;
5398
5081
  break;
5399
5082
  }
5400
- OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
5401
- _context42.next = 15;
5083
+ _context42.next = 14;
5402
5084
  return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5403
- case 15:
5404
- _context42.next = 17;
5085
+ case 14:
5086
+ _context42.next = 16;
5405
5087
  return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5406
- case 17:
5088
+ case 16:
5407
5089
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5408
- _context42.next = 20;
5090
+ _context42.next = 19;
5409
5091
  break;
5410
5092
  }
5411
- _context42.next = 20;
5093
+ _context42.next = 19;
5412
5094
  return this.recalculateSummary({
5413
5095
  createIfMissing: false
5414
5096
  });
5415
- case 20:
5097
+ case 19:
5416
5098
  this.persistTempOrder();
5417
5099
  return _context42.abrupt("return", nextTempOrder);
5418
- case 22:
5100
+ case 21:
5419
5101
  case "end":
5420
5102
  return _context42.stop();
5421
5103
  }
@@ -5462,7 +5144,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5462
5144
  }, {
5463
5145
  key: "normalizeTempOrderForRuntime",
5464
5146
  value: function normalizeTempOrderForRuntime(raw, options) {
5465
- var _this27 = this;
5147
+ var _this25 = this;
5466
5148
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5467
5149
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5468
5150
  if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
@@ -5485,10 +5167,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5485
5167
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5486
5168
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5487
5169
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5488
- return _this27.normalizeHydratedOrderProduct(p);
5170
+ return _this25.normalizeHydratedOrderProduct(p);
5489
5171
  }) : [];
5490
5172
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5491
- var booking = _this27.normalizeHydratedBookingHolder(b || {});
5173
+ var booking = _this25.normalizeHydratedBookingHolder(b || {});
5492
5174
  return _objectSpread(_objectSpread({}, booking), {}, {
5493
5175
  is_all: normalizeBookingIsAll(booking),
5494
5176
  sub_type: normalizeBookingSubType(booking)
@@ -5518,15 +5200,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5518
5200
  _step22;
5519
5201
  try {
5520
5202
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5521
- var _product$metadata10, _ref74, _ref75, _existed$origin, _rawProduct$metadata;
5203
+ var _product$metadata8, _ref72, _ref73, _existed$origin, _rawProduct$metadata;
5522
5204
  var _step22$value = _slicedToArray(_step22.value, 2),
5523
5205
  index = _step22$value[0],
5524
5206
  product = _step22$value[1];
5525
- var uid = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number;
5207
+ var uid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
5526
5208
  if (!uid) continue;
5527
5209
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5528
5210
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5529
- var origin = (_ref74 = (_ref75 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref75 !== void 0 ? _ref75 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref74 !== void 0 ? _ref74 : rawProduct;
5211
+ var origin = (_ref72 = (_ref73 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref73 !== void 0 ? _ref73 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref72 !== void 0 ? _ref72 : rawProduct;
5530
5212
  var originSnapshot = cloneDeep(origin);
5531
5213
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5532
5214
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5560,8 +5242,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5560
5242
  var bookingUidByProductUid = new Map();
5561
5243
  var productByUid = new Map();
5562
5244
  (tempOrder.products || []).forEach(function (product) {
5563
- var _product$metadata11;
5564
- var productUid = (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5245
+ var _product$metadata9;
5246
+ var productUid = (product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5565
5247
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
5566
5248
  productByUid.set(String(productUid), product);
5567
5249
  }
@@ -5582,8 +5264,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5582
5264
  bookingUidByProductUid.set(String(productUid), bookingUid);
5583
5265
  });
5584
5266
  (tempOrder.products || []).forEach(function (product) {
5585
- var _product$metadata12;
5586
- var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5267
+ var _product$metadata10;
5268
+ var productUid = (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5587
5269
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
5588
5270
  var bookingUid = bookingUidByProductUid.get(String(productUid));
5589
5271
  if (!bookingUid) return;
@@ -5594,7 +5276,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5594
5276
  product.booking_uid = linkedBookingUid;
5595
5277
  product.metadata.booking_uid = linkedBookingUid;
5596
5278
  });
5597
- this.syncLinkedBookingHoldersToProducts(tempOrder);
5598
5279
  }
5599
5280
  }, {
5600
5281
  key: "pickHydratedDisplayText",
@@ -5637,10 +5318,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5637
5318
  }, {
5638
5319
  key: "normalizeHydratedProductOptionItem",
5639
5320
  value: function normalizeHydratedProductOptionItem(optionItem) {
5640
- var _ref76, _optionItem$num, _ref77, _optionItem$add_price;
5641
- var rawNum = (_ref76 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref76 !== void 0 ? _ref76 : 1;
5321
+ var _ref74, _optionItem$num, _ref75, _optionItem$add_price;
5322
+ var rawNum = (_ref74 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref74 !== void 0 ? _ref74 : 1;
5642
5323
  var parsedNum = Number(rawNum);
5643
- var rawPrice = (_ref77 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref77 !== void 0 ? _ref77 : 0;
5324
+ var rawPrice = (_ref75 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref75 !== void 0 ? _ref75 : 0;
5644
5325
  var parsedPrice = Number(rawPrice);
5645
5326
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5646
5327
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -5657,7 +5338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5657
5338
  }, {
5658
5339
  key: "normalizeHydratedOrderProduct",
5659
5340
  value: function normalizeHydratedOrderProduct(product) {
5660
- var _this28 = this;
5341
+ var _this26 = this;
5661
5342
  var row = _objectSpread({}, product || {});
5662
5343
  if (row.num === undefined && row.product_quantity !== undefined) {
5663
5344
  row.num = row.product_quantity;
@@ -5665,7 +5346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5665
5346
  var productSku = ensureProductSku(row);
5666
5347
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5667
5348
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5668
- return _this28.normalizeHydratedProductOptionItem(optionItem || {});
5349
+ return _this26.normalizeHydratedProductOptionItem(optionItem || {});
5669
5350
  }))
5670
5351
  });
5671
5352
  delete row["product_".concat('option', "_item")];
@@ -5674,7 +5355,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5674
5355
  if (row.booking_uid && !row.metadata.booking_uid) {
5675
5356
  row.metadata.booking_uid = row.booking_uid;
5676
5357
  }
5677
- row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
5678
5358
  var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
5679
5359
  if (!existingIdentity) {
5680
5360
  row.metadata.unique_identification_number = createUuidV4();
@@ -5686,8 +5366,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5686
5366
  metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
5687
5367
  });
5688
5368
  if (result.metadata) delete result.metadata.price_schema_version;
5689
- var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
5690
- return this.sanitizeOrderProductForTempOrder(restored);
5369
+ return this.sanitizeOrderProductForTempOrder(result);
5691
5370
  }
5692
5371
  }, {
5693
5372
  key: "getLastOrderInfo",
@@ -5723,12 +5402,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5723
5402
  }
5724
5403
  return getOrderInfo;
5725
5404
  }()
5726
- }, {
5727
- key: "getVouchers",
5728
- value: function getVouchers() {
5729
- var _this$store$tempOrder5;
5730
- return ((_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.vouchers) || [];
5731
- }
5732
5405
  }], [{
5733
5406
  key: "populateSavedAmounts",
5734
5407
  value: function populateSavedAmounts(productList, discountList) {
@@ -5777,10 +5450,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5777
5450
  _step27;
5778
5451
  try {
5779
5452
  for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5780
- var _ref78, _bundle$num3;
5453
+ var _ref76, _bundle$num3;
5781
5454
  var bundle = _step27.value;
5782
5455
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
5783
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref78 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1) || 1).toNumber();
5456
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref76 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref76 !== void 0 ? _ref76 : 1) || 1).toNumber();
5784
5457
  var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5785
5458
  _step28;
5786
5459
  try {