@pisell/pisellos 2.3.20 → 2.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/Order/index.js +14 -6
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +10 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +392 -253
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +383 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +144 -127
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/Order/index.js +21 -7
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +10 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +83 -2
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +20 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +40 -22
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -3,8 +3,6 @@ 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 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; }
|
|
7
|
-
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; }
|
|
8
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -20,15 +18,17 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
20
18
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
20
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
|
-
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); }
|
|
26
21
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
27
22
|
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."); }
|
|
28
23
|
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); }
|
|
29
24
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
30
25
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
31
26
|
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; }
|
|
27
|
+
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; }
|
|
28
|
+
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; }
|
|
29
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
31
|
+
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); }
|
|
32
32
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
33
33
|
import { BaseModule } from "../../modules/BaseModule";
|
|
34
34
|
import { BaseSalesHookNames } from "./types";
|
|
@@ -92,7 +92,24 @@ function getBaseSalesMetadataUid(item, metadataKey) {
|
|
|
92
92
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
93
93
|
return String(uid);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function isBaseSalesBlankValue(value) {
|
|
96
|
+
return value === undefined || value === null || value === '';
|
|
97
|
+
}
|
|
98
|
+
function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
|
|
99
|
+
var _currentItem$metadata, _mergedItem$metadata, _mergedItem$metadata2;
|
|
100
|
+
var mergedItem = cloneDeep(loadedItem);
|
|
101
|
+
if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem === null || currentItem === void 0 ? void 0 : currentItem.product_cover)) {
|
|
102
|
+
mergedItem.product_cover = currentItem.product_cover;
|
|
103
|
+
}
|
|
104
|
+
var currentHolderConfig = currentItem === null || currentItem === void 0 || (_currentItem$metadata = currentItem.metadata) === null || _currentItem$metadata === void 0 ? void 0 : _currentItem$metadata.holder_config;
|
|
105
|
+
if ((((_mergedItem$metadata = mergedItem.metadata) === null || _mergedItem$metadata === void 0 ? void 0 : _mergedItem$metadata.holder_config) === undefined || ((_mergedItem$metadata2 = mergedItem.metadata) === null || _mergedItem$metadata2 === void 0 ? void 0 : _mergedItem$metadata2.holder_config) === null) && currentHolderConfig !== undefined && currentHolderConfig !== null) {
|
|
106
|
+
mergedItem.metadata = _objectSpread(_objectSpread({}, mergedItem.metadata || {}), {}, {
|
|
107
|
+
holder_config: currentHolderConfig
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return mergedItem;
|
|
111
|
+
}
|
|
112
|
+
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, arrayKey) {
|
|
96
113
|
var result = [];
|
|
97
114
|
var indexByUid = new Map();
|
|
98
115
|
var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
|
|
@@ -104,7 +121,7 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
104
121
|
}
|
|
105
122
|
var existingIndex = indexByUid.get(uid);
|
|
106
123
|
if (existingIndex !== undefined) {
|
|
107
|
-
result[existingIndex] = clonedItem;
|
|
124
|
+
result[existingIndex] = arrayKey === 'products' ? mergeBaseSalesProductSnapshotFields(result[existingIndex], clonedItem) : clonedItem;
|
|
108
125
|
return;
|
|
109
126
|
}
|
|
110
127
|
indexByUid.set(uid, result.length);
|
|
@@ -120,7 +137,7 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
|
120
137
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
121
138
|
var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
122
139
|
if (metadataKey) {
|
|
123
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
140
|
+
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, key);
|
|
124
141
|
}
|
|
125
142
|
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
126
143
|
}
|
|
@@ -291,22 +308,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
308
|
return _context2.abrupt("return");
|
|
292
309
|
case 8:
|
|
293
310
|
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
294
|
-
var
|
|
311
|
+
var _getTempOrder, _ref2;
|
|
312
|
+
var currentTempOrder, record, sales;
|
|
295
313
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
296
314
|
while (1) switch (_context.prev = _context.next) {
|
|
297
315
|
case 0:
|
|
298
|
-
|
|
299
|
-
|
|
316
|
+
currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
|
|
317
|
+
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder);
|
|
318
|
+
_context.next = 4;
|
|
319
|
+
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
300
320
|
recalcOnHydrate: false
|
|
301
321
|
});
|
|
302
|
-
case
|
|
322
|
+
case 4:
|
|
303
323
|
sales = _context.sent;
|
|
304
324
|
_this2.currentSalesDetail = sales;
|
|
305
|
-
_context.next =
|
|
325
|
+
_context.next = 8;
|
|
306
326
|
return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
|
|
307
327
|
sales: sales
|
|
308
328
|
});
|
|
309
|
-
case
|
|
329
|
+
case 8:
|
|
310
330
|
case "end":
|
|
311
331
|
return _context.stop();
|
|
312
332
|
}
|
|
@@ -411,10 +431,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
411
431
|
});
|
|
412
432
|
}
|
|
413
433
|
quotation.setScheduleResolver(function (id) {
|
|
414
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
434
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref3;
|
|
415
435
|
var scheduleId = String(id);
|
|
416
436
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
417
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
437
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref3 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref3, [id])) || [];
|
|
418
438
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
419
439
|
return schedules[0];
|
|
420
440
|
});
|
|
@@ -601,10 +621,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
601
621
|
return groups.flatMap(function (group) {
|
|
602
622
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
603
623
|
return items.map(function (item) {
|
|
604
|
-
var _item$group_id,
|
|
624
|
+
var _item$group_id, _ref4, _item$bundle_group_id;
|
|
605
625
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
606
626
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
607
|
-
bundle_group_id: (
|
|
627
|
+
bundle_group_id: (_ref4 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref4 !== void 0 ? _ref4 : group === null || group === void 0 ? void 0 : group.id
|
|
608
628
|
});
|
|
609
629
|
});
|
|
610
630
|
});
|
|
@@ -635,21 +655,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
635
655
|
}, {
|
|
636
656
|
key: "getAuthoritativeBundleUnitPrice",
|
|
637
657
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
638
|
-
var
|
|
639
|
-
return (
|
|
658
|
+
var _ref5, _ref6, _ref7, _bundle$price;
|
|
659
|
+
return (_ref5 = (_ref6 = (_ref7 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.product_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.base_price;
|
|
640
660
|
}
|
|
641
661
|
}, {
|
|
642
662
|
key: "mergeProductForPriceQuery",
|
|
643
663
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
644
664
|
var _this4 = this,
|
|
645
665
|
_product$id,
|
|
646
|
-
_ref7,
|
|
647
|
-
_product$product_id2,
|
|
648
666
|
_ref8,
|
|
649
|
-
_product$
|
|
667
|
+
_product$product_id2,
|
|
650
668
|
_ref9,
|
|
651
|
-
_product$
|
|
669
|
+
_product$product_vari,
|
|
652
670
|
_ref10,
|
|
671
|
+
_product$num,
|
|
672
|
+
_ref11,
|
|
653
673
|
_product$quantity,
|
|
654
674
|
_product$metadata4;
|
|
655
675
|
if (!authoritativeProduct) return product;
|
|
@@ -669,10 +689,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
689
|
});
|
|
670
690
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
671
691
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
672
|
-
product_id: (
|
|
673
|
-
product_variant_id: (
|
|
674
|
-
num: (
|
|
675
|
-
quantity: (
|
|
692
|
+
product_id: (_ref8 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.id,
|
|
693
|
+
product_variant_id: (_ref9 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0,
|
|
694
|
+
num: (_ref10 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref10 !== void 0 ? _ref10 : authoritativeProduct.num,
|
|
695
|
+
quantity: (_ref11 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.quantity,
|
|
676
696
|
product_sku: function () {
|
|
677
697
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
678
698
|
var productSku = ensureProductSku(product);
|
|
@@ -748,24 +768,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
748
768
|
value: (function () {
|
|
749
769
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
|
|
750
770
|
var _this5 = this;
|
|
751
|
-
var
|
|
752
|
-
|
|
771
|
+
var _ref12,
|
|
772
|
+
_ref12$cover,
|
|
753
773
|
cover,
|
|
754
774
|
nextSubModuleOtherParams,
|
|
755
775
|
_args7 = arguments;
|
|
756
776
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
757
777
|
while (1) switch (_context7.prev = _context7.next) {
|
|
758
778
|
case 0:
|
|
759
|
-
|
|
779
|
+
_ref12 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
|
|
760
780
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
761
781
|
_context7.next = 4;
|
|
762
782
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
763
|
-
var
|
|
764
|
-
var
|
|
783
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref13) {
|
|
784
|
+
var _ref15, moduleName, subModule, targetModule;
|
|
765
785
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
766
786
|
while (1) switch (_context6.prev = _context6.next) {
|
|
767
787
|
case 0:
|
|
768
|
-
|
|
788
|
+
_ref15 = _slicedToArray(_ref13, 2), moduleName = _ref15[0], subModule = _ref15[1];
|
|
769
789
|
if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
|
|
770
790
|
_context6.next = 3;
|
|
771
791
|
break;
|
|
@@ -791,7 +811,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
791
811
|
}, _callee6);
|
|
792
812
|
}));
|
|
793
813
|
return function (_x7) {
|
|
794
|
-
return
|
|
814
|
+
return _ref14.apply(this, arguments);
|
|
795
815
|
};
|
|
796
816
|
}()));
|
|
797
817
|
case 4:
|
|
@@ -1004,7 +1024,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
1024
|
key: "loadSalesDetail",
|
|
1005
1025
|
value: (function () {
|
|
1006
1026
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderIdOrParams) {
|
|
1007
|
-
var
|
|
1027
|
+
var _ref16, _ref17, _ref18, _ref19, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
|
|
1008
1028
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1009
1029
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1010
1030
|
case 0:
|
|
@@ -1021,7 +1041,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1021
1041
|
};
|
|
1022
1042
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1023
1043
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1024
|
-
lookup = (
|
|
1044
|
+
lookup = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref19 !== void 0 ? _ref19 : params.orderNumber) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref16 !== void 0 ? _ref16 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1025
1045
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1026
1046
|
_context10.next = 10;
|
|
1027
1047
|
break;
|
|
@@ -1613,7 +1633,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
1633
|
value: function () {
|
|
1614
1634
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1615
1635
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1616
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary,
|
|
1636
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1617
1637
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1618
1638
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1619
1639
|
case 0:
|
|
@@ -1707,16 +1727,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1707
1727
|
});
|
|
1708
1728
|
case 40:
|
|
1709
1729
|
if (!rulesModule) {
|
|
1710
|
-
_context17.next =
|
|
1730
|
+
_context17.next = 77;
|
|
1711
1731
|
break;
|
|
1712
1732
|
}
|
|
1713
|
-
holders = ((_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
1714
1733
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
1715
1734
|
console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
|
|
1716
1735
|
result = rulesModule.calcDiscount({
|
|
1717
1736
|
productList: tempOrder.products,
|
|
1718
1737
|
discountList: nextDiscountList,
|
|
1719
|
-
holders:
|
|
1738
|
+
holders: [],
|
|
1720
1739
|
isFormSubject: function isFormSubject(product) {
|
|
1721
1740
|
return resolveIsFormSubject(tempOrder, product);
|
|
1722
1741
|
},
|
|
@@ -1729,22 +1748,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1729
1748
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1730
1749
|
}
|
|
1731
1750
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1732
|
-
_context17.prev =
|
|
1751
|
+
_context17.prev = 46;
|
|
1733
1752
|
_iterator.s();
|
|
1734
|
-
case
|
|
1753
|
+
case 48:
|
|
1735
1754
|
if ((_step = _iterator.n()).done) {
|
|
1736
|
-
_context17.next =
|
|
1755
|
+
_context17.next = 63;
|
|
1737
1756
|
break;
|
|
1738
1757
|
}
|
|
1739
1758
|
product = _step.value;
|
|
1740
1759
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
1741
1760
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
1742
1761
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1743
|
-
_context17.next =
|
|
1762
|
+
_context17.next = 54;
|
|
1744
1763
|
break;
|
|
1745
1764
|
}
|
|
1746
|
-
return _context17.abrupt("continue",
|
|
1747
|
-
case
|
|
1765
|
+
return _context17.abrupt("continue", 61);
|
|
1766
|
+
case 54:
|
|
1748
1767
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1749
1768
|
return sum + Number(pd.amount || 0);
|
|
1750
1769
|
}, 0);
|
|
@@ -1760,58 +1779,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1760
1779
|
mainPrice: newMainSellingPrice,
|
|
1761
1780
|
bundle: product.product_bundle
|
|
1762
1781
|
});
|
|
1763
|
-
case
|
|
1764
|
-
_context17.next =
|
|
1782
|
+
case 61:
|
|
1783
|
+
_context17.next = 48;
|
|
1765
1784
|
break;
|
|
1766
|
-
case
|
|
1767
|
-
_context17.next =
|
|
1785
|
+
case 63:
|
|
1786
|
+
_context17.next = 68;
|
|
1768
1787
|
break;
|
|
1769
|
-
case
|
|
1770
|
-
_context17.prev =
|
|
1771
|
-
_context17.t0 = _context17["catch"](
|
|
1788
|
+
case 65:
|
|
1789
|
+
_context17.prev = 65;
|
|
1790
|
+
_context17.t0 = _context17["catch"](46);
|
|
1772
1791
|
_iterator.e(_context17.t0);
|
|
1773
|
-
case
|
|
1774
|
-
_context17.prev =
|
|
1792
|
+
case 68:
|
|
1793
|
+
_context17.prev = 68;
|
|
1775
1794
|
_iterator.f();
|
|
1776
|
-
return _context17.finish(
|
|
1777
|
-
case
|
|
1795
|
+
return _context17.finish(68);
|
|
1796
|
+
case 71:
|
|
1778
1797
|
if (!result.discountList) {
|
|
1779
|
-
_context17.next =
|
|
1798
|
+
_context17.next = 77;
|
|
1780
1799
|
break;
|
|
1781
1800
|
}
|
|
1782
1801
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1783
1802
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1784
|
-
_context17.next =
|
|
1803
|
+
_context17.next = 76;
|
|
1785
1804
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1786
|
-
case
|
|
1805
|
+
case 76:
|
|
1787
1806
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1788
1807
|
return discount.isSelected;
|
|
1789
1808
|
});
|
|
1790
|
-
case
|
|
1791
|
-
_context17.next =
|
|
1809
|
+
case 77:
|
|
1810
|
+
_context17.next = 79;
|
|
1792
1811
|
return this.store.order.recalculateSummary({
|
|
1793
1812
|
createIfMissing: true
|
|
1794
1813
|
});
|
|
1795
|
-
case
|
|
1814
|
+
case 79:
|
|
1796
1815
|
summary = _context17.sent;
|
|
1797
1816
|
this.store.order.persistTempOrder();
|
|
1798
|
-
_context17.next =
|
|
1817
|
+
_context17.next = 83;
|
|
1799
1818
|
return this.effectsEmit('onDiscountApplied', {
|
|
1800
1819
|
productList: tempOrder.products || [],
|
|
1801
1820
|
discountList: nextDiscountList,
|
|
1802
1821
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1803
1822
|
tempOrder: tempOrder
|
|
1804
1823
|
});
|
|
1805
|
-
case
|
|
1824
|
+
case 83:
|
|
1806
1825
|
return _context17.abrupt("return", {
|
|
1807
1826
|
productList: tempOrder.products || [],
|
|
1808
1827
|
discountList: nextDiscountList
|
|
1809
1828
|
});
|
|
1810
|
-
case
|
|
1829
|
+
case 84:
|
|
1811
1830
|
case "end":
|
|
1812
1831
|
return _context17.stop();
|
|
1813
1832
|
}
|
|
1814
|
-
}, _callee17, this, [[
|
|
1833
|
+
}, _callee17, this, [[46, 65, 68, 71]]);
|
|
1815
1834
|
}));
|
|
1816
1835
|
function loadDiscountConfig(_x11) {
|
|
1817
1836
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -1823,7 +1842,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
1842
|
value: function () {
|
|
1824
1843
|
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
|
|
1825
1844
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1826
|
-
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result,
|
|
1845
|
+
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
1827
1846
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1828
1847
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1829
1848
|
case 0:
|
|
@@ -1848,16 +1867,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1867
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1849
1868
|
case 12:
|
|
1850
1869
|
if (!rulesModule) {
|
|
1851
|
-
_context18.next =
|
|
1870
|
+
_context18.next = 24;
|
|
1852
1871
|
break;
|
|
1853
1872
|
}
|
|
1854
|
-
holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
1855
1873
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
1856
1874
|
console.log('[BaseSales.bestDiscount.calcDiscount]');
|
|
1857
1875
|
result = rulesModule.calcDiscount({
|
|
1858
1876
|
productList: tempOrder.products,
|
|
1859
1877
|
discountList: nextDiscountList,
|
|
1860
|
-
holders:
|
|
1878
|
+
holders: [],
|
|
1861
1879
|
isFormSubject: function isFormSubject(product) {
|
|
1862
1880
|
return resolveIsFormSubject(tempOrder, product);
|
|
1863
1881
|
},
|
|
@@ -1867,14 +1885,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1867
1885
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1868
1886
|
}
|
|
1869
1887
|
if (!result.discountList) {
|
|
1870
|
-
_context18.next =
|
|
1888
|
+
_context18.next = 24;
|
|
1871
1889
|
break;
|
|
1872
1890
|
}
|
|
1873
1891
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1874
1892
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1875
|
-
_context18.next =
|
|
1893
|
+
_context18.next = 22;
|
|
1876
1894
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1877
|
-
case
|
|
1895
|
+
case 22:
|
|
1878
1896
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1879
1897
|
return discount.isSelected;
|
|
1880
1898
|
});
|
|
@@ -1882,16 +1900,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1882
1900
|
productList: tempOrder.products,
|
|
1883
1901
|
discountList: nextDiscountList
|
|
1884
1902
|
};
|
|
1885
|
-
case
|
|
1886
|
-
_context18.next =
|
|
1903
|
+
case 24:
|
|
1904
|
+
_context18.next = 26;
|
|
1887
1905
|
return this.store.order.recalculateSummary({
|
|
1888
1906
|
createIfMissing: true
|
|
1889
1907
|
});
|
|
1890
|
-
case
|
|
1908
|
+
case 26:
|
|
1891
1909
|
this.store.order.persistTempOrder();
|
|
1892
1910
|
cb === null || cb === void 0 || cb(result);
|
|
1893
1911
|
return _context18.abrupt("return", result);
|
|
1894
|
-
case
|
|
1912
|
+
case 29:
|
|
1895
1913
|
case "end":
|
|
1896
1914
|
return _context18.stop();
|
|
1897
1915
|
}
|
|
@@ -1962,7 +1980,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1962
1980
|
key: "setDiscountSelected",
|
|
1963
1981
|
value: function () {
|
|
1964
1982
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1965
|
-
var
|
|
1983
|
+
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1966
1984
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1967
1985
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1968
1986
|
case 0:
|
|
@@ -1985,18 +2003,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1985
2003
|
orderStore = this.store.order.store || {};
|
|
1986
2004
|
discountModule = orderStore.discount;
|
|
1987
2005
|
rulesModule = orderStore.rules;
|
|
1988
|
-
holders = ((_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_record) || [];
|
|
1989
2006
|
nextDiscountList = updated;
|
|
1990
|
-
_context20.next =
|
|
2007
|
+
_context20.next = 13;
|
|
1991
2008
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1992
|
-
case
|
|
2009
|
+
case 13:
|
|
1993
2010
|
if (rulesModule) {
|
|
1994
2011
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
1995
2012
|
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
1996
2013
|
result = rulesModule.calcDiscount({
|
|
1997
2014
|
productList: tempOrder.products,
|
|
1998
2015
|
discountList: updated,
|
|
1999
|
-
holders:
|
|
2016
|
+
holders: [],
|
|
2000
2017
|
isFormSubject: function isFormSubject(product) {
|
|
2001
2018
|
return resolveIsFormSubject(tempOrder, product);
|
|
2002
2019
|
},
|
|
@@ -2050,29 +2067,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2050
2067
|
});
|
|
2051
2068
|
};
|
|
2052
2069
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
2053
|
-
_context20.prev =
|
|
2070
|
+
_context20.prev = 17;
|
|
2054
2071
|
_iterator3.s();
|
|
2055
|
-
case
|
|
2072
|
+
case 19:
|
|
2056
2073
|
if ((_step3 = _iterator3.n()).done) {
|
|
2057
|
-
_context20.next =
|
|
2074
|
+
_context20.next = 36;
|
|
2058
2075
|
break;
|
|
2059
2076
|
}
|
|
2060
2077
|
product = _step3.value;
|
|
2061
2078
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2062
2079
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
2063
2080
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2064
|
-
_context20.next =
|
|
2081
|
+
_context20.next = 25;
|
|
2065
2082
|
break;
|
|
2066
2083
|
}
|
|
2067
|
-
return _context20.abrupt("continue",
|
|
2068
|
-
case
|
|
2084
|
+
return _context20.abrupt("continue", 34);
|
|
2085
|
+
case 25:
|
|
2069
2086
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2070
2087
|
if (Array.isArray(product.product_bundle)) {
|
|
2071
2088
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2072
|
-
var
|
|
2089
|
+
var _ref20, _bundle$original_pric;
|
|
2073
2090
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2074
2091
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2075
|
-
var restoredBundlePrice = (
|
|
2092
|
+
var restoredBundlePrice = (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2076
2093
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2077
2094
|
price: restoredBundlePrice,
|
|
2078
2095
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2099,33 +2116,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
2116
|
mainPrice: newMainSellingPrice,
|
|
2100
2117
|
bundle: product.product_bundle
|
|
2101
2118
|
});
|
|
2102
|
-
case
|
|
2103
|
-
_context20.next =
|
|
2119
|
+
case 34:
|
|
2120
|
+
_context20.next = 19;
|
|
2104
2121
|
break;
|
|
2105
|
-
case
|
|
2106
|
-
_context20.next =
|
|
2122
|
+
case 36:
|
|
2123
|
+
_context20.next = 41;
|
|
2107
2124
|
break;
|
|
2108
|
-
case
|
|
2109
|
-
_context20.prev =
|
|
2110
|
-
_context20.t0 = _context20["catch"](
|
|
2125
|
+
case 38:
|
|
2126
|
+
_context20.prev = 38;
|
|
2127
|
+
_context20.t0 = _context20["catch"](17);
|
|
2111
2128
|
_iterator3.e(_context20.t0);
|
|
2112
|
-
case
|
|
2113
|
-
_context20.prev =
|
|
2129
|
+
case 41:
|
|
2130
|
+
_context20.prev = 41;
|
|
2114
2131
|
_iterator3.f();
|
|
2115
|
-
return _context20.finish(
|
|
2116
|
-
case
|
|
2132
|
+
return _context20.finish(41);
|
|
2133
|
+
case 44:
|
|
2117
2134
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2118
|
-
_context20.next =
|
|
2135
|
+
_context20.next = 47;
|
|
2119
2136
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2120
|
-
case
|
|
2137
|
+
case 47:
|
|
2121
2138
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2122
2139
|
return d.isSelected;
|
|
2123
2140
|
});
|
|
2124
|
-
_context20.next =
|
|
2141
|
+
_context20.next = 50;
|
|
2125
2142
|
return this.store.order.recalculateSummary({
|
|
2126
2143
|
createIfMissing: true
|
|
2127
2144
|
});
|
|
2128
|
-
case
|
|
2145
|
+
case 50:
|
|
2129
2146
|
this.store.order.persistTempOrder();
|
|
2130
2147
|
this.effectsEmit('onDiscountApplied', {
|
|
2131
2148
|
productList: tempOrder.products,
|
|
@@ -2133,17 +2150,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2133
2150
|
selectedDiscountList: tempOrder.discount_list,
|
|
2134
2151
|
tempOrder: tempOrder
|
|
2135
2152
|
});
|
|
2136
|
-
_context20.next =
|
|
2153
|
+
_context20.next = 57;
|
|
2137
2154
|
break;
|
|
2138
|
-
case
|
|
2139
|
-
_context20.prev =
|
|
2155
|
+
case 54:
|
|
2156
|
+
_context20.prev = 54;
|
|
2140
2157
|
_context20.t1 = _context20["catch"](0);
|
|
2141
2158
|
throw _context20.t1;
|
|
2142
|
-
case
|
|
2159
|
+
case 57:
|
|
2143
2160
|
case "end":
|
|
2144
2161
|
return _context20.stop();
|
|
2145
2162
|
}
|
|
2146
|
-
}, _callee20, this, [[0,
|
|
2163
|
+
}, _callee20, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2147
2164
|
}));
|
|
2148
2165
|
function setDiscountSelected(_x15) {
|
|
2149
2166
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -2413,7 +2430,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2413
2430
|
key: "syncPaymentsToOrder",
|
|
2414
2431
|
value: function () {
|
|
2415
2432
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2416
|
-
var
|
|
2433
|
+
var _ref21, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
|
|
2417
2434
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2418
2435
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2419
2436
|
while (1) switch (_context26.prev = _context26.next) {
|
|
@@ -2424,7 +2441,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2424
2441
|
}
|
|
2425
2442
|
throw new Error('order 模块未初始化');
|
|
2426
2443
|
case 2:
|
|
2427
|
-
businessCode = (
|
|
2444
|
+
businessCode = (_ref21 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref21 !== void 0 ? _ref21 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
|
|
2428
2445
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2429
2446
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2430
2447
|
businessCode: businessCode
|
|
@@ -2634,7 +2651,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2634
2651
|
var _this$otherParams20,
|
|
2635
2652
|
_paymentRecord$paymen,
|
|
2636
2653
|
_paymentRecord$create,
|
|
2637
|
-
|
|
2654
|
+
_ref22,
|
|
2638
2655
|
_paymentRecord$origin,
|
|
2639
2656
|
_this11 = this;
|
|
2640
2657
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -2658,7 +2675,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2658
2675
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
2659
2676
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
2660
2677
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
2661
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
2678
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
2662
2679
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
2663
2680
|
service_fee: calculatedServiceFee
|
|
2664
2681
|
} : {}), {}, {
|
|
@@ -2787,7 +2804,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2787
2804
|
key: "initWalletData",
|
|
2788
2805
|
value: function () {
|
|
2789
2806
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2790
|
-
var _params$order_wait_pa,
|
|
2807
|
+
var _params$order_wait_pa, _ref23, _tempOrder$is_price_i;
|
|
2791
2808
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2792
2809
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2793
2810
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -2830,7 +2847,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2830
2847
|
},
|
|
2831
2848
|
products: this.getWalletProductList(),
|
|
2832
2849
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
2833
|
-
is_price_include_tax: (
|
|
2850
|
+
is_price_include_tax: (_ref23 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref23 !== void 0 ? _ref23 : 1
|
|
2834
2851
|
}, snapshot.identity.orderId ? {
|
|
2835
2852
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2836
2853
|
} : {});
|
|
@@ -2961,7 +2978,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2961
2978
|
key: "sendCustomerPayLink",
|
|
2962
2979
|
value: (function () {
|
|
2963
2980
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2964
|
-
var orderIds,
|
|
2981
|
+
var orderIds, _ref24, _ref25, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2965
2982
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2966
2983
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2967
2984
|
case 0:
|
|
@@ -2982,7 +2999,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2982
2999
|
});
|
|
2983
3000
|
case 6:
|
|
2984
3001
|
submitResult = _context30.sent;
|
|
2985
|
-
orderId = (
|
|
3002
|
+
orderId = (_ref24 = (_ref25 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref24 !== void 0 ? _ref24 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2986
3003
|
if (orderId) {
|
|
2987
3004
|
_context30.next = 10;
|
|
2988
3005
|
break;
|
|
@@ -3154,12 +3171,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3154
3171
|
});
|
|
3155
3172
|
_context33.next = 9;
|
|
3156
3173
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3157
|
-
var
|
|
3158
|
-
var
|
|
3174
|
+
var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(_ref26) {
|
|
3175
|
+
var _ref28, groupKey, group, productsById;
|
|
3159
3176
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3160
3177
|
while (1) switch (_context32.prev = _context32.next) {
|
|
3161
3178
|
case 0:
|
|
3162
|
-
|
|
3179
|
+
_ref28 = _slicedToArray(_ref26, 2), groupKey = _ref28[0], group = _ref28[1];
|
|
3163
3180
|
_context32.next = 3;
|
|
3164
3181
|
return _this13.loadProductsForPriceQuery({
|
|
3165
3182
|
ids: Array.from(group.ids),
|
|
@@ -3177,7 +3194,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3177
3194
|
}, _callee32);
|
|
3178
3195
|
}));
|
|
3179
3196
|
return function (_x26) {
|
|
3180
|
-
return
|
|
3197
|
+
return _ref27.apply(this, arguments);
|
|
3181
3198
|
};
|
|
3182
3199
|
}()));
|
|
3183
3200
|
case 9:
|
|
@@ -3606,14 +3623,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3606
3623
|
value: function () {
|
|
3607
3624
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
3608
3625
|
var _this$otherParams22;
|
|
3609
|
-
var
|
|
3610
|
-
|
|
3626
|
+
var _ref29,
|
|
3627
|
+
_ref29$cover,
|
|
3611
3628
|
cover,
|
|
3612
3629
|
_args43 = arguments;
|
|
3613
3630
|
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3614
3631
|
while (1) switch (_context43.prev = _context43.next) {
|
|
3615
3632
|
case 0:
|
|
3616
|
-
|
|
3633
|
+
_ref29 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref29$cover = _ref29.cover, cover = _ref29$cover === void 0 ? false : _ref29$cover;
|
|
3617
3634
|
if (cover) {
|
|
3618
3635
|
this.otherParams = _objectSpread({}, params);
|
|
3619
3636
|
} else {
|