@pisell/pisellos 2.2.258 → 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 (90) 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 +2 -30
  15. package/dist/modules/Order/index.js +241 -508
  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/server/index.d.ts +50 -3
  28. package/dist/server/index.js +958 -1000
  29. package/dist/server/modules/order/index.d.ts +3 -22
  30. package/dist/server/modules/order/index.js +314 -397
  31. package/dist/server/modules/products/index.d.ts +26 -7
  32. package/dist/server/modules/products/index.js +166 -76
  33. package/dist/server/modules/products/types.d.ts +14 -0
  34. package/dist/solution/BaseSales/index.d.ts +2 -16
  35. package/dist/solution/BaseSales/index.js +314 -484
  36. package/dist/solution/BaseSales/types.d.ts +0 -1
  37. package/dist/solution/BaseSales/types.js +1 -2
  38. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
  39. package/dist/solution/BookingByStep/index.d.ts +1 -1
  40. package/dist/solution/BookingTicket/index.d.ts +1 -9
  41. package/dist/solution/BookingTicket/index.js +6 -162
  42. package/dist/solution/BookingTicket/types.d.ts +2 -0
  43. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  44. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  46. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  48. package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  50. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  52. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  53. package/lib/model/strategy/adapter/index.d.ts +4 -0
  54. package/lib/model/strategy/adapter/index.js +13 -2
  55. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  56. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
  57. package/lib/modules/Order/index.d.ts +2 -30
  58. package/lib/modules/Order/index.js +57 -340
  59. package/lib/modules/Order/types.d.ts +2 -20
  60. package/lib/modules/Order/utils.d.ts +0 -4
  61. package/lib/modules/Order/utils.js +2 -84
  62. package/lib/modules/Product/index.d.ts +1 -1
  63. package/lib/modules/Product/types.d.ts +22 -0
  64. package/lib/modules/ProductList/index.d.ts +1 -1
  65. package/lib/modules/ProductList/index.js +4 -2
  66. package/lib/modules/ProductList/types.d.ts +2 -0
  67. package/lib/modules/Rules/index.d.ts +3 -3
  68. package/lib/modules/Rules/index.js +3 -4
  69. package/lib/modules/Rules/types.d.ts +1 -2
  70. package/lib/server/index.d.ts +50 -3
  71. package/lib/server/index.js +215 -230
  72. package/lib/server/modules/order/index.d.ts +3 -22
  73. package/lib/server/modules/order/index.js +51 -102
  74. package/lib/server/modules/products/index.d.ts +26 -7
  75. package/lib/server/modules/products/index.js +113 -35
  76. package/lib/server/modules/products/types.d.ts +14 -0
  77. package/lib/solution/BaseSales/index.d.ts +2 -16
  78. package/lib/solution/BaseSales/index.js +31 -143
  79. package/lib/solution/BaseSales/types.d.ts +0 -1
  80. package/lib/solution/BaseSales/types.js +1 -2
  81. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
  82. package/lib/solution/BookingByStep/index.d.ts +1 -1
  83. package/lib/solution/BookingTicket/index.d.ts +1 -9
  84. package/lib/solution/BookingTicket/index.js +0 -112
  85. package/lib/solution/BookingTicket/types.d.ts +2 -0
  86. package/package.json +1 -1
  87. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  88. package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
  89. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  90. 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;
@@ -713,27 +674,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
713
674
  // appliedProductDetails / savedAmount 复位。
714
675
  if (!tempOrder) return;
715
676
  delete tempOrder.discount_list;
716
- var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
717
- var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
718
- if (shouldSkipDiscountCalculation) return;
677
+ if (this.shouldSkipDiscountCalculation(tempOrder)) return;
719
678
  var rulesModule = this.store.rules;
720
679
  if (!rulesModule) return;
721
- 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
+ }] : [];
722
684
  var result = rulesModule.calcDiscount({
723
685
  productList: tempOrder.products,
724
686
  discountList: discountList,
725
687
  holders: holders,
726
- isFormSubject: function isFormSubject(product) {
727
- return resolveIsFormSubject(tempOrder, product);
728
- },
688
+ isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
729
689
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
730
690
  });
731
691
  if (result !== null && result !== void 0 && result.productList) {
732
692
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
733
693
  tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
734
- var _ref14;
694
+ var _ref13;
735
695
  var uid = getOrderProductLineUid(product);
736
- 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));
737
697
  if (isManualProductDiscountProduct(previous)) {
738
698
  return previous;
739
699
  }
@@ -1258,15 +1218,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1258
1218
  }, {
1259
1219
  key: "extractOrderIdFromSubmitResult",
1260
1220
  value: function extractOrderIdFromSubmitResult(result) {
1261
- var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
1262
- 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;
1263
1223
  }
1264
1224
  }, {
1265
1225
  key: "calculatePaymentEffectiveAmount",
1266
1226
  value: function calculatePaymentEffectiveAmount(payment) {
1267
- var _ref18, _payment$origin_amoun;
1227
+ var _ref17, _payment$origin_amoun;
1268
1228
  var amount = new Decimal(payment.amount || 0);
1269
- 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);
1270
1230
  var serviceFee = new Decimal(payment.service_fee || 0);
1271
1231
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1272
1232
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1280,7 +1240,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1280
1240
  return mapPaymentItemsToOrderPayments(payments, {
1281
1241
  includeVoided: false
1282
1242
  }).reduce(function (sum, payment) {
1283
- if (!isPaidPaymentRecord(payment)) return sum;
1284
1243
  return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1285
1244
  }, new Decimal(0));
1286
1245
  }
@@ -1294,35 +1253,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1294
1253
  value: function normalizeDepositAmount(amount) {
1295
1254
  return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
1296
1255
  }
1297
- }, {
1298
- key: "getLastOrderDepositSnapshot",
1299
- value: function getLastOrderDepositSnapshot() {
1300
- var _lastOrderInfo$deposi, _lastOrderInfo$summar;
1301
- var lastOrderInfo = this.store.lastOrderInfo;
1302
- if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return null;
1303
- 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;
1304
- var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
1305
- var hasDepositAmount = new Decimal(depositAmount).gt(0);
1306
- var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
1307
- if (!isDeposit || !hasDepositAmount) return null;
1308
- return {
1309
- isDeposit: 1,
1310
- depositAmount: depositAmount
1311
- };
1312
- }
1313
- }, {
1314
- key: "getLastOrderSubmitSnapshot",
1315
- value: function getLastOrderSubmitSnapshot() {
1316
- var lastOrderInfo = this.store.lastOrderInfo;
1317
- if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return {};
1318
- var businessCode = lastOrderInfo.business_code;
1319
- var type = lastOrderInfo.type;
1320
- return _objectSpread(_objectSpread({}, typeof businessCode === 'string' && businessCode ? {
1321
- businessCode: businessCode
1322
- } : {}), typeof type === 'string' && type ? {
1323
- type: type
1324
- } : {});
1325
- }
1326
1256
  }, {
1327
1257
  key: "applyDepositAmountToSummary",
1328
1258
  value: function applyDepositAmountToSummary(tempOrder, summary, amount) {
@@ -1341,28 +1271,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1341
1271
  tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
1342
1272
  return nextSummary;
1343
1273
  }
1344
- }, {
1345
- key: "applyLastOrderDepositSnapshot",
1346
- value: function applyLastOrderDepositSnapshot(tempOrder, summary) {
1347
- var snapshot = this.getLastOrderDepositSnapshot();
1348
- if (!snapshot) return summary;
1349
- var existedDeposit = summary.deposit && _typeof(summary.deposit) === 'object' ? summary.deposit : undefined;
1350
- var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
1351
- deposit_amount: snapshot.depositAmount,
1352
- deposit: _objectSpread(_objectSpread({}, existedDeposit || {}), {}, {
1353
- total: snapshot.depositAmount,
1354
- deposit_policy_ids: (existedDeposit === null || existedDeposit === void 0 ? void 0 : existedDeposit.deposit_policy_ids) || [],
1355
- hasDeposit: true
1356
- })
1357
- });
1358
- tempOrder.deposit_amount = snapshot.depositAmount;
1359
- tempOrder.is_deposit = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
1360
- return nextSummary;
1361
- }
1362
1274
  }, {
1363
1275
  key: "isDepositOrder",
1364
1276
  value: function isDepositOrder(tempOrder, depositAmount) {
1365
- return tempOrder.is_deposit === 1 && depositAmount.gt(0);
1277
+ return tempOrder.is_deposit === 1 || depositAmount.gt(0);
1366
1278
  }
1367
1279
  }, {
1368
1280
  key: "getOrderExpectedAmount",
@@ -1377,39 +1289,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1377
1289
  if (depositAmount.lte(0)) return false;
1378
1290
  return params.paidAmount.gte(depositAmount);
1379
1291
  }
1380
- }, {
1381
- key: "getPaymentCompletion",
1382
- value: function getPaymentCompletion(payments) {
1383
- var tempOrder = this.ensureTempOrder();
1384
- var summary = this.store.summary || createEmptySummary();
1385
- var paymentList = payments || tempOrder.payments || [];
1386
- var refundAmount = this.getSummaryRefundAmount(summary);
1387
- var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1388
- var depositAmount = this.getDepositAmount(tempOrder, summary);
1389
- var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1390
- var isDepositFullyPaid = this.isDepositCovered({
1391
- tempOrder: tempOrder,
1392
- summary: summary,
1393
- paidAmount: netPaidAmount
1394
- });
1395
- var isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
1396
- var paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? 'deposit' : 'normal';
1397
- return {
1398
- isFullyPaid: isOrderFullyPaid,
1399
- isOrderFullyPaid: isOrderFullyPaid,
1400
- isDepositFullyPaid: isDepositFullyPaid,
1401
- paymentStage: paymentStage,
1402
- depositAmount: depositAmount.toFixed(2),
1403
- orderExpectedAmount: orderExpectedAmount.toFixed(2)
1404
- };
1405
- }
1406
1292
  }, {
1407
1293
  key: "calculateDepositPaidAmount",
1408
1294
  value: function calculateDepositPaidAmount(payments) {
1409
1295
  var _this5 = this;
1410
1296
  return (payments || []).reduce(function (sum, payment) {
1411
1297
  var paymentRecord = payment;
1412
- if (!isPaidPaymentRecord(paymentRecord)) return sum;
1298
+ if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return sum;
1413
1299
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1414
1300
  if (!isDepositPayment) return sum;
1415
1301
  if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
@@ -1431,7 +1317,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1431
1317
  }, {
1432
1318
  key: "normalizePaymentSource",
1433
1319
  value: function normalizePaymentSource(payment, options) {
1434
- var _ref19, _paymentRecord$origin;
1320
+ var _ref18, _paymentRecord$origin;
1435
1321
  var paymentRecord = payment;
1436
1322
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1437
1323
  if (!metadata.unique_payment_number) {
@@ -1439,7 +1325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1439
1325
  }
1440
1326
  var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1441
1327
  metadata: metadata,
1442
- 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'
1443
1329
  });
1444
1330
  if (paymentRecord.status !== undefined) {
1445
1331
  normalized.status = paymentRecord.status;
@@ -1560,7 +1446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1560
1446
  var _this6 = this;
1561
1447
  return (payments || []).reduce(function (summary, payment) {
1562
1448
  var paymentRecord = payment;
1563
- if (!isPaidPaymentRecord(paymentRecord)) return summary;
1449
+ if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
1564
1450
  return {
1565
1451
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1566
1452
  orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
@@ -1772,7 +1658,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1772
1658
  _product$payment_pric,
1773
1659
  _sku$code,
1774
1660
  _sku$barcode,
1775
- _ref20,
1661
+ _ref19,
1776
1662
  _sku$variant_id,
1777
1663
  _this8 = this;
1778
1664
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1799,24 +1685,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1799
1685
  product_sku: this.normalizeFingerprintValue({
1800
1686
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
1801
1687
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
1802
- 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,
1803
1689
  variant: sku.variant || [],
1804
1690
  option: getProductSkuOptions(product || {}).map(function (option) {
1805
- 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;
1806
1692
  return {
1807
- 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,
1808
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,
1809
- 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,
1810
1696
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1811
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)
1812
1698
  };
1813
1699
  })
1814
1700
  }),
1815
1701
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1816
- 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;
1817
1703
  return {
1818
- 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,
1819
- 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,
1820
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),
1821
1707
  price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1822
1708
  bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
@@ -1825,10 +1711,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1825
1711
  };
1826
1712
  })),
1827
1713
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1828
- var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
1714
+ var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
1829
1715
  return {
1830
- 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 : '',
1831
- 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,
1832
1718
  amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1833
1719
  };
1834
1720
  }))
@@ -1852,14 +1738,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1852
1738
  var _product$product_id3,
1853
1739
  _product$product_vari2,
1854
1740
  _product$num2,
1855
- _ref29,
1741
+ _ref28,
1856
1742
  _metadata$unique_iden,
1857
1743
  _metadata$price_overr,
1858
1744
  _metadata$is_manual_d,
1859
1745
  _metadata$product_dis,
1860
1746
  _sku$code2,
1861
1747
  _sku$barcode2,
1862
- _ref30,
1748
+ _ref29,
1863
1749
  _sku$variant_id2,
1864
1750
  _this10 = this;
1865
1751
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1875,7 +1761,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1875
1761
  extension_type: extensionType,
1876
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),
1877
1763
  metadata: {
1878
- 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 : '',
1879
1765
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
1880
1766
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
1881
1767
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -1883,35 +1769,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1883
1769
  product_sku: this.normalizeFingerprintValue({
1884
1770
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
1885
1771
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
1886
- 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,
1887
1773
  variant: sku.variant || [],
1888
1774
  option: getProductSkuOptions(product || {}).map(function (option) {
1889
- 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;
1890
1776
  return {
1891
- 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,
1892
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,
1893
- 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,
1894
1780
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1895
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)
1896
1782
  };
1897
1783
  })
1898
1784
  }),
1899
1785
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1900
- 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;
1901
1787
  return {
1902
- 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,
1903
- 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,
1904
- 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,
1905
- 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,
1906
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),
1907
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 : '',
1908
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 : '',
1909
1795
  option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1910
- 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;
1911
1797
  return {
1912
- 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,
1913
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,
1914
- 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,
1915
1801
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1916
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)
1917
1803
  };
@@ -1919,10 +1805,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1919
1805
  };
1920
1806
  })),
1921
1807
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1922
- var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
1808
+ var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
1923
1809
  return {
1924
- 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 : '',
1925
- 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,
1926
1812
  amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1927
1813
  };
1928
1814
  }))
@@ -2129,7 +2015,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2129
2015
  key: "restoreOrder",
2130
2016
  value: function restoreOrder() {
2131
2017
  var _this$store$discount11, _this$store$discount12;
2132
- this.logInfo('restoreOrder start', {});
2133
2018
  var freshTempOrder = this.createDefaultTempOrderInstance();
2134
2019
  this.ensureExternalSaleNumber(freshTempOrder);
2135
2020
  this.store.tempOrder = freshTempOrder;
@@ -2203,11 +2088,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2203
2088
  }, {
2204
2089
  key: "getOrderIdentity",
2205
2090
  value: function getOrderIdentity() {
2206
- var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
2091
+ var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2207
2092
  var tempOrder = this.store.tempOrder;
2208
2093
  if (!tempOrder) return null;
2209
2094
  var lastOrderInfo = this.store.lastOrderInfo || {};
2210
- 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;
2211
2096
  return {
2212
2097
  localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2213
2098
  orderId: orderId,
@@ -2242,7 +2127,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2242
2127
  orderPaidAmount: paidPaymentSummary.gapPaidAmount
2243
2128
  });
2244
2129
  return {
2245
- isDeposit: tempOrder.is_deposit === 1,
2130
+ isDeposit: tempOrder.is_deposit === 1 || depositAmount !== '0.00',
2246
2131
  depositAmount: depositAmount,
2247
2132
  expectAmount: summary.expect_amount || '0.00',
2248
2133
  totalAmount: summary.total_amount || '0.00',
@@ -2360,11 +2245,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2360
2245
  }, {
2361
2246
  key: "captureProductRuntime",
2362
2247
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2363
- var _extend$productsByUid, _ref45, _rawProduct$_origin;
2248
+ var _extend$productsByUid, _ref44, _rawProduct$_origin;
2364
2249
  var uid = existedUid || this.getProductUid(normalizedProduct);
2365
2250
  var extend = this.ensureExtend(tempOrder);
2366
2251
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2367
- 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;
2368
2253
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2369
2254
  origin: origin
2370
2255
  } : {});
@@ -2465,7 +2350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2465
2350
  }, {
2466
2351
  key: "buildTempOrderHolderFromBookings",
2467
2352
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2468
- 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;
2469
2354
  var holderRecords = [];
2470
2355
  var holderNames = [];
2471
2356
  var baseHolder = null;
@@ -2512,7 +2397,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2512
2397
  }
2513
2398
  var nextHolder = {
2514
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,
2515
- 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,
2516
2401
  form_record: holderRecords
2517
2402
  };
2518
2403
  if (holderNames.length) {
@@ -2607,16 +2492,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2607
2492
  hasDeposit: true
2608
2493
  } : undefined
2609
2494
  });
2610
- var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
2611
2495
  tempOrder.deposit_amount = depositAmount;
2612
- tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
2613
- return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
2496
+ tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
2497
+ return nextSummary;
2614
2498
  }
2615
2499
  }, {
2616
2500
  key: "recalculateSummary",
2617
2501
  value: function () {
2618
2502
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2619
- var _ref47, _salesSummaryResult$e;
2503
+ var _ref46, _salesSummaryResult$e;
2620
2504
  var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2621
2505
  return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2622
2506
  while (1) switch (_context13.prev = _context13.next) {
@@ -2689,7 +2573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2689
2573
  roundingAmount = paidPaymentSummary.roundingAmount;
2690
2574
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2691
2575
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2692
- 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;
2693
2577
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2694
2578
  rounding_amount: roundingAmount.toFixed(2)
2695
2579
  }, expectAmount ? {
@@ -2867,17 +2751,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2867
2751
  }, {
2868
2752
  key: "buildTempOrderCustomer",
2869
2753
  value: function buildTempOrderCustomer(params) {
2870
- 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;
2871
2755
  if (!params.customerId) return null;
2872
2756
  var source = params.source ? cloneDeep(params.source) : {};
2873
- 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;
2874
- 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;
2875
2759
  return _objectSpread(_objectSpread({}, source), {}, {
2876
2760
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
2877
2761
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
2878
2762
  name: String(name || ''),
2879
2763
  customer_name: String(customerName || ''),
2880
- 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),
2881
2765
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
2882
2766
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
2883
2767
  });
@@ -2976,14 +2860,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2976
2860
  }, {
2977
2861
  key: "updateTempOrderCustomer",
2978
2862
  value: function updateTempOrderCustomer(customer) {
2979
- 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;
2980
2864
  var tempOrder = this.ensureTempOrder();
2981
2865
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
2982
- 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;
2983
- 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 : '';
2984
2868
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
2985
2869
  tempOrder.customer_name = String(customerName || '');
2986
- 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 : '');
2987
2871
  tempOrder.phone = String(customer.phone || '');
2988
2872
  tempOrder.email = String(customer.email || '');
2989
2873
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3034,7 +2918,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3034
2918
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3035
2919
  clearTempOrderHolderAssignments(tempOrder);
3036
2920
  this.clearCustomerBoundDiscounts(tempOrder);
3037
- this.applyDiscount();
3038
2921
  }
3039
2922
  this.persistTempOrder();
3040
2923
  this.saveDraftInBackground();
@@ -3201,77 +3084,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3201
3084
  this.persistTempOrder();
3202
3085
  return tempOrder.payments;
3203
3086
  }
3204
- }, {
3205
- key: "confirmPendingVoucherPaymentsInList",
3206
- value: function confirmPendingVoucherPaymentsInList(payments) {
3207
- return (payments || []).map(function (payment) {
3208
- if (!isPendingVoucherPaymentRecord(payment)) return payment;
3209
- return _objectSpread(_objectSpread({}, payment), {}, {
3210
- status: ORDER_PAYMENT_STATUS_PAID
3211
- });
3212
- });
3213
- }
3214
- }, {
3215
- key: "discardPendingVoucherPaymentsFromList",
3216
- value: function discardPendingVoucherPaymentsFromList(payments) {
3217
- return (payments || []).filter(function (payment) {
3218
- return !isPendingVoucherPaymentRecord(payment);
3219
- });
3220
- }
3221
- }, {
3222
- key: "prepareVoucherPaymentsForSubmit",
3223
- value: function prepareVoucherPaymentsForSubmit(payments) {
3224
- var confirmPendingVoucherPayments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3225
- var mappedPayments = mapPaymentItemsToOrderPayments(payments || []);
3226
- return confirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : this.discardPendingVoucherPaymentsFromList(mappedPayments);
3227
- }
3228
- }, {
3229
- key: "applyPaymentLifecycleChange",
3230
- value: function applyPaymentLifecycleChange(tempOrder, options) {
3231
- var _this19 = this;
3232
- this.updateTempOrderPaymentStatus(tempOrder);
3233
- if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3234
- this.persistTempOrder();
3235
- }
3236
- if ((options === null || options === void 0 ? void 0 : options.recalculateSummary) === false) return;
3237
- var logContext = (options === null || options === void 0 ? void 0 : options.logContext) || 'payment lifecycle change';
3238
- void this.recalculateSummary({
3239
- createIfMissing: true
3240
- }).catch(function (error) {
3241
- _this19.logError("recalculate summary after ".concat(logContext, " failed"), {
3242
- error: error instanceof Error ? error.message : String(error)
3243
- });
3244
- });
3245
- }
3246
- }, {
3247
- key: "confirmPendingVoucherPayments",
3248
- value: function confirmPendingVoucherPayments(options) {
3249
- var tempOrder = this.ensureTempOrder();
3250
- var payments = tempOrder.payments || [];
3251
- var hasPendingVoucher = payments.some(function (payment) {
3252
- return isPendingVoucherPaymentRecord(payment);
3253
- });
3254
- if (!hasPendingVoucher) return payments;
3255
- tempOrder.payments = this.confirmPendingVoucherPaymentsInList(payments);
3256
- this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
3257
- logContext: 'confirmPendingVoucherPayments'
3258
- }));
3259
- // this.recalculateSummary();
3260
- return tempOrder.payments;
3261
- }
3262
- }, {
3263
- key: "discardPendingVoucherPayments",
3264
- value: function discardPendingVoucherPayments(options) {
3265
- var tempOrder = this.ensureTempOrder();
3266
- var payments = tempOrder.payments || [];
3267
- var nextPayments = this.discardPendingVoucherPaymentsFromList(payments);
3268
- if (nextPayments.length === payments.length) return payments;
3269
- tempOrder.payments = nextPayments;
3270
- this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
3271
- logContext: 'discardPendingVoucherPayments'
3272
- }));
3273
- return tempOrder.payments;
3274
- }
3275
3087
 
3276
3088
  /**
3277
3089
  * 覆盖当前订单中的 wallet pass 支付项。
@@ -3281,92 +3093,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3281
3093
  */
3282
3094
  }, {
3283
3095
  key: "updateVoucherOrderPayments",
3284
- value: function updateVoucherOrderPayments(payments, options) {
3285
- var _this20 = this;
3096
+ value: function updateVoucherOrderPayments(payments) {
3097
+ var _this19 = this;
3286
3098
  var tempOrder = this.ensureTempOrder();
3287
- var isOrderPaymentType = function isOrderPaymentType(value) {
3288
- return value === 'normal' || value === 'deposit';
3099
+ var isVoucherPayment = function isVoucherPayment(payment) {
3100
+ return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
3289
3101
  };
3290
- var voucherOrderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
3291
- var withVoucherPaymentType = function withVoucherPaymentType(payment) {
3292
- var paymentRecord = payment;
3293
- if (!isVoucherPaymentRecord(paymentRecord)) return payment;
3294
- var explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : undefined;
3295
- var nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
3296
- var shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === undefined && paymentRecord.type !== undefined && !isOrderPaymentType(paymentRecord.type);
3297
- return _objectSpread(_objectSpread(_objectSpread({}, paymentRecord), shouldPreserveCustomPaymentType ? {
3298
- custom_payment_type: paymentRecord.type
3299
- } : {}), {}, {
3300
- type: nextPaymentType,
3301
- order_payment_type: nextPaymentType
3302
- });
3303
- };
3304
- var normalizeVoucherPaymentStatus = function normalizeVoucherPaymentStatus(payment) {
3305
- var paymentRecord = payment;
3306
- if (!isVoucherPaymentRecord(paymentRecord)) return payment;
3307
- if (hasSyncedOrderPaymentRecord(paymentRecord) && (paymentRecord.status === undefined || paymentRecord.status === 'active')) {
3308
- return _objectSpread(_objectSpread({}, paymentRecord), {}, {
3309
- status: ORDER_PAYMENT_STATUS_PAID
3310
- });
3311
- }
3312
- if (paymentRecord.status !== undefined && paymentRecord.status !== 'active') {
3313
- return payment;
3314
- }
3315
- return _objectSpread(_objectSpread({}, paymentRecord), {}, {
3316
- status: (options === null || options === void 0 ? void 0 : options.status) || ORDER_PAYMENT_STATUS_PENDING
3317
- });
3102
+ var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
3103
+ return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
3318
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
+ // };
3319
3117
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3320
- return _this20.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3321
- defaultPaid: false
3118
+ return _this19.normalizePaymentSource(payment, {
3119
+ defaultPaid: true
3322
3120
  });
3323
3121
  })).filter(function (payment) {
3324
- return isVoucherPaymentRecord(payment);
3122
+ return isVoucherPayment(payment);
3325
3123
  });
3326
3124
  var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3327
- return !isVoucherPaymentRecord(payment);
3125
+ return !isVoucherPayment(payment);
3328
3126
  });
3329
- var normalizeCommittedVoucherPayment = function normalizeCommittedVoucherPayment(payment) {
3330
- if (hasSyncedOrderPaymentRecord(payment) && (payment.status === undefined || payment.status === 'active')) {
3331
- return _objectSpread(_objectSpread({}, payment), {}, {
3332
- status: ORDER_PAYMENT_STATUS_PAID
3333
- });
3334
- }
3335
- return payment;
3336
- };
3337
- var committedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3338
- return isCommittedVoucherPaymentRecord(payment);
3339
- }).map(function (payment) {
3340
- return normalizeCommittedVoucherPayment(payment);
3127
+ var syncedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
3128
+ return isVoucherPayment(payment) && hasSyncedOrderPayment(payment);
3341
3129
  });
3342
- var committedVoucherPaymentIds = new Set(committedVoucherPayments.filter(function (payment) {
3343
- return hasSyncedOrderPaymentRecord(payment);
3344
- }).map(function (payment) {
3130
+ var syncedVoucherPaymentIds = new Set(syncedVoucherPayments.map(function (payment) {
3345
3131
  return String(payment.order_payment_id);
3346
3132
  }));
3347
- var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
3348
- return String(payment.voucher_id);
3349
- }));
3350
3133
  var replaceableVouchers = mappedVouchers.filter(function (payment) {
3351
- if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
3352
- return false;
3353
- }
3354
- if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
3355
- return false;
3356
- }
3357
- return true;
3134
+ if (!hasSyncedOrderPayment(payment)) return true;
3135
+ return !syncedVoucherPaymentIds.has(String(payment.order_payment_id));
3358
3136
  });
3359
3137
  var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
3360
3138
  vouchers: replaceableVouchers,
3361
- nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments))
3139
+ nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments))
3362
3140
  });
3363
- tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments), _toConsumableArray(cappedVouchers));
3141
+ tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments), _toConsumableArray(cappedVouchers));
3364
3142
  this.updateTempOrderPaymentStatus(tempOrder);
3365
3143
  this.persistTempOrder();
3366
3144
  void this.recalculateSummary({
3367
3145
  createIfMissing: true
3368
3146
  }).catch(function (error) {
3369
- _this20.logError('recalculate summary after updateVoucherOrderPayments failed', {
3147
+ _this19.logError('recalculate summary after updateVoucherOrderPayments failed', {
3370
3148
  error: error instanceof Error ? error.message : String(error)
3371
3149
  });
3372
3150
  });
@@ -3502,7 +3280,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3502
3280
  var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3503
3281
  var _booking_uid,
3504
3282
  _metadata,
3505
- _this21 = this;
3283
+ _this20 = this;
3506
3284
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3507
3285
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3508
3286
  while (1) switch (_context18.prev = _context18.next) {
@@ -3527,8 +3305,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3527
3305
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3528
3306
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3529
3307
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3530
- if (_this21.hasGoodPassDiscount(item)) return false;
3531
- if (_this21.hasOrderProductLineNote(item)) return false;
3308
+ if (_this20.hasGoodPassDiscount(item)) return false;
3309
+ if (_this20.hasOrderProductLineNote(item)) return false;
3532
3310
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3533
3311
  if (item.product_id !== productToAdd.product_id) return false;
3534
3312
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -3634,52 +3412,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3634
3412
  key: "addProductToOrder",
3635
3413
  value: (function () {
3636
3414
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3637
- var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3415
+ var tempOrder, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
3638
3416
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3639
3417
  while (1) switch (_context19.prev = _context19.next) {
3640
3418
  case 0:
3641
3419
  tempOrder = this.ensureTempOrder();
3420
+ debugger;
3642
3421
  if (!booking) {
3643
- _context19.next = 18;
3422
+ _context19.next = 19;
3644
3423
  break;
3645
3424
  }
3646
3425
  productRecord = product;
3647
- 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);
3648
3427
  if (!(splitCount > 1)) {
3649
- _context19.next = 18;
3428
+ _context19.next = 19;
3650
3429
  break;
3651
3430
  }
3652
3431
  i = 0;
3653
- case 6:
3432
+ case 7:
3654
3433
  if (!(i < splitCount)) {
3655
- _context19.next = 15;
3434
+ _context19.next = 16;
3656
3435
  break;
3657
3436
  }
3658
3437
  singleLine = cloneDeep(productRecord);
3659
3438
  singleLine.num = 1;
3660
3439
  delete singleLine.product_quantity;
3661
- _context19.next = 12;
3440
+ _context19.next = 13;
3662
3441
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3663
- case 12:
3442
+ case 13:
3664
3443
  i += 1;
3665
- _context19.next = 6;
3444
+ _context19.next = 7;
3666
3445
  break;
3667
- case 15:
3668
- _context19.next = 17;
3446
+ case 16:
3447
+ _context19.next = 18;
3669
3448
  return this.finalizeProductOrderMutation(tempOrder);
3670
- case 17:
3671
- return _context19.abrupt("return", tempOrder.products);
3672
3449
  case 18:
3673
- _context19.next = 20;
3450
+ return _context19.abrupt("return", tempOrder.products);
3451
+ case 19:
3452
+ _context19.next = 21;
3674
3453
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3675
- case 20:
3676
- _context19.next = 22;
3454
+ case 21:
3455
+ _context19.next = 23;
3677
3456
  return this.finalizeProductOrderMutation(tempOrder);
3678
- case 22:
3679
- this.logInfo('addProductToOrder success', {
3680
- product_id: product.product_id,
3681
- with_booking: !!booking
3682
- });
3457
+ case 23:
3683
3458
  return _context19.abrupt("return", tempOrder.products);
3684
3459
  case 24:
3685
3460
  case "end":
@@ -3706,7 +3481,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3706
3481
  key: "addProductsToOrder",
3707
3482
  value: (function () {
3708
3483
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3709
- 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;
3710
3485
  return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3711
3486
  while (1) switch (_context20.prev = _context20.next) {
3712
3487
  case 0:
@@ -3738,7 +3513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3738
3513
  break;
3739
3514
  }
3740
3515
  productRecord = product;
3741
- 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);
3742
3517
  if (!(splitCount > 1)) {
3743
3518
  _context20.next = 26;
3744
3519
  break;
@@ -3781,11 +3556,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3781
3556
  _context20.next = 40;
3782
3557
  return this.finalizeProductOrderMutation(tempOrder, options);
3783
3558
  case 40:
3784
- this.logInfo('addProductsToOrder success', {
3785
- itemsCount: items.length
3786
- });
3787
3559
  return _context20.abrupt("return", tempOrder.products);
3788
- case 42:
3560
+ case 41:
3789
3561
  case "end":
3790
3562
  return _context20.stop();
3791
3563
  }
@@ -3818,24 +3590,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3818
3590
  }, {
3819
3591
  key: "getBundleRuntimeIdentity",
3820
3592
  value: function getBundleRuntimeIdentity(bundle) {
3821
- 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;
3822
3594
  if (!bundle || _typeof(bundle) !== 'object') return '';
3823
- 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('|');
3824
3596
  }
3825
3597
  }, {
3826
3598
  key: "preservePersistedBundlePriceFields",
3827
3599
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3828
- var _this22 = this;
3600
+ var _this21 = this;
3829
3601
  if (!Array.isArray(nextBundles)) return nextBundles;
3830
3602
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3831
3603
  var previousByIdentity = new Map();
3832
3604
  previousBundles.forEach(function (bundle) {
3833
- var identity = _this22.getBundleRuntimeIdentity(bundle);
3605
+ var identity = _this21.getBundleRuntimeIdentity(bundle);
3834
3606
  if (identity) previousByIdentity.set(identity, bundle);
3835
3607
  });
3836
3608
  return nextBundles.map(function (bundle, index) {
3837
3609
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3838
- var previous = previousByIdentity.get(_this22.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3610
+ var previous = previousByIdentity.get(_this21.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3839
3611
  if (!previous || _typeof(previous) !== 'object') return bundle;
3840
3612
  return _objectSpread(_objectSpread({}, bundle), {}, {
3841
3613
  price: previous.price,
@@ -4003,11 +3775,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4003
3775
  });
4004
3776
  case 8:
4005
3777
  this.persistTempOrder();
4006
- this.logInfo('updateOrderProduct success', {
4007
- params: params
4008
- });
4009
3778
  return _context21.abrupt("return", tempOrder.products);
4010
- case 11:
3779
+ case 10:
4011
3780
  case "end":
4012
3781
  return _context21.stop();
4013
3782
  }
@@ -4022,7 +3791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4022
3791
  key: "updateOrderProducts",
4023
3792
  value: function () {
4024
3793
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4025
- var _this23 = this;
3794
+ var _this22 = this;
4026
3795
  var tempOrder;
4027
3796
  return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4028
3797
  while (1) switch (_context22.prev = _context22.next) {
@@ -4035,16 +3804,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4035
3804
  return _context22.abrupt("return", tempOrder.products);
4036
3805
  case 3:
4037
3806
  paramsList.forEach(function (params) {
4038
- _this23.applyOrderProductUpdateToTempOrder(tempOrder, params);
3807
+ _this22.applyOrderProductUpdateToTempOrder(tempOrder, params);
4039
3808
  });
4040
3809
  _context22.next = 6;
4041
3810
  return this.finalizeAfterProductsMutation(tempOrder);
4042
3811
  case 6:
4043
- this.logInfo('updateOrderProduct success', {
4044
- paramsList: paramsList
4045
- });
4046
3812
  return _context22.abrupt("return", tempOrder.products);
4047
- case 8:
3813
+ case 7:
4048
3814
  case "end":
4049
3815
  return _context22.stop();
4050
3816
  }
@@ -4116,11 +3882,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4116
3882
  });
4117
3883
  case 22:
4118
3884
  this.persistTempOrder();
4119
- this.logInfo('updateOrderProductQuantity success', {
4120
- params: params
4121
- });
4122
3885
  return _context23.abrupt("return", tempOrder.products);
4123
- case 25:
3886
+ case 24:
4124
3887
  case "end":
4125
3888
  return _context23.stop();
4126
3889
  }
@@ -4205,7 +3968,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4205
3968
  key: "removeProductsFromOrder",
4206
3969
  value: (function () {
4207
3970
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4208
- var _this24 = this;
3971
+ var _this23 = this;
4209
3972
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4210
3973
  return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4211
3974
  while (1) switch (_context26.prev = _context26.next) {
@@ -4260,7 +4023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4260
4023
  }
4261
4024
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4262
4025
  bookingsBeforeRemove.forEach(function (booking) {
4263
- var bookingUid = _this24.getBookingUniqueIdentificationNumber(booking);
4026
+ var bookingUid = _this23.getBookingUniqueIdentificationNumber(booking);
4264
4027
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4265
4028
  linkedBookingUidsToRemove.add(bookingUid);
4266
4029
  }
@@ -4312,11 +4075,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4312
4075
  _context26.next = 31;
4313
4076
  return this.finalizeAfterProductsMutation(tempOrder);
4314
4077
  case 31:
4315
- this.logInfo('removeProductsFromOrder success', {
4316
- identities: identities
4317
- });
4318
4078
  return _context26.abrupt("return", tempOrder.products);
4319
- case 33:
4079
+ case 32:
4320
4080
  case "end":
4321
4081
  return _context26.stop();
4322
4082
  }
@@ -4378,9 +4138,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4378
4138
  });
4379
4139
  case 11:
4380
4140
  this.persistTempOrder();
4381
- this.logInfo('clearOrderCartLines success', {});
4382
4141
  return _context28.abrupt("return", tempOrder);
4383
- case 14:
4142
+ case 13:
4384
4143
  case "end":
4385
4144
  return _context28.stop();
4386
4145
  }
@@ -4395,23 +4154,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4395
4154
  }, {
4396
4155
  key: "buildCurrentSubmitPayloadForLocalPrint",
4397
4156
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4398
- var _params$cacheId, _this$otherParams2, _ref68, _params$businessCode, _this$otherParams3, _this$otherParams4;
4157
+ var _params$cacheId, _this$otherParams2, _ref67, _params$businessCode, _this$otherParams3, _this$otherParams4;
4399
4158
  var tempOrder = this.ensureTempOrder();
4400
4159
  this.persistTempOrder();
4401
4160
  var payload = buildSubmitPayload({
4402
4161
  tempOrder: tempOrder,
4403
4162
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4404
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),
4405
- businessCode: (_ref68 = (_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 && _ref68 !== void 0 ? _ref68 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
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,
4406
4165
  channel: params === null || params === void 0 ? void 0 : params.channel,
4407
4166
  type: params === null || params === void 0 ? void 0 : params.type,
4408
4167
  summary: this.store.summary || createEmptySummary(),
4409
4168
  enhance: function enhance(nextPayload) {
4410
- 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_;
4411
4170
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4412
- 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,
4413
- 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,
4414
- 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,
4415
4174
  small_ticket_data_flag: 1
4416
4175
  });
4417
4176
  }
@@ -4508,56 +4267,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4508
4267
  key: "runSubmitTempOrder",
4509
4268
  value: function () {
4510
4269
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4511
- var _params$cacheId2, _this$otherParams5, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams6, _this$otherParams7, _submitSnapshot$type;
4512
- 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;
4513
4272
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4514
4273
  while (1) switch (_context32.prev = _context32.next) {
4515
4274
  case 0:
4516
4275
  tempOrder = this.ensureTempOrder();
4517
- shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
4518
- hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
4519
- preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments) : undefined;
4520
- if (!hasPaymentOverride) {
4521
- if (shouldConfirmPendingVoucherPayments) {
4522
- this.confirmPendingVoucherPayments({
4523
- persist: false,
4524
- recalculateSummary: false
4525
- });
4526
- } else {
4527
- this.discardPendingVoucherPayments({
4528
- persist: false,
4529
- recalculateSummary: false
4530
- });
4531
- }
4532
- }
4533
4276
  this.persistTempOrder();
4534
- _context32.next = 8;
4277
+ _context32.next = 4;
4535
4278
  return this.recalculateSummary({
4536
4279
  createIfMissing: true
4537
4280
  });
4538
- case 8:
4281
+ case 4:
4539
4282
  _context32.t1 = _context32.sent;
4540
4283
  if (_context32.t1) {
4541
- _context32.next = 11;
4284
+ _context32.next = 7;
4542
4285
  break;
4543
4286
  }
4544
4287
  _context32.t1 = this.store.summary;
4545
- case 11:
4288
+ case 7:
4546
4289
  _context32.t0 = _context32.t1;
4547
4290
  if (_context32.t0) {
4548
- _context32.next = 14;
4291
+ _context32.next = 10;
4549
4292
  break;
4550
4293
  }
4551
4294
  _context32.t0 = createEmptySummary();
4552
- case 14:
4295
+ case 10:
4553
4296
  latestSummary = _context32.t0;
4554
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;
4555
4299
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4556
4300
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
4557
4301
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
4558
4302
  var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
4559
- payments: preparedPaymentOverride || []
4560
- } : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
4303
+ payments: mapPaymentItemsToOrderPayments((params === null || params === void 0 ? void 0 : params.payments) || [])
4304
+ } : {}), hasPaymentStatusOverride ? {
4561
4305
  payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
4562
4306
  } : {}), hasSmallTicketDataFlagOverride ? {
4563
4307
  small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
@@ -4565,19 +4309,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4565
4309
  var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
4566
4310
  return enhancedPayload;
4567
4311
  } : undefined;
4568
- submitSnapshot = this.getLastOrderSubmitSnapshot();
4569
4312
  payload = buildSubmitPayload({
4570
4313
  tempOrder: tempOrder,
4571
4314
  cacheId: effectiveCacheId,
4572
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),
4573
- 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$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
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,
4574
4317
  channel: params === null || params === void 0 ? void 0 : params.channel,
4575
- 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,
4576
4319
  summary: latestSummary,
4577
4320
  request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
4578
4321
  enhance: enhancePayload
4579
4322
  });
4580
- console.log('[Order.runSubmitTempOrder.payload]', payload);
4581
4323
  if (params !== null && params !== void 0 && params.syncMode) {
4582
4324
  payload.sync_mode = true;
4583
4325
  }
@@ -4585,10 +4327,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4585
4327
  if (!payload.created_at) {
4586
4328
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4587
4329
  }
4588
- _context32.next = 26;
4330
+ _context32.next = 21;
4589
4331
  return this.saveDraft();
4590
- case 26:
4591
- _context32.prev = 26;
4332
+ case 21:
4333
+ _context32.prev = 21;
4592
4334
  this.logInfo('submitTempOrder calling sales checkout', {
4593
4335
  orderId: payload.order_id,
4594
4336
  externalSaleNumber: payload.external_sale_number,
@@ -4598,26 +4340,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4598
4340
  smallTicketDataFlag: payload.small_ticket_data_flag,
4599
4341
  syncMode: payload.sync_mode
4600
4342
  });
4601
- _context32.next = 30;
4343
+ _context32.next = 25;
4602
4344
  return this.submitSalesOrder({
4603
4345
  query: payload
4604
4346
  });
4605
- case 30:
4347
+ case 25:
4606
4348
  result = _context32.sent;
4607
- _context32.next = 43;
4349
+ _context32.next = 38;
4608
4350
  break;
4609
- case 33:
4610
- _context32.prev = 33;
4611
- _context32.t2 = _context32["catch"](26);
4351
+ case 28:
4352
+ _context32.prev = 28;
4353
+ _context32.t2 = _context32["catch"](21);
4612
4354
  backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4613
4355
  if (!backendErrorResponse) {
4614
- _context32.next = 40;
4356
+ _context32.next = 35;
4615
4357
  break;
4616
4358
  }
4617
4359
  this.store.syncState = 'failed';
4618
4360
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4619
4361
  return _context32.abrupt("return", backendErrorResponse);
4620
- case 40:
4362
+ case 35:
4621
4363
  this.store.syncState = 'failed';
4622
4364
  this.logError('submitTempOrder failed', {
4623
4365
  error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
@@ -4627,47 +4369,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4627
4369
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4628
4370
  });
4629
4371
  throw _context32.t2;
4630
- case 43:
4372
+ case 38:
4631
4373
  if (!this.isSubmitResponseRejected(result)) {
4632
- _context32.next = 47;
4374
+ _context32.next = 42;
4633
4375
  break;
4634
4376
  }
4635
4377
  this.store.syncState = 'failed';
4636
4378
  this.logSubmitBackendRejected(result, payload);
4637
4379
  return _context32.abrupt("return", result);
4638
- case 47:
4380
+ case 42:
4639
4381
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4640
4382
  this.logInfo('runSubmitTempOrder: 提交成功', {
4641
4383
  submittedOrderId: submittedOrderId,
4642
4384
  result: result,
4643
- tempOrder: _objectSpread(_objectSpread({}, tempOrder), {}, {
4644
- _extend: undefined
4645
- })
4385
+ tempOrder: tempOrder
4646
4386
  });
4647
4387
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4648
- _context32.next = 56;
4388
+ _context32.next = 51;
4649
4389
  break;
4650
4390
  }
4651
4391
  tempOrder.order_id = submittedOrderId;
4652
4392
  resultRecord = result;
4653
- _context32.next = 54;
4393
+ _context32.next = 49;
4654
4394
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4655
- case 54:
4656
- _context32.next = 57;
4395
+ case 49:
4396
+ _context32.next = 52;
4657
4397
  break;
4658
- case 56:
4398
+ case 51:
4659
4399
  if (this.isLocalPendingSubmitResult(result)) {
4660
4400
  this.store.syncState = 'local';
4661
4401
  } else {
4662
4402
  this.store.syncState = 'submitted';
4663
4403
  }
4664
- case 57:
4404
+ case 52:
4665
4405
  return _context32.abrupt("return", result);
4666
- case 58:
4406
+ case 53:
4667
4407
  case "end":
4668
4408
  return _context32.stop();
4669
4409
  }
4670
- }, _callee29, this, [[26, 33]]);
4410
+ }, _callee29, this, [[21, 28]]);
4671
4411
  }));
4672
4412
  function runSubmitTempOrder(_x32) {
4673
4413
  return _runSubmitTempOrder.apply(this, arguments);
@@ -4739,10 +4479,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4739
4479
  value: function extractSubmitErrorResponse(error) {
4740
4480
  var _error$response,
4741
4481
  _error$response2,
4742
- _this25 = this;
4482
+ _this24 = this;
4743
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];
4744
4484
  return candidates.find(function (candidate) {
4745
- return _this25.isSubmitErrorResponse(candidate);
4485
+ return _this24.isSubmitErrorResponse(candidate);
4746
4486
  }) || null;
4747
4487
  }
4748
4488
  }, {
@@ -4770,46 +4510,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4770
4510
  key: "syncPaymentsToOrder",
4771
4511
  value: function () {
4772
4512
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4773
- var _params$confirmPendin;
4774
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4513
+ var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4775
4514
  return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4776
4515
  while (1) switch (_context34.prev = _context34.next) {
4777
4516
  case 0:
4778
4517
  tempOrder = this.ensureTempOrder();
4779
4518
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
4780
- shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
4781
- effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
4782
- completion = this.getPaymentCompletion(effectivePayments);
4783
- paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
4784
- paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4785
- 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;
4786
4524
  tempOrder.payment_status = paymentStatus;
4787
4525
  this.persistTempOrder();
4788
- _context34.next = 12;
4526
+ _context34.next = 11;
4789
4527
  return this.saveDraft();
4790
- case 12:
4528
+ case 11:
4791
4529
  if (params.submitWhenPaid) {
4792
- _context34.next = 14;
4530
+ _context34.next = 13;
4793
4531
  break;
4794
4532
  }
4795
- return _context34.abrupt("return", completion);
4796
- case 14:
4533
+ return _context34.abrupt("return", {
4534
+ isFullyPaid: isFullyPaid
4535
+ });
4536
+ case 13:
4797
4537
  if (!(this.store.syncState === 'submitting')) {
4798
- _context34.next = 16;
4538
+ _context34.next = 15;
4799
4539
  break;
4800
4540
  }
4801
- return _context34.abrupt("return", completion);
4802
- case 16:
4541
+ return _context34.abrupt("return", {
4542
+ isFullyPaid: isFullyPaid
4543
+ });
4544
+ case 15:
4803
4545
  this.store.syncState = 'submitting';
4804
- paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4805
- _context34.next = 20;
4546
+ paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4547
+ _context34.next = 19;
4806
4548
  return this.submitTempOrder({
4807
- payments: effectivePayments,
4549
+ payments: mappedPayments,
4808
4550
  paymentStatus: paymentStatus,
4809
4551
  smallTicketDataFlag: params.smallTicketDataFlag,
4810
4552
  businessCode: params.businessCode,
4811
4553
  channel: params.channel,
4812
- confirmPendingVoucherPayments: true,
4813
4554
  enhancePayload: function enhancePayload(payload) {
4814
4555
  var nextPayload = _objectSpread(_objectSpread({}, payload), {}, {
4815
4556
  request_unique_idempotency_token: paymentSyncIdempotencyToken
@@ -4817,12 +4558,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4817
4558
  return nextPayload;
4818
4559
  }
4819
4560
  });
4820
- case 20:
4561
+ case 19:
4821
4562
  submitResult = _context34.sent;
4822
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4563
+ return _context34.abrupt("return", {
4564
+ isFullyPaid: isFullyPaid,
4823
4565
  submitResult: submitResult
4824
- }));
4825
- case 22:
4566
+ });
4567
+ case 21:
4826
4568
  case "end":
4827
4569
  return _context34.stop();
4828
4570
  }
@@ -5335,28 +5077,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5335
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() || [] : [];
5336
5078
  shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5337
5079
  if (shouldSkipEmptyDiscountSync) {
5338
- _context42.next = 17;
5080
+ _context42.next = 16;
5339
5081
  break;
5340
5082
  }
5341
- OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
5342
- _context42.next = 15;
5083
+ _context42.next = 14;
5343
5084
  return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5344
- case 15:
5345
- _context42.next = 17;
5085
+ case 14:
5086
+ _context42.next = 16;
5346
5087
  return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5347
- case 17:
5088
+ case 16:
5348
5089
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5349
- _context42.next = 20;
5090
+ _context42.next = 19;
5350
5091
  break;
5351
5092
  }
5352
- _context42.next = 20;
5093
+ _context42.next = 19;
5353
5094
  return this.recalculateSummary({
5354
5095
  createIfMissing: false
5355
5096
  });
5356
- case 20:
5097
+ case 19:
5357
5098
  this.persistTempOrder();
5358
5099
  return _context42.abrupt("return", nextTempOrder);
5359
- case 22:
5100
+ case 21:
5360
5101
  case "end":
5361
5102
  return _context42.stop();
5362
5103
  }
@@ -5403,7 +5144,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5403
5144
  }, {
5404
5145
  key: "normalizeTempOrderForRuntime",
5405
5146
  value: function normalizeTempOrderForRuntime(raw, options) {
5406
- var _this26 = this;
5147
+ var _this25 = this;
5407
5148
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5408
5149
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5409
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) {
@@ -5426,10 +5167,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5426
5167
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5427
5168
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5428
5169
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5429
- return _this26.normalizeHydratedOrderProduct(p);
5170
+ return _this25.normalizeHydratedOrderProduct(p);
5430
5171
  }) : [];
5431
5172
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5432
- var booking = _this26.normalizeHydratedBookingHolder(b || {});
5173
+ var booking = _this25.normalizeHydratedBookingHolder(b || {});
5433
5174
  return _objectSpread(_objectSpread({}, booking), {}, {
5434
5175
  is_all: normalizeBookingIsAll(booking),
5435
5176
  sub_type: normalizeBookingSubType(booking)
@@ -5459,7 +5200,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5459
5200
  _step22;
5460
5201
  try {
5461
5202
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5462
- var _product$metadata8, _ref74, _ref75, _existed$origin, _rawProduct$metadata;
5203
+ var _product$metadata8, _ref72, _ref73, _existed$origin, _rawProduct$metadata;
5463
5204
  var _step22$value = _slicedToArray(_step22.value, 2),
5464
5205
  index = _step22$value[0],
5465
5206
  product = _step22$value[1];
@@ -5467,7 +5208,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5467
5208
  if (!uid) continue;
5468
5209
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5469
5210
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5470
- 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;
5471
5212
  var originSnapshot = cloneDeep(origin);
5472
5213
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5473
5214
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5577,10 +5318,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5577
5318
  }, {
5578
5319
  key: "normalizeHydratedProductOptionItem",
5579
5320
  value: function normalizeHydratedProductOptionItem(optionItem) {
5580
- var _ref76, _optionItem$num, _ref77, _optionItem$add_price;
5581
- 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;
5582
5323
  var parsedNum = Number(rawNum);
5583
- 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;
5584
5325
  var parsedPrice = Number(rawPrice);
5585
5326
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5586
5327
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -5597,7 +5338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5597
5338
  }, {
5598
5339
  key: "normalizeHydratedOrderProduct",
5599
5340
  value: function normalizeHydratedOrderProduct(product) {
5600
- var _this27 = this;
5341
+ var _this26 = this;
5601
5342
  var row = _objectSpread({}, product || {});
5602
5343
  if (row.num === undefined && row.product_quantity !== undefined) {
5603
5344
  row.num = row.product_quantity;
@@ -5605,7 +5346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5605
5346
  var productSku = ensureProductSku(row);
5606
5347
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5607
5348
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5608
- return _this27.normalizeHydratedProductOptionItem(optionItem || {});
5349
+ return _this26.normalizeHydratedProductOptionItem(optionItem || {});
5609
5350
  }))
5610
5351
  });
5611
5352
  delete row["product_".concat('option', "_item")];
@@ -5614,7 +5355,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5614
5355
  if (row.booking_uid && !row.metadata.booking_uid) {
5615
5356
  row.metadata.booking_uid = row.booking_uid;
5616
5357
  }
5617
- row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
5618
5358
  var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
5619
5359
  if (!existingIdentity) {
5620
5360
  row.metadata.unique_identification_number = createUuidV4();
@@ -5626,8 +5366,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5626
5366
  metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
5627
5367
  });
5628
5368
  if (result.metadata) delete result.metadata.price_schema_version;
5629
- var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
5630
- return this.sanitizeOrderProductForTempOrder(restored);
5369
+ return this.sanitizeOrderProductForTempOrder(result);
5631
5370
  }
5632
5371
  }, {
5633
5372
  key: "getLastOrderInfo",
@@ -5663,12 +5402,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5663
5402
  }
5664
5403
  return getOrderInfo;
5665
5404
  }()
5666
- }, {
5667
- key: "getVouchers",
5668
- value: function getVouchers() {
5669
- var _this$store$tempOrder5;
5670
- return ((_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.vouchers) || [];
5671
- }
5672
5405
  }], [{
5673
5406
  key: "populateSavedAmounts",
5674
5407
  value: function populateSavedAmounts(productList, discountList) {
@@ -5717,10 +5450,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5717
5450
  _step27;
5718
5451
  try {
5719
5452
  for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5720
- var _ref78, _bundle$num3;
5453
+ var _ref76, _bundle$num3;
5721
5454
  var bundle = _step27.value;
5722
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));
5723
- 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();
5724
5457
  var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5725
5458
  _step28;
5726
5459
  try {