@pisell/pisellos 2.2.246 → 2.2.247
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Order/index.d.ts +4 -0
- package/dist/modules/Order/index.js +173 -120
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +1 -1
- package/dist/server/utils/small-ticket.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +81 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +4 -0
- package/lib/modules/Order/index.js +44 -5
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/server/utils/small-ticket.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +40 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -91,6 +91,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
91
91
|
_defineProperty(_assertThisInitialized(_this), "giftSelectResolver", null);
|
|
92
92
|
/** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
|
|
93
93
|
_defineProperty(_assertThisInitialized(_this), "isApplyingPromotion", false);
|
|
94
|
+
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "hasActiveCustomerBoundDiscount", false);
|
|
94
96
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
95
97
|
_defineProperty(_assertThisInitialized(_this), "lastUnfulfilledPromotions", []);
|
|
96
98
|
/** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
|
|
@@ -660,13 +662,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
662
|
}, {
|
|
661
663
|
key: "applyDiscount",
|
|
662
664
|
value: function applyDiscount() {
|
|
663
|
-
var _this$store$discount9,
|
|
665
|
+
var _this$store$discount9,
|
|
666
|
+
_tempOrder$holder3,
|
|
667
|
+
_tempOrder$holder4,
|
|
668
|
+
_this$store$summary2,
|
|
669
|
+
_this2 = this;
|
|
664
670
|
var tempOrder = this.store.tempOrder;
|
|
665
671
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
666
672
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
667
673
|
// appliedProductDetails / savedAmount 复位。
|
|
668
674
|
if (!tempOrder) return;
|
|
669
675
|
delete tempOrder.discount_list;
|
|
676
|
+
if (this.shouldSkipDiscountCalculation(tempOrder)) return;
|
|
670
677
|
var rulesModule = this.store.rules;
|
|
671
678
|
if (!rulesModule) return;
|
|
672
679
|
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
@@ -700,6 +707,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
700
707
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
701
708
|
(_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
|
|
702
709
|
}
|
|
710
|
+
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
711
|
+
return _this2.productHasCustomerBoundDiscount(product);
|
|
712
|
+
});
|
|
703
713
|
}
|
|
704
714
|
|
|
705
715
|
// ─── 促销/赠品 ──────────────────────────────────────
|
|
@@ -758,8 +768,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
768
|
key: "applyPromotion",
|
|
759
769
|
value: (function () {
|
|
760
770
|
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
761
|
-
var
|
|
762
|
-
|
|
771
|
+
var _this$promotionEvalua,
|
|
772
|
+
_this$promotionEvalua2,
|
|
773
|
+
_this3 = this;
|
|
774
|
+
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
763
775
|
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
|
764
776
|
while (1) switch (_context8.prev = _context8.next) {
|
|
765
777
|
case 0:
|
|
@@ -782,8 +794,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
782
794
|
}
|
|
783
795
|
return _context8.abrupt("return");
|
|
784
796
|
case 7:
|
|
797
|
+
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
798
|
+
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
799
|
+
_context8.next = 10;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
return _context8.abrupt("return");
|
|
803
|
+
case 10:
|
|
785
804
|
this.isApplyingPromotion = true;
|
|
786
|
-
_context8.prev =
|
|
805
|
+
_context8.prev = 11;
|
|
787
806
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
788
807
|
if (result.giftActions.toRemove.length > 0) {
|
|
789
808
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -795,16 +814,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
795
814
|
|
|
796
815
|
// step 2: toReduce —— 调整数量
|
|
797
816
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
798
|
-
_context8.prev =
|
|
817
|
+
_context8.prev = 15;
|
|
799
818
|
_iterator3.s();
|
|
800
|
-
case
|
|
819
|
+
case 17:
|
|
801
820
|
if ((_step3 = _iterator3.n()).done) {
|
|
802
|
-
_context8.next =
|
|
821
|
+
_context8.next = 37;
|
|
803
822
|
break;
|
|
804
823
|
}
|
|
805
824
|
reduce = _step3.value;
|
|
806
825
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
807
|
-
_context8.prev =
|
|
826
|
+
_context8.prev = 20;
|
|
808
827
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
809
828
|
var item, product;
|
|
810
829
|
return _regeneratorRuntime().wrap(function _loop2$(_context7) {
|
|
@@ -824,47 +843,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
824
843
|
}, _loop2);
|
|
825
844
|
});
|
|
826
845
|
_iterator6.s();
|
|
827
|
-
case
|
|
846
|
+
case 23:
|
|
828
847
|
if ((_step6 = _iterator6.n()).done) {
|
|
829
|
-
_context8.next =
|
|
848
|
+
_context8.next = 27;
|
|
830
849
|
break;
|
|
831
850
|
}
|
|
832
|
-
return _context8.delegateYield(_loop2(), "t0",
|
|
833
|
-
case
|
|
834
|
-
_context8.next =
|
|
851
|
+
return _context8.delegateYield(_loop2(), "t0", 25);
|
|
852
|
+
case 25:
|
|
853
|
+
_context8.next = 23;
|
|
835
854
|
break;
|
|
836
|
-
case
|
|
837
|
-
_context8.next =
|
|
855
|
+
case 27:
|
|
856
|
+
_context8.next = 32;
|
|
838
857
|
break;
|
|
839
|
-
case 26:
|
|
840
|
-
_context8.prev = 26;
|
|
841
|
-
_context8.t1 = _context8["catch"](17);
|
|
842
|
-
_iterator6.e(_context8.t1);
|
|
843
858
|
case 29:
|
|
844
859
|
_context8.prev = 29;
|
|
845
|
-
|
|
846
|
-
|
|
860
|
+
_context8.t1 = _context8["catch"](20);
|
|
861
|
+
_iterator6.e(_context8.t1);
|
|
847
862
|
case 32:
|
|
848
|
-
_context8.
|
|
863
|
+
_context8.prev = 32;
|
|
864
|
+
_iterator6.f();
|
|
865
|
+
return _context8.finish(32);
|
|
866
|
+
case 35:
|
|
867
|
+
_context8.next = 17;
|
|
849
868
|
break;
|
|
850
|
-
case
|
|
851
|
-
_context8.next =
|
|
869
|
+
case 37:
|
|
870
|
+
_context8.next = 42;
|
|
852
871
|
break;
|
|
853
|
-
case 36:
|
|
854
|
-
_context8.prev = 36;
|
|
855
|
-
_context8.t2 = _context8["catch"](12);
|
|
856
|
-
_iterator3.e(_context8.t2);
|
|
857
872
|
case 39:
|
|
858
873
|
_context8.prev = 39;
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
_context8.t2 = _context8["catch"](15);
|
|
875
|
+
_iterator3.e(_context8.t2);
|
|
861
876
|
case 42:
|
|
877
|
+
_context8.prev = 42;
|
|
878
|
+
_iterator3.f();
|
|
879
|
+
return _context8.finish(42);
|
|
880
|
+
case 45:
|
|
862
881
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
863
|
-
_context8.next =
|
|
882
|
+
_context8.next = 68;
|
|
864
883
|
break;
|
|
865
884
|
}
|
|
866
885
|
if (this.giftSelectResolver) {
|
|
867
|
-
_context8.next =
|
|
886
|
+
_context8.next = 50;
|
|
868
887
|
break;
|
|
869
888
|
}
|
|
870
889
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -875,11 +894,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
875
894
|
} else {
|
|
876
895
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
877
896
|
}
|
|
878
|
-
_context8.next =
|
|
897
|
+
_context8.next = 68;
|
|
879
898
|
break;
|
|
880
|
-
case
|
|
899
|
+
case 50:
|
|
881
900
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
882
|
-
_context8.prev =
|
|
901
|
+
_context8.prev = 51;
|
|
883
902
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
884
903
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
885
904
|
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
|
@@ -903,7 +922,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
922
|
case 6:
|
|
904
923
|
_context6.prev = 6;
|
|
905
924
|
_context6.next = 9;
|
|
906
|
-
return
|
|
925
|
+
return _this3.giftSelectResolver({
|
|
907
926
|
strategyId: addAction.strategyId,
|
|
908
927
|
strategyName: addAction.strategyName,
|
|
909
928
|
giftCount: addAction.giftCount,
|
|
@@ -938,7 +957,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
938
957
|
_context6.next = 26;
|
|
939
958
|
break;
|
|
940
959
|
}
|
|
941
|
-
linked =
|
|
960
|
+
linked = _this3.createLinkedProductAndBooking({
|
|
942
961
|
product: gp,
|
|
943
962
|
booking: booking
|
|
944
963
|
});
|
|
@@ -977,33 +996,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
977
996
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
978
997
|
});
|
|
979
998
|
_iterator4.s();
|
|
980
|
-
case
|
|
999
|
+
case 54:
|
|
981
1000
|
if ((_step4 = _iterator4.n()).done) {
|
|
982
|
-
_context8.next =
|
|
1001
|
+
_context8.next = 60;
|
|
983
1002
|
break;
|
|
984
1003
|
}
|
|
985
|
-
return _context8.delegateYield(_loop(), "t3",
|
|
986
|
-
case
|
|
1004
|
+
return _context8.delegateYield(_loop(), "t3", 56);
|
|
1005
|
+
case 56:
|
|
987
1006
|
if (!_context8.t3) {
|
|
988
|
-
_context8.next =
|
|
1007
|
+
_context8.next = 58;
|
|
989
1008
|
break;
|
|
990
1009
|
}
|
|
991
|
-
return _context8.abrupt("continue",
|
|
992
|
-
case
|
|
993
|
-
_context8.next =
|
|
1010
|
+
return _context8.abrupt("continue", 58);
|
|
1011
|
+
case 58:
|
|
1012
|
+
_context8.next = 54;
|
|
994
1013
|
break;
|
|
995
|
-
case
|
|
996
|
-
_context8.next =
|
|
1014
|
+
case 60:
|
|
1015
|
+
_context8.next = 65;
|
|
997
1016
|
break;
|
|
998
|
-
case 59:
|
|
999
|
-
_context8.prev = 59;
|
|
1000
|
-
_context8.t4 = _context8["catch"](48);
|
|
1001
|
-
_iterator4.e(_context8.t4);
|
|
1002
1017
|
case 62:
|
|
1003
1018
|
_context8.prev = 62;
|
|
1004
|
-
|
|
1005
|
-
|
|
1019
|
+
_context8.t4 = _context8["catch"](51);
|
|
1020
|
+
_iterator4.e(_context8.t4);
|
|
1006
1021
|
case 65:
|
|
1022
|
+
_context8.prev = 65;
|
|
1023
|
+
_iterator4.f();
|
|
1024
|
+
return _context8.finish(65);
|
|
1025
|
+
case 68:
|
|
1007
1026
|
tempOrder.products = result.products;
|
|
1008
1027
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1009
1028
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1021,21 +1040,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1021
1040
|
products: tempOrder.products
|
|
1022
1041
|
};
|
|
1023
1042
|
this.effectsEmit('onPromotionApplied', payload);
|
|
1024
|
-
_context8.next =
|
|
1043
|
+
_context8.next = 78;
|
|
1025
1044
|
break;
|
|
1026
|
-
case 72:
|
|
1027
|
-
_context8.prev = 72;
|
|
1028
|
-
_context8.t5 = _context8["catch"](8);
|
|
1029
|
-
console.error('[OrderModule] applyPromotion failed', _context8.t5);
|
|
1030
1045
|
case 75:
|
|
1031
1046
|
_context8.prev = 75;
|
|
1032
|
-
|
|
1033
|
-
|
|
1047
|
+
_context8.t5 = _context8["catch"](11);
|
|
1048
|
+
console.error('[OrderModule] applyPromotion failed', _context8.t5);
|
|
1034
1049
|
case 78:
|
|
1050
|
+
_context8.prev = 78;
|
|
1051
|
+
this.isApplyingPromotion = false;
|
|
1052
|
+
return _context8.finish(78);
|
|
1053
|
+
case 81:
|
|
1035
1054
|
case "end":
|
|
1036
1055
|
return _context8.stop();
|
|
1037
1056
|
}
|
|
1038
|
-
}, _callee6, this, [[
|
|
1057
|
+
}, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
|
|
1039
1058
|
}));
|
|
1040
1059
|
function applyPromotion() {
|
|
1041
1060
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1211,11 +1230,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1211
1230
|
}, {
|
|
1212
1231
|
key: "calculatePaymentTotal",
|
|
1213
1232
|
value: function calculatePaymentTotal(payments) {
|
|
1214
|
-
var
|
|
1233
|
+
var _this4 = this;
|
|
1215
1234
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1216
1235
|
includeVoided: false
|
|
1217
1236
|
}).reduce(function (sum, payment) {
|
|
1218
|
-
return sum.plus(
|
|
1237
|
+
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1219
1238
|
}, new Decimal(0));
|
|
1220
1239
|
}
|
|
1221
1240
|
}, {
|
|
@@ -1267,14 +1286,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1267
1286
|
}, {
|
|
1268
1287
|
key: "calculateDepositPaidAmount",
|
|
1269
1288
|
value: function calculateDepositPaidAmount(payments) {
|
|
1270
|
-
var
|
|
1289
|
+
var _this5 = this;
|
|
1271
1290
|
return (payments || []).reduce(function (sum, payment) {
|
|
1272
1291
|
var paymentRecord = payment;
|
|
1273
1292
|
if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return sum;
|
|
1274
1293
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1275
1294
|
if (!isDepositPayment) return sum;
|
|
1276
1295
|
if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
|
|
1277
|
-
return sum.plus(
|
|
1296
|
+
return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
|
|
1278
1297
|
}
|
|
1279
1298
|
var rounding = new Decimal(paymentRecord.rounding_amount || 0);
|
|
1280
1299
|
return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
|
|
@@ -1419,16 +1438,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1419
1438
|
}, {
|
|
1420
1439
|
key: "calculatePaidPaymentSummary",
|
|
1421
1440
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1422
|
-
var
|
|
1441
|
+
var _this6 = this;
|
|
1423
1442
|
return (payments || []).reduce(function (summary, payment) {
|
|
1424
1443
|
var paymentRecord = payment;
|
|
1425
1444
|
if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
|
|
1426
1445
|
return {
|
|
1427
1446
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1428
1447
|
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
1429
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1430
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1431
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1448
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
|
|
1449
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
|
|
1450
|
+
roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
|
|
1432
1451
|
};
|
|
1433
1452
|
}, {
|
|
1434
1453
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1613,15 +1632,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
1632
|
}, {
|
|
1614
1633
|
key: "normalizeFingerprintValue",
|
|
1615
1634
|
value: function normalizeFingerprintValue(value) {
|
|
1616
|
-
var
|
|
1635
|
+
var _this7 = this;
|
|
1617
1636
|
if (Array.isArray(value)) {
|
|
1618
1637
|
return value.map(function (item) {
|
|
1619
|
-
return
|
|
1638
|
+
return _this7.normalizeFingerprintValue(item);
|
|
1620
1639
|
});
|
|
1621
1640
|
}
|
|
1622
1641
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1623
1642
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1624
|
-
result[key] =
|
|
1643
|
+
result[key] = _this7.normalizeFingerprintValue(value[key]);
|
|
1625
1644
|
return result;
|
|
1626
1645
|
}, {});
|
|
1627
1646
|
}
|
|
@@ -1636,7 +1655,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1655
|
_sku$barcode,
|
|
1637
1656
|
_ref18,
|
|
1638
1657
|
_sku$variant_id,
|
|
1639
|
-
|
|
1658
|
+
_this8 = this;
|
|
1640
1659
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1641
1660
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1642
1661
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1670,7 +1689,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1670
1689
|
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,
|
|
1671
1690
|
option_group_item_id: (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : null,
|
|
1672
1691
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1673
|
-
add_price:
|
|
1692
|
+
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)
|
|
1674
1693
|
};
|
|
1675
1694
|
})
|
|
1676
1695
|
}),
|
|
@@ -1680,8 +1699,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1680
1699
|
bundle_product_id: (_ref21 = (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref21 !== void 0 ? _ref21 : null,
|
|
1681
1700
|
bundle_variant_id: (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : 0,
|
|
1682
1701
|
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),
|
|
1683
|
-
price:
|
|
1684
|
-
bundle_selling_price:
|
|
1702
|
+
price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1703
|
+
bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1685
1704
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1686
1705
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
1687
1706
|
};
|
|
@@ -1691,7 +1710,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1691
1710
|
return {
|
|
1692
1711
|
type: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : '',
|
|
1693
1712
|
discount_id: (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref25 !== void 0 ? _ref25 : null,
|
|
1694
|
-
amount:
|
|
1713
|
+
amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1695
1714
|
};
|
|
1696
1715
|
}))
|
|
1697
1716
|
};
|
|
@@ -1699,9 +1718,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1699
1718
|
}, {
|
|
1700
1719
|
key: "buildOrderProductsFingerprint",
|
|
1701
1720
|
value: function buildOrderProductsFingerprint(products) {
|
|
1702
|
-
var
|
|
1721
|
+
var _this9 = this;
|
|
1703
1722
|
var items = (products || []).map(function (product) {
|
|
1704
|
-
return
|
|
1723
|
+
return _this9.buildProductFingerprintItem(product);
|
|
1705
1724
|
});
|
|
1706
1725
|
items.sort(function (left, right) {
|
|
1707
1726
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1723,7 +1742,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1723
1742
|
_sku$barcode2,
|
|
1724
1743
|
_ref28,
|
|
1725
1744
|
_sku$variant_id2,
|
|
1726
|
-
|
|
1745
|
+
_this10 = this;
|
|
1727
1746
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1728
1747
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1729
1748
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1754,7 +1773,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1754
1773
|
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,
|
|
1755
1774
|
option_group_item_id: (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : null,
|
|
1756
1775
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1757
|
-
add_price:
|
|
1776
|
+
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)
|
|
1758
1777
|
};
|
|
1759
1778
|
})
|
|
1760
1779
|
}),
|
|
@@ -1768,14 +1787,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1768
1787
|
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),
|
|
1769
1788
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1770
1789
|
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 : '',
|
|
1771
|
-
option:
|
|
1790
|
+
option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
1772
1791
|
var _ref36, _option$id3, _option$option_group_5, _ref37, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1773
1792
|
return {
|
|
1774
1793
|
id: (_ref36 = (_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 && _ref36 !== void 0 ? _ref36 : null,
|
|
1775
1794
|
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,
|
|
1776
1795
|
option_group_item_id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
|
|
1777
1796
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1778
|
-
add_price:
|
|
1797
|
+
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)
|
|
1779
1798
|
};
|
|
1780
1799
|
}))
|
|
1781
1800
|
};
|
|
@@ -1785,7 +1804,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
1804
|
return {
|
|
1786
1805
|
type: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : '',
|
|
1787
1806
|
discount_id: (_ref39 = (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
1788
|
-
amount:
|
|
1807
|
+
amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1789
1808
|
};
|
|
1790
1809
|
}))
|
|
1791
1810
|
};
|
|
@@ -1793,9 +1812,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1793
1812
|
}, {
|
|
1794
1813
|
key: "buildOrderProductsStructuralFingerprint",
|
|
1795
1814
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
1796
|
-
var
|
|
1815
|
+
var _this11 = this;
|
|
1797
1816
|
var items = (products || []).map(function (product) {
|
|
1798
|
-
return
|
|
1817
|
+
return _this11.buildProductStructuralFingerprintItem(product);
|
|
1799
1818
|
});
|
|
1800
1819
|
items.sort(function (left, right) {
|
|
1801
1820
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2200,9 +2219,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2200
2219
|
}, {
|
|
2201
2220
|
key: "sanitizeTempOrderProducts",
|
|
2202
2221
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2203
|
-
var
|
|
2222
|
+
var _this12 = this;
|
|
2204
2223
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2205
|
-
return
|
|
2224
|
+
return _this12.sanitizeOrderProductForTempOrder(product);
|
|
2206
2225
|
});
|
|
2207
2226
|
}
|
|
2208
2227
|
}, {
|
|
@@ -2415,9 +2434,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2415
2434
|
}, {
|
|
2416
2435
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2417
2436
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2418
|
-
var
|
|
2437
|
+
var _this13 = this;
|
|
2419
2438
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2420
|
-
return
|
|
2439
|
+
return _this13.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2421
2440
|
});
|
|
2422
2441
|
}
|
|
2423
2442
|
}, {
|
|
@@ -2425,12 +2444,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2425
2444
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2426
2445
|
var _product$metadata5,
|
|
2427
2446
|
_product$metadata6,
|
|
2428
|
-
|
|
2447
|
+
_this14 = this;
|
|
2429
2448
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
2430
2449
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2431
2450
|
if (!productUid && !bookingUid) return;
|
|
2432
2451
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2433
|
-
var currentBookingUid =
|
|
2452
|
+
var currentBookingUid = _this14.getBookingUniqueIdentificationNumber(booking);
|
|
2434
2453
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2435
2454
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2436
2455
|
return true;
|
|
@@ -2749,18 +2768,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2749
2768
|
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2750
2769
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2751
2770
|
}
|
|
2771
|
+
}, {
|
|
2772
|
+
key: "productHasCustomerBoundDiscount",
|
|
2773
|
+
value: function productHasCustomerBoundDiscount(product) {
|
|
2774
|
+
var _this15 = this;
|
|
2775
|
+
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
2776
|
+
return _this15.isCustomerBoundDiscount(discount);
|
|
2777
|
+
})) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
2781
|
+
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
2782
|
+
return _this15.isCustomerBoundDiscount(discount);
|
|
2783
|
+
});
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2786
|
+
}, {
|
|
2787
|
+
key: "shouldSkipDiscountCalculation",
|
|
2788
|
+
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
2789
|
+
var _this$store$discount13,
|
|
2790
|
+
_this$store$discount14,
|
|
2791
|
+
_this16 = this;
|
|
2792
|
+
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
2793
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
|
|
2794
|
+
if (discountList.length > 0) return false;
|
|
2795
|
+
return !(tempOrder.products || []).some(function (product) {
|
|
2796
|
+
return _this16.productHasCustomerBoundDiscount(product);
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2752
2799
|
}, {
|
|
2753
2800
|
key: "clearCustomerBoundDiscounts",
|
|
2754
2801
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
2755
|
-
var
|
|
2802
|
+
var _this17 = this,
|
|
2756
2803
|
_discountModule$getDi,
|
|
2757
2804
|
_discountModule$getOr,
|
|
2758
2805
|
_discountModule$setDi,
|
|
2759
2806
|
_discountModule$setOr;
|
|
2807
|
+
var didRemoveCustomerBoundDiscount = false;
|
|
2760
2808
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
2761
2809
|
if (!Array.isArray(discountList)) return [];
|
|
2762
2810
|
return discountList.filter(function (discount) {
|
|
2763
|
-
|
|
2811
|
+
var shouldRemove = _this17.isCustomerBoundDiscount(discount);
|
|
2812
|
+
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
2813
|
+
return !shouldRemove;
|
|
2764
2814
|
});
|
|
2765
2815
|
};
|
|
2766
2816
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
@@ -2777,17 +2827,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2777
2827
|
return nextProduct;
|
|
2778
2828
|
});
|
|
2779
2829
|
delete tempOrder.discount_list;
|
|
2830
|
+
if (didRemoveCustomerBoundDiscount) {
|
|
2831
|
+
this.hasActiveCustomerBoundDiscount = true;
|
|
2832
|
+
}
|
|
2780
2833
|
var discountModule = this.store.discount;
|
|
2781
2834
|
if (!discountModule) return;
|
|
2782
2835
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
2783
2836
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
2784
2837
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
2785
2838
|
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2786
|
-
return !
|
|
2839
|
+
return !_this17.isCustomerBoundDiscount(discount);
|
|
2787
2840
|
});
|
|
2788
2841
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
2789
2842
|
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2790
|
-
return !
|
|
2843
|
+
return !_this17.isCustomerBoundDiscount(discount);
|
|
2791
2844
|
});
|
|
2792
2845
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
2793
2846
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -2954,7 +3007,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2954
3007
|
}, {
|
|
2955
3008
|
key: "addOrderPayment",
|
|
2956
3009
|
value: function addOrderPayment(payment) {
|
|
2957
|
-
var
|
|
3010
|
+
var _this18 = this;
|
|
2958
3011
|
this.logInfo('addOrderPayment', {
|
|
2959
3012
|
payment: payment
|
|
2960
3013
|
});
|
|
@@ -2971,7 +3024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2971
3024
|
void this.recalculateSummary({
|
|
2972
3025
|
createIfMissing: true
|
|
2973
3026
|
}).catch(function (error) {
|
|
2974
|
-
|
|
3027
|
+
_this18.logError('recalculate summary after addOrderPayment failed', {
|
|
2975
3028
|
error: error instanceof Error ? error.message : String(error)
|
|
2976
3029
|
});
|
|
2977
3030
|
});
|
|
@@ -3036,7 +3089,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3036
3089
|
}, {
|
|
3037
3090
|
key: "updateVoucherOrderPayments",
|
|
3038
3091
|
value: function updateVoucherOrderPayments(payments) {
|
|
3039
|
-
var
|
|
3092
|
+
var _this19 = this;
|
|
3040
3093
|
var tempOrder = this.ensureTempOrder();
|
|
3041
3094
|
var isVoucherPayment = function isVoucherPayment(payment) {
|
|
3042
3095
|
return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
|
|
@@ -3057,7 +3110,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3057
3110
|
// return paymentRecord
|
|
3058
3111
|
// };
|
|
3059
3112
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3060
|
-
return
|
|
3113
|
+
return _this19.normalizePaymentSource(payment, {
|
|
3061
3114
|
defaultPaid: true
|
|
3062
3115
|
});
|
|
3063
3116
|
})).filter(function (payment) {
|
|
@@ -3086,7 +3139,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3086
3139
|
void this.recalculateSummary({
|
|
3087
3140
|
createIfMissing: true
|
|
3088
3141
|
}).catch(function (error) {
|
|
3089
|
-
|
|
3142
|
+
_this19.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3090
3143
|
error: error instanceof Error ? error.message : String(error)
|
|
3091
3144
|
});
|
|
3092
3145
|
});
|
|
@@ -3222,7 +3275,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3222
3275
|
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
|
|
3223
3276
|
var _booking_uid,
|
|
3224
3277
|
_metadata,
|
|
3225
|
-
|
|
3278
|
+
_this20 = this;
|
|
3226
3279
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3227
3280
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3228
3281
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -3247,8 +3300,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3247
3300
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3248
3301
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3249
3302
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3250
|
-
if (
|
|
3251
|
-
if (
|
|
3303
|
+
if (_this20.hasGoodPassDiscount(item)) return false;
|
|
3304
|
+
if (_this20.hasOrderProductLineNote(item)) return false;
|
|
3252
3305
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3253
3306
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3254
3307
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
@@ -3538,17 +3591,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3538
3591
|
}, {
|
|
3539
3592
|
key: "preservePersistedBundlePriceFields",
|
|
3540
3593
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
3541
|
-
var
|
|
3594
|
+
var _this21 = this;
|
|
3542
3595
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
3543
3596
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
3544
3597
|
var previousByIdentity = new Map();
|
|
3545
3598
|
previousBundles.forEach(function (bundle) {
|
|
3546
|
-
var identity =
|
|
3599
|
+
var identity = _this21.getBundleRuntimeIdentity(bundle);
|
|
3547
3600
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
3548
3601
|
});
|
|
3549
3602
|
return nextBundles.map(function (bundle, index) {
|
|
3550
3603
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3551
|
-
var previous = previousByIdentity.get(
|
|
3604
|
+
var previous = previousByIdentity.get(_this21.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3552
3605
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3553
3606
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
3554
3607
|
price: previous.price,
|
|
@@ -3864,7 +3917,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3864
3917
|
key: "removeProductsFromOrder",
|
|
3865
3918
|
value: (function () {
|
|
3866
3919
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identities) {
|
|
3867
|
-
var
|
|
3920
|
+
var _this22 = this;
|
|
3868
3921
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
3869
3922
|
return _regeneratorRuntime().wrap(function _callee22$(_context25) {
|
|
3870
3923
|
while (1) switch (_context25.prev = _context25.next) {
|
|
@@ -3919,7 +3972,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3919
3972
|
}
|
|
3920
3973
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
3921
3974
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
3922
|
-
var bookingUid =
|
|
3975
|
+
var bookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3923
3976
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
3924
3977
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
3925
3978
|
}
|
|
@@ -4375,10 +4428,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4375
4428
|
value: function extractSubmitErrorResponse(error) {
|
|
4376
4429
|
var _error$response,
|
|
4377
4430
|
_error$response2,
|
|
4378
|
-
|
|
4431
|
+
_this23 = this;
|
|
4379
4432
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
4380
4433
|
return candidates.find(function (candidate) {
|
|
4381
|
-
return
|
|
4434
|
+
return _this23.isSubmitErrorResponse(candidate);
|
|
4382
4435
|
}) || null;
|
|
4383
4436
|
}
|
|
4384
4437
|
}, {
|
|
@@ -4944,8 +4997,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4944
4997
|
key: "hydrateTempOrderFromRecord",
|
|
4945
4998
|
value: (function () {
|
|
4946
4999
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(record, options) {
|
|
4947
|
-
var _this$store$
|
|
4948
|
-
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
5000
|
+
var _this$store$discount15;
|
|
5001
|
+
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
|
|
4949
5002
|
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
4950
5003
|
while (1) switch (_context41.prev = _context41.next) {
|
|
4951
5004
|
case 0:
|
|
@@ -4970,17 +5023,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4970
5023
|
});
|
|
4971
5024
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
4972
5025
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
4973
|
-
currentDiscounts = typeof ((_this$store$
|
|
5026
|
+
currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
4974
5027
|
shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
4975
5028
|
if (shouldSkipEmptyDiscountSync) {
|
|
4976
5029
|
_context41.next = 16;
|
|
4977
5030
|
break;
|
|
4978
5031
|
}
|
|
4979
5032
|
_context41.next = 14;
|
|
4980
|
-
return (_this$store$
|
|
5033
|
+
return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
|
|
4981
5034
|
case 14:
|
|
4982
5035
|
_context41.next = 16;
|
|
4983
|
-
return (_this$store$
|
|
5036
|
+
return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
|
|
4984
5037
|
case 16:
|
|
4985
5038
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
4986
5039
|
_context41.next = 19;
|
|
@@ -5007,7 +5060,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5007
5060
|
}, {
|
|
5008
5061
|
key: "normalizeTempOrderForRuntime",
|
|
5009
5062
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5010
|
-
var
|
|
5063
|
+
var _this24 = this;
|
|
5011
5064
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
5012
5065
|
delete nextTempOrder.summary;
|
|
5013
5066
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -5026,7 +5079,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5026
5079
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5027
5080
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5028
5081
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5029
|
-
return
|
|
5082
|
+
return _this24.normalizeHydratedOrderProduct(p);
|
|
5030
5083
|
}) : [];
|
|
5031
5084
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5032
5085
|
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
@@ -5154,7 +5207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5154
5207
|
}, {
|
|
5155
5208
|
key: "normalizeHydratedOrderProduct",
|
|
5156
5209
|
value: function normalizeHydratedOrderProduct(product) {
|
|
5157
|
-
var
|
|
5210
|
+
var _this25 = this;
|
|
5158
5211
|
var row = _objectSpread({}, product || {});
|
|
5159
5212
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5160
5213
|
row.num = row.product_quantity;
|
|
@@ -5162,7 +5215,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5162
5215
|
var productSku = ensureProductSku(row);
|
|
5163
5216
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5164
5217
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5165
|
-
return
|
|
5218
|
+
return _this25.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5166
5219
|
}))
|
|
5167
5220
|
});
|
|
5168
5221
|
delete row["product_".concat('option', "_item")];
|