@pisell/pisellos 2.3.6 → 2.3.7
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 +17 -13
- package/dist/modules/Order/index.js +146 -113
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +31 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +8 -3
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.js +60 -53
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.js +54 -17
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +39 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.js +20 -13
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ 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 } 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, resolveIsFormSubject } 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";
|
|
@@ -224,6 +224,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
224
224
|
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
225
225
|
product.metadata.price_schema_version = 2;
|
|
226
226
|
}
|
|
227
|
+
if (Array.isArray(product.product_bundle)) {
|
|
228
|
+
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
229
|
+
var _ref12, _bundle$original_pric;
|
|
230
|
+
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
231
|
+
if (hasBundleDiscount) return bundle;
|
|
232
|
+
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;
|
|
233
|
+
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
234
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
235
|
+
price: restoredPrice,
|
|
236
|
+
bundle_selling_price: restoredPrice
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
227
240
|
product.selling_price = composeLinePrice({
|
|
228
241
|
mainPrice: newMainSellingPrice,
|
|
229
242
|
bundle: product.product_bundle
|
|
@@ -553,8 +566,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
553
566
|
key: "scanCode",
|
|
554
567
|
value: function () {
|
|
555
568
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
556
|
-
var _this$store$discount7, _tempOrder$holder, _this$store$summary
|
|
557
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
569
|
+
var _this$store$discount7, _tempOrder$holder, _this$store$summary;
|
|
570
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
|
|
558
571
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
559
572
|
while (1) switch (_context5.prev = _context5.next) {
|
|
560
573
|
case 0:
|
|
@@ -624,20 +637,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
624
637
|
});
|
|
625
638
|
case 16:
|
|
626
639
|
tempOrder = this.store.tempOrder;
|
|
627
|
-
holders = tempOrder
|
|
628
|
-
|
|
629
|
-
}] : [];
|
|
630
|
-
_ref12 = rulesModule.isDiscountListAvailable({
|
|
640
|
+
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
641
|
+
_ref13 = rulesModule.isDiscountListAvailable({
|
|
631
642
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
632
643
|
oldDiscountList: this.getDiscountList(),
|
|
633
644
|
newDiscountList: withScanList,
|
|
634
645
|
orderTotalAmount: Number(((_this$store$summary = this.store.summary) === null || _this$store$summary === void 0 ? void 0 : _this$store$summary.total_amount) || 0),
|
|
635
646
|
holders: holders,
|
|
636
|
-
isFormSubject:
|
|
647
|
+
isFormSubject: function isFormSubject(product) {
|
|
648
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
649
|
+
}
|
|
637
650
|
}) || {
|
|
638
651
|
isAvailable: false,
|
|
639
652
|
discountList: this.getDiscountList()
|
|
640
|
-
}, isAvailable =
|
|
653
|
+
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
641
654
|
if (isAvailable && newDiscountList) {
|
|
642
655
|
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
|
|
643
656
|
this.applyDiscount();
|
|
@@ -664,8 +677,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
664
677
|
key: "applyDiscount",
|
|
665
678
|
value: function applyDiscount() {
|
|
666
679
|
var _this$store$discount9,
|
|
667
|
-
_tempOrder$
|
|
668
|
-
_tempOrder$holder4,
|
|
680
|
+
_tempOrder$holder2,
|
|
669
681
|
_this$store$summary2,
|
|
670
682
|
_this2 = this;
|
|
671
683
|
var tempOrder = this.store.tempOrder;
|
|
@@ -674,26 +686,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
674
686
|
// appliedProductDetails / savedAmount 复位。
|
|
675
687
|
if (!tempOrder) return;
|
|
676
688
|
delete tempOrder.discount_list;
|
|
677
|
-
|
|
689
|
+
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
690
|
+
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
691
|
+
if (shouldSkipDiscountCalculation) return;
|
|
678
692
|
var rulesModule = this.store.rules;
|
|
679
693
|
if (!rulesModule) return;
|
|
680
|
-
var
|
|
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
|
-
}] : [];
|
|
694
|
+
var holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
684
695
|
var result = rulesModule.calcDiscount({
|
|
685
696
|
productList: tempOrder.products,
|
|
686
697
|
discountList: discountList,
|
|
687
698
|
holders: holders,
|
|
688
|
-
isFormSubject:
|
|
699
|
+
isFormSubject: function isFormSubject(product) {
|
|
700
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
701
|
+
},
|
|
689
702
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
690
703
|
});
|
|
691
704
|
if (result !== null && result !== void 0 && result.productList) {
|
|
692
705
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
693
706
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
694
|
-
var
|
|
707
|
+
var _ref14;
|
|
695
708
|
var uid = getOrderProductLineUid(product);
|
|
696
|
-
var previous = (
|
|
709
|
+
var previous = (_ref14 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref14 !== void 0 ? _ref14 : previousProductsByUid.get("__index__:".concat(index));
|
|
697
710
|
if (isManualProductDiscountProduct(previous)) {
|
|
698
711
|
return previous;
|
|
699
712
|
}
|
|
@@ -1218,15 +1231,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1218
1231
|
}, {
|
|
1219
1232
|
key: "extractOrderIdFromSubmitResult",
|
|
1220
1233
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1221
|
-
var
|
|
1222
|
-
return (
|
|
1234
|
+
var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
|
|
1235
|
+
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;
|
|
1223
1236
|
}
|
|
1224
1237
|
}, {
|
|
1225
1238
|
key: "calculatePaymentEffectiveAmount",
|
|
1226
1239
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1227
|
-
var
|
|
1240
|
+
var _ref18, _payment$origin_amoun;
|
|
1228
1241
|
var amount = new Decimal(payment.amount || 0);
|
|
1229
|
-
var originAmount = new Decimal((
|
|
1242
|
+
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);
|
|
1230
1243
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1231
1244
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1232
1245
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1315,13 +1328,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1328
|
})
|
|
1316
1329
|
});
|
|
1317
1330
|
tempOrder.deposit_amount = snapshot.depositAmount;
|
|
1318
|
-
tempOrder.is_deposit = snapshot.isDeposit;
|
|
1331
|
+
tempOrder.is_deposit = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
|
|
1319
1332
|
return nextSummary;
|
|
1320
1333
|
}
|
|
1321
1334
|
}, {
|
|
1322
1335
|
key: "isDepositOrder",
|
|
1323
1336
|
value: function isDepositOrder(tempOrder, depositAmount) {
|
|
1324
|
-
return tempOrder.is_deposit === 1
|
|
1337
|
+
return tempOrder.is_deposit === 1 && depositAmount.gt(0);
|
|
1325
1338
|
}
|
|
1326
1339
|
}, {
|
|
1327
1340
|
key: "getOrderExpectedAmount",
|
|
@@ -1390,7 +1403,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1390
1403
|
}, {
|
|
1391
1404
|
key: "normalizePaymentSource",
|
|
1392
1405
|
value: function normalizePaymentSource(payment, options) {
|
|
1393
|
-
var
|
|
1406
|
+
var _ref19, _paymentRecord$origin;
|
|
1394
1407
|
var paymentRecord = payment;
|
|
1395
1408
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1396
1409
|
if (!metadata.unique_payment_number) {
|
|
@@ -1398,7 +1411,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1398
1411
|
}
|
|
1399
1412
|
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1400
1413
|
metadata: metadata,
|
|
1401
|
-
origin_amount: (
|
|
1414
|
+
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1402
1415
|
});
|
|
1403
1416
|
if (paymentRecord.status !== undefined) {
|
|
1404
1417
|
normalized.status = paymentRecord.status;
|
|
@@ -1731,7 +1744,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1731
1744
|
_product$payment_pric,
|
|
1732
1745
|
_sku$code,
|
|
1733
1746
|
_sku$barcode,
|
|
1734
|
-
|
|
1747
|
+
_ref20,
|
|
1735
1748
|
_sku$variant_id,
|
|
1736
1749
|
_this8 = this;
|
|
1737
1750
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -1758,24 +1771,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1758
1771
|
product_sku: this.normalizeFingerprintValue({
|
|
1759
1772
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
1760
1773
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
1761
|
-
variant_id: (
|
|
1774
|
+
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,
|
|
1762
1775
|
variant: sku.variant || [],
|
|
1763
1776
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1764
|
-
var
|
|
1777
|
+
var _ref21, _option$id, _option$option_group_, _ref22, _option$option_group_2, _option$num, _option$add_price;
|
|
1765
1778
|
return {
|
|
1766
|
-
id: (
|
|
1779
|
+
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,
|
|
1767
1780
|
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,
|
|
1768
|
-
option_group_item_id: (
|
|
1781
|
+
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,
|
|
1769
1782
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1770
1783
|
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)
|
|
1771
1784
|
};
|
|
1772
1785
|
})
|
|
1773
1786
|
}),
|
|
1774
1787
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1775
|
-
var
|
|
1788
|
+
var _ref23, _ref24, _bundle$bundle_produc, _ref25, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
1776
1789
|
return {
|
|
1777
|
-
bundle_product_id: (
|
|
1778
|
-
bundle_variant_id: (
|
|
1790
|
+
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,
|
|
1791
|
+
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,
|
|
1779
1792
|
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),
|
|
1780
1793
|
price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1781
1794
|
bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
@@ -1784,10 +1797,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1784
1797
|
};
|
|
1785
1798
|
})),
|
|
1786
1799
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1787
|
-
var
|
|
1800
|
+
var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
|
|
1788
1801
|
return {
|
|
1789
|
-
type: (
|
|
1790
|
-
discount_id: (
|
|
1802
|
+
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 : '',
|
|
1803
|
+
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,
|
|
1791
1804
|
amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1792
1805
|
};
|
|
1793
1806
|
}))
|
|
@@ -1811,14 +1824,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1811
1824
|
var _product$product_id3,
|
|
1812
1825
|
_product$product_vari2,
|
|
1813
1826
|
_product$num2,
|
|
1814
|
-
|
|
1827
|
+
_ref29,
|
|
1815
1828
|
_metadata$unique_iden,
|
|
1816
1829
|
_metadata$price_overr,
|
|
1817
1830
|
_metadata$is_manual_d,
|
|
1818
1831
|
_metadata$product_dis,
|
|
1819
1832
|
_sku$code2,
|
|
1820
1833
|
_sku$barcode2,
|
|
1821
|
-
|
|
1834
|
+
_ref30,
|
|
1822
1835
|
_sku$variant_id2,
|
|
1823
1836
|
_this10 = this;
|
|
1824
1837
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -1834,7 +1847,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1834
1847
|
extension_type: extensionType,
|
|
1835
1848
|
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),
|
|
1836
1849
|
metadata: {
|
|
1837
|
-
unique_identification_number: (
|
|
1850
|
+
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 : '',
|
|
1838
1851
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
1839
1852
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
1840
1853
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -1842,35 +1855,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1842
1855
|
product_sku: this.normalizeFingerprintValue({
|
|
1843
1856
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
1844
1857
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
1845
|
-
variant_id: (
|
|
1858
|
+
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,
|
|
1846
1859
|
variant: sku.variant || [],
|
|
1847
1860
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1848
|
-
var
|
|
1861
|
+
var _ref31, _option$id2, _option$option_group_3, _ref32, _option$option_group_4, _option$num2, _option$add_price2;
|
|
1849
1862
|
return {
|
|
1850
|
-
id: (
|
|
1863
|
+
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,
|
|
1851
1864
|
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,
|
|
1852
|
-
option_group_item_id: (
|
|
1865
|
+
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,
|
|
1853
1866
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1854
1867
|
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)
|
|
1855
1868
|
};
|
|
1856
1869
|
})
|
|
1857
1870
|
}),
|
|
1858
1871
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1859
|
-
var
|
|
1872
|
+
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;
|
|
1860
1873
|
return {
|
|
1861
|
-
bundle_id: (
|
|
1862
|
-
bundle_group_id: (
|
|
1863
|
-
bundle_product_id: (
|
|
1864
|
-
bundle_variant_id: (
|
|
1874
|
+
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,
|
|
1875
|
+
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,
|
|
1876
|
+
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,
|
|
1877
|
+
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,
|
|
1865
1878
|
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),
|
|
1866
1879
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1867
1880
|
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 : '',
|
|
1868
1881
|
option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
1869
|
-
var
|
|
1882
|
+
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1870
1883
|
return {
|
|
1871
|
-
id: (
|
|
1884
|
+
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,
|
|
1872
1885
|
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,
|
|
1873
|
-
option_group_item_id: (
|
|
1886
|
+
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,
|
|
1874
1887
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1875
1888
|
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)
|
|
1876
1889
|
};
|
|
@@ -1878,10 +1891,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1878
1891
|
};
|
|
1879
1892
|
})),
|
|
1880
1893
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1881
|
-
var
|
|
1894
|
+
var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
|
|
1882
1895
|
return {
|
|
1883
|
-
type: (
|
|
1884
|
-
discount_id: (
|
|
1896
|
+
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 : '',
|
|
1897
|
+
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,
|
|
1885
1898
|
amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1886
1899
|
};
|
|
1887
1900
|
}))
|
|
@@ -2161,11 +2174,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2161
2174
|
}, {
|
|
2162
2175
|
key: "getOrderIdentity",
|
|
2163
2176
|
value: function getOrderIdentity() {
|
|
2164
|
-
var
|
|
2177
|
+
var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
|
|
2165
2178
|
var tempOrder = this.store.tempOrder;
|
|
2166
2179
|
if (!tempOrder) return null;
|
|
2167
2180
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2168
|
-
var orderId = (
|
|
2181
|
+
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;
|
|
2169
2182
|
return {
|
|
2170
2183
|
localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
|
|
2171
2184
|
orderId: orderId,
|
|
@@ -2200,7 +2213,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2200
2213
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
2201
2214
|
});
|
|
2202
2215
|
return {
|
|
2203
|
-
isDeposit: tempOrder.is_deposit === 1
|
|
2216
|
+
isDeposit: tempOrder.is_deposit === 1,
|
|
2204
2217
|
depositAmount: depositAmount,
|
|
2205
2218
|
expectAmount: summary.expect_amount || '0.00',
|
|
2206
2219
|
totalAmount: summary.total_amount || '0.00',
|
|
@@ -2318,11 +2331,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2318
2331
|
}, {
|
|
2319
2332
|
key: "captureProductRuntime",
|
|
2320
2333
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2321
|
-
var _extend$productsByUid,
|
|
2334
|
+
var _extend$productsByUid, _ref45, _rawProduct$_origin;
|
|
2322
2335
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2323
2336
|
var extend = this.ensureExtend(tempOrder);
|
|
2324
2337
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2325
|
-
var origin = (
|
|
2338
|
+
var origin = (_ref45 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref45 !== void 0 ? _ref45 : existed.origin;
|
|
2326
2339
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2327
2340
|
origin: origin
|
|
2328
2341
|
} : {});
|
|
@@ -2423,7 +2436,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2423
2436
|
}, {
|
|
2424
2437
|
key: "buildTempOrderHolderFromBookings",
|
|
2425
2438
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2426
|
-
var _baseHolder$customer_, _baseHolder,
|
|
2439
|
+
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder3, _baseHolder3, _this$otherParams;
|
|
2427
2440
|
var holderRecords = [];
|
|
2428
2441
|
var holderNames = [];
|
|
2429
2442
|
var baseHolder = null;
|
|
@@ -2470,7 +2483,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2470
2483
|
}
|
|
2471
2484
|
var nextHolder = {
|
|
2472
2485
|
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,
|
|
2473
|
-
form_id: (
|
|
2486
|
+
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,
|
|
2474
2487
|
form_record: holderRecords
|
|
2475
2488
|
};
|
|
2476
2489
|
if (holderNames.length) {
|
|
@@ -2565,15 +2578,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2565
2578
|
hasDeposit: true
|
|
2566
2579
|
} : undefined
|
|
2567
2580
|
});
|
|
2581
|
+
var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
|
|
2568
2582
|
tempOrder.deposit_amount = depositAmount;
|
|
2569
|
-
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
2583
|
+
tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
|
|
2570
2584
|
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
2571
2585
|
}
|
|
2572
2586
|
}, {
|
|
2573
2587
|
key: "recalculateSummary",
|
|
2574
2588
|
value: function () {
|
|
2575
2589
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
2576
|
-
var
|
|
2590
|
+
var _ref47, _salesSummaryResult$e;
|
|
2577
2591
|
var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2578
2592
|
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2579
2593
|
while (1) switch (_context13.prev = _context13.next) {
|
|
@@ -2646,7 +2660,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2646
2660
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
2647
2661
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
2648
2662
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
2649
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
2663
|
+
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;
|
|
2650
2664
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
2651
2665
|
rounding_amount: roundingAmount.toFixed(2)
|
|
2652
2666
|
}, expectAmount ? {
|
|
@@ -2824,17 +2838,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2824
2838
|
}, {
|
|
2825
2839
|
key: "buildTempOrderCustomer",
|
|
2826
2840
|
value: function buildTempOrderCustomer(params) {
|
|
2827
|
-
var
|
|
2841
|
+
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;
|
|
2828
2842
|
if (!params.customerId) return null;
|
|
2829
2843
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
2830
|
-
var name = (
|
|
2831
|
-
var customerName = (
|
|
2844
|
+
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;
|
|
2845
|
+
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;
|
|
2832
2846
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
2833
2847
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
2834
2848
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
2835
2849
|
name: String(name || ''),
|
|
2836
2850
|
customer_name: String(customerName || ''),
|
|
2837
|
-
country_calling_code: String((
|
|
2851
|
+
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),
|
|
2838
2852
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
2839
2853
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
2840
2854
|
});
|
|
@@ -2933,14 +2947,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2933
2947
|
}, {
|
|
2934
2948
|
key: "updateTempOrderCustomer",
|
|
2935
2949
|
value: function updateTempOrderCustomer(customer) {
|
|
2936
|
-
var _tempOrder$customer_i2,
|
|
2950
|
+
var _tempOrder$customer_i2, _ref55, _ref56, _customer$customer_id, _ref57, _ref58, _ref59, _customer$customer_na, _ref60, _customer$country_cal, _tempOrder$customer_i3;
|
|
2937
2951
|
var tempOrder = this.ensureTempOrder();
|
|
2938
2952
|
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
2939
|
-
var customerId = (
|
|
2940
|
-
var customerName = (
|
|
2953
|
+
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;
|
|
2954
|
+
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 : '';
|
|
2941
2955
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
2942
2956
|
tempOrder.customer_name = String(customerName || '');
|
|
2943
|
-
tempOrder.country_calling_code = String((
|
|
2957
|
+
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 : '');
|
|
2944
2958
|
tempOrder.phone = String(customer.phone || '');
|
|
2945
2959
|
tempOrder.email = String(customer.email || '');
|
|
2946
2960
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -2991,6 +3005,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2991
3005
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
2992
3006
|
clearTempOrderHolderAssignments(tempOrder);
|
|
2993
3007
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3008
|
+
this.applyDiscount();
|
|
2994
3009
|
}
|
|
2995
3010
|
this.persistTempOrder();
|
|
2996
3011
|
this.saveDraftInBackground();
|
|
@@ -3175,6 +3190,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3175
3190
|
var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
|
|
3176
3191
|
return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
|
|
3177
3192
|
};
|
|
3193
|
+
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3194
|
+
return value === 'normal' || value === 'deposit';
|
|
3195
|
+
};
|
|
3196
|
+
var voucherOrderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
|
|
3197
|
+
var withVoucherPaymentType = function withVoucherPaymentType(payment) {
|
|
3198
|
+
var paymentRecord = payment;
|
|
3199
|
+
if (!isVoucherPayment(paymentRecord)) return payment;
|
|
3200
|
+
var explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : undefined;
|
|
3201
|
+
var nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
|
|
3202
|
+
var shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === undefined && paymentRecord.type !== undefined && !isOrderPaymentType(paymentRecord.type);
|
|
3203
|
+
return _objectSpread(_objectSpread(_objectSpread({}, paymentRecord), shouldPreserveCustomPaymentType ? {
|
|
3204
|
+
custom_payment_type: paymentRecord.type
|
|
3205
|
+
} : {}), {}, {
|
|
3206
|
+
type: nextPaymentType,
|
|
3207
|
+
order_payment_type: nextPaymentType
|
|
3208
|
+
});
|
|
3209
|
+
};
|
|
3178
3210
|
// const normalizeVoucherPaymentStatus = (payment: OrderPaymentSource): OrderPaymentSource => {
|
|
3179
3211
|
// const paymentRecord = payment as Record<string, any>;
|
|
3180
3212
|
// // if (paymentRecord.status !== 'active') return payment;
|
|
@@ -3188,7 +3220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3188
3220
|
// return paymentRecord
|
|
3189
3221
|
// };
|
|
3190
3222
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3191
|
-
return _this19.normalizePaymentSource(payment, {
|
|
3223
|
+
return _this19.normalizePaymentSource(withVoucherPaymentType(payment), {
|
|
3192
3224
|
defaultPaid: true
|
|
3193
3225
|
});
|
|
3194
3226
|
})).filter(function (payment) {
|
|
@@ -3485,51 +3517,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3485
3517
|
key: "addProductToOrder",
|
|
3486
3518
|
value: (function () {
|
|
3487
3519
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
|
|
3488
|
-
var tempOrder,
|
|
3520
|
+
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3489
3521
|
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3490
3522
|
while (1) switch (_context19.prev = _context19.next) {
|
|
3491
3523
|
case 0:
|
|
3492
3524
|
tempOrder = this.ensureTempOrder();
|
|
3493
|
-
debugger;
|
|
3494
3525
|
if (!booking) {
|
|
3495
|
-
_context19.next =
|
|
3526
|
+
_context19.next = 18;
|
|
3496
3527
|
break;
|
|
3497
3528
|
}
|
|
3498
3529
|
productRecord = product;
|
|
3499
|
-
splitCount = getSafeProductNum((
|
|
3530
|
+
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3500
3531
|
if (!(splitCount > 1)) {
|
|
3501
|
-
_context19.next =
|
|
3532
|
+
_context19.next = 18;
|
|
3502
3533
|
break;
|
|
3503
3534
|
}
|
|
3504
3535
|
i = 0;
|
|
3505
|
-
case
|
|
3536
|
+
case 6:
|
|
3506
3537
|
if (!(i < splitCount)) {
|
|
3507
|
-
_context19.next =
|
|
3538
|
+
_context19.next = 15;
|
|
3508
3539
|
break;
|
|
3509
3540
|
}
|
|
3510
3541
|
singleLine = cloneDeep(productRecord);
|
|
3511
3542
|
singleLine.num = 1;
|
|
3512
3543
|
delete singleLine.product_quantity;
|
|
3513
|
-
_context19.next =
|
|
3544
|
+
_context19.next = 12;
|
|
3514
3545
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3515
|
-
case
|
|
3546
|
+
case 12:
|
|
3516
3547
|
i += 1;
|
|
3517
|
-
_context19.next =
|
|
3548
|
+
_context19.next = 6;
|
|
3518
3549
|
break;
|
|
3519
|
-
case
|
|
3520
|
-
_context19.next =
|
|
3550
|
+
case 15:
|
|
3551
|
+
_context19.next = 17;
|
|
3521
3552
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3522
|
-
case
|
|
3553
|
+
case 17:
|
|
3523
3554
|
return _context19.abrupt("return", tempOrder.products);
|
|
3524
|
-
case
|
|
3525
|
-
_context19.next =
|
|
3555
|
+
case 18:
|
|
3556
|
+
_context19.next = 20;
|
|
3526
3557
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3527
|
-
case
|
|
3528
|
-
_context19.next =
|
|
3558
|
+
case 20:
|
|
3559
|
+
_context19.next = 22;
|
|
3529
3560
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3530
|
-
case
|
|
3561
|
+
case 22:
|
|
3531
3562
|
return _context19.abrupt("return", tempOrder.products);
|
|
3532
|
-
case
|
|
3563
|
+
case 23:
|
|
3533
3564
|
case "end":
|
|
3534
3565
|
return _context19.stop();
|
|
3535
3566
|
}
|
|
@@ -3554,7 +3585,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3554
3585
|
key: "addProductsToOrder",
|
|
3555
3586
|
value: (function () {
|
|
3556
3587
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
|
|
3557
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
3588
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3558
3589
|
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3559
3590
|
while (1) switch (_context20.prev = _context20.next) {
|
|
3560
3591
|
case 0:
|
|
@@ -3586,7 +3617,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3586
3617
|
break;
|
|
3587
3618
|
}
|
|
3588
3619
|
productRecord = product;
|
|
3589
|
-
splitCount = getSafeProductNum((
|
|
3620
|
+
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3590
3621
|
if (!(splitCount > 1)) {
|
|
3591
3622
|
_context20.next = 26;
|
|
3592
3623
|
break;
|
|
@@ -3663,9 +3694,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3663
3694
|
}, {
|
|
3664
3695
|
key: "getBundleRuntimeIdentity",
|
|
3665
3696
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
3666
|
-
var
|
|
3697
|
+
var _ref63, _bundle$bundle_id2, _ref64, _bundle$bundle_group_2, _ref65, _ref66, _bundle$bundle_produc3, _ref67, _bundle$bundle_varian3;
|
|
3667
3698
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
3668
|
-
return [(
|
|
3699
|
+
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('|');
|
|
3669
3700
|
}
|
|
3670
3701
|
}, {
|
|
3671
3702
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -4227,23 +4258,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4227
4258
|
}, {
|
|
4228
4259
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4229
4260
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4230
|
-
var _params$cacheId, _this$otherParams2,
|
|
4261
|
+
var _params$cacheId, _this$otherParams2, _ref68, _params$businessCode, _this$otherParams3, _this$otherParams4;
|
|
4231
4262
|
var tempOrder = this.ensureTempOrder();
|
|
4232
4263
|
this.persistTempOrder();
|
|
4233
4264
|
var payload = buildSubmitPayload({
|
|
4234
4265
|
tempOrder: tempOrder,
|
|
4235
4266
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4236
4267
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
|
|
4237
|
-
businessCode: (
|
|
4268
|
+
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,
|
|
4238
4269
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4239
4270
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4240
4271
|
summary: this.store.summary || createEmptySummary(),
|
|
4241
4272
|
enhance: function enhance(nextPayload) {
|
|
4242
|
-
var
|
|
4273
|
+
var _ref69, _tempOrder$order_numb, _ref70, _tempOrder$shop_order, _ref71, _tempOrder$shop_full_;
|
|
4243
4274
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4244
|
-
order_number: (
|
|
4245
|
-
shop_order_number: (
|
|
4246
|
-
shop_full_order_number: (
|
|
4275
|
+
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,
|
|
4276
|
+
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,
|
|
4277
|
+
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,
|
|
4247
4278
|
small_ticket_data_flag: 1
|
|
4248
4279
|
});
|
|
4249
4280
|
}
|
|
@@ -4340,7 +4371,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4340
4371
|
key: "runSubmitTempOrder",
|
|
4341
4372
|
value: function () {
|
|
4342
4373
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4343
|
-
var _params$cacheId2, _this$otherParams5,
|
|
4374
|
+
var _params$cacheId2, _this$otherParams5, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams6, _this$otherParams7, _submitSnapshot$type;
|
|
4344
4375
|
var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4345
4376
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4346
4377
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -4387,7 +4418,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4387
4418
|
tempOrder: tempOrder,
|
|
4388
4419
|
cacheId: effectiveCacheId,
|
|
4389
4420
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
4390
|
-
businessCode: (
|
|
4421
|
+
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,
|
|
4391
4422
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4392
4423
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4393
4424
|
summary: latestSummary,
|
|
@@ -5267,7 +5298,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5267
5298
|
_step22;
|
|
5268
5299
|
try {
|
|
5269
5300
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
5270
|
-
var _product$metadata8,
|
|
5301
|
+
var _product$metadata8, _ref74, _ref75, _existed$origin, _rawProduct$metadata;
|
|
5271
5302
|
var _step22$value = _slicedToArray(_step22.value, 2),
|
|
5272
5303
|
index = _step22$value[0],
|
|
5273
5304
|
product = _step22$value[1];
|
|
@@ -5275,7 +5306,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5275
5306
|
if (!uid) continue;
|
|
5276
5307
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
5277
5308
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
5278
|
-
var origin = (
|
|
5309
|
+
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;
|
|
5279
5310
|
var originSnapshot = cloneDeep(origin);
|
|
5280
5311
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
5281
5312
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -5385,10 +5416,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5385
5416
|
}, {
|
|
5386
5417
|
key: "normalizeHydratedProductOptionItem",
|
|
5387
5418
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
5388
|
-
var
|
|
5389
|
-
var rawNum = (
|
|
5419
|
+
var _ref76, _optionItem$num, _ref77, _optionItem$add_price;
|
|
5420
|
+
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;
|
|
5390
5421
|
var parsedNum = Number(rawNum);
|
|
5391
|
-
var rawPrice = (
|
|
5422
|
+
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;
|
|
5392
5423
|
var parsedPrice = Number(rawPrice);
|
|
5393
5424
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
5394
5425
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -5452,6 +5483,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5452
5483
|
_context43.next = 2;
|
|
5453
5484
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
5454
5485
|
with: ['products', 'bookings']
|
|
5486
|
+
}, {
|
|
5487
|
+
osServer: true
|
|
5455
5488
|
});
|
|
5456
5489
|
case 2:
|
|
5457
5490
|
res = _context43.sent;
|
|
@@ -5515,10 +5548,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5515
5548
|
_step27;
|
|
5516
5549
|
try {
|
|
5517
5550
|
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
5518
|
-
var
|
|
5551
|
+
var _ref78, _bundle$num3;
|
|
5519
5552
|
var bundle = _step27.value;
|
|
5520
5553
|
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));
|
|
5521
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
5554
|
+
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();
|
|
5522
5555
|
var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
5523
5556
|
_step28;
|
|
5524
5557
|
try {
|