@pisell/pisellos 2.2.194 → 2.2.195

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.
@@ -83,6 +83,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
83
83
  var bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : []);
84
84
  var originExtend = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 || (_product$metadata2 = _product$metadata2.origin) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._extend;
85
85
  var productOptionString = buildProductOptionStringFromOrderLine(product);
86
+ var discountList = product.discount_list || [];
86
87
  var other = {
87
88
  product_id: resolvedId,
88
89
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
@@ -132,6 +133,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
132
133
  } : {}), {}, {
133
134
  note: product.note,
134
135
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
136
+ discount_list: discountList,
135
137
  new: 0,
136
138
  autoClose: true,
137
139
  _extend: extend
@@ -265,7 +265,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
265
265
  private logSubmitBackendRejected;
266
266
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
267
267
  createOrder(params: CommitOrderParams['query']): {
268
- type: "appointment_booking" | "virtual";
268
+ type: "virtual" | "appointment_booking";
269
269
  platform: string;
270
270
  sales_channel: string;
271
271
  order_sales_channel: string;
@@ -56,6 +56,12 @@ function isSameDiscountList(left, right) {
56
56
  if (!Array.isArray(left) || !Array.isArray(right)) return false;
57
57
  return JSON.stringify(normalizeDiscountListSignature(left)) === JSON.stringify(normalizeDiscountListSignature(right));
58
58
  }
59
+ function isManualProductDiscountProduct(product) {
60
+ var _product$metadata, _product$metadata2;
61
+ return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
62
+ return (item === null || item === void 0 ? void 0 : item.type) === 'product';
63
+ });
64
+ }
59
65
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
60
66
  _inherits(OrderModule, _BaseModule);
61
67
  var _super = _createSuper(OrderModule);
@@ -97,8 +103,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
97
103
  key: "applyProductDiscountPrices",
98
104
  value: function applyProductDiscountPrices(products) {
99
105
  return (products || []).map(function (product) {
100
- var _product$metadata, _product$metadata$sou, _product$metadata2, _product$metadata3, _product$original_pri;
101
- if ((_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.is_manual_discount) return product;
106
+ var _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri;
107
+ if (isManualProductDiscountProduct(product)) return product;
102
108
  var discountItems = Array.isArray(product.discount_list) ? product.discount_list : [];
103
109
  var hasOnlyPersistedDiscountSnapshots = product.order_detail_id !== undefined && product.order_detail_id !== null && discountItems.length > 0 && discountItems.every(function (discount) {
104
110
  return (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== undefined && (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null;
@@ -108,7 +114,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
108
114
  }
109
115
  var totalPerUnitDiscount = resolveEffectivePerUnitDiscount(product);
110
116
  var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
111
- var sourcePrice = (_product$metadata$sou = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
117
+ var sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
112
118
  var newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
113
119
  var newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
114
120
  if (product.metadata) {
@@ -448,6 +454,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
448
454
  var _ref2;
449
455
  var uid = getOrderProductLineUid(product);
450
456
  var previous = (_ref2 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref2 !== void 0 ? _ref2 : previousProductsByUid.get("__index__:".concat(index));
457
+ if (isManualProductDiscountProduct(previous)) {
458
+ return previous;
459
+ }
451
460
  var mergedProduct = previous ? mergeOrderProductDisplayFields(previous, product) : product;
452
461
  return _objectSpread(_objectSpread({}, mergedProduct), {}, {
453
462
  discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(mergedProduct.discount_list, mergedProduct.num))
@@ -1481,11 +1490,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1481
1490
  }, {
1482
1491
  key: "removeLinkedBookingsForProduct",
1483
1492
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
1484
- var _product$metadata4,
1485
- _product$metadata5,
1493
+ var _product$metadata5,
1494
+ _product$metadata6,
1486
1495
  _this7 = this;
1487
- var productUid = (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
1488
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid);
1496
+ 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);
1497
+ 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);
1489
1498
  if (!productUid && !bookingUid) return;
1490
1499
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
1491
1500
  var currentBookingUid = _this7.getBookingUniqueIdentificationNumber(booking);
@@ -2020,7 +2029,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2020
2029
  value: function () {
2021
2030
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(product, booking) {
2022
2031
  var _this10 = this;
2023
- var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
2032
+ var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
2024
2033
  return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2025
2034
  while (1) switch (_context15.prev = _context15.next) {
2026
2035
  case 0:
@@ -2085,7 +2094,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2085
2094
  })
2086
2095
  })));
2087
2096
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
2088
- tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
2097
+ nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
2098
+ targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
2099
+ nextDiscountList = targetIsManualProductDiscount ? normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(targetProduct.discount_list, nextNum)) : normalizedProduct.discount_list;
2100
+ tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
2101
+ discount_list: nextDiscountList,
2089
2102
  metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
2090
2103
  unique_identification_number: targetUid
2091
2104
  }),
@@ -2095,10 +2108,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2095
2108
  option: []
2096
2109
  }), {}, {
2097
2110
  option: getProductSkuOptions(normalizedProduct)
2098
- }),
2111
+ })
2112
+ }, targetIsManualProductDiscount ? {
2113
+ selling_price: targetProduct.selling_price,
2114
+ original_price: targetProduct.original_price,
2115
+ payment_price: targetProduct.payment_price,
2116
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
2117
+ unique_identification_number: targetUid
2118
+ })
2119
+ } : {}), {}, {
2099
2120
  note: targetProduct.note,
2100
2121
  order_detail_id: targetProduct.order_detail_id,
2101
- num: getSafeProductNum(targetProduct.num + normalizedProduct.num)
2122
+ num: nextNum
2102
2123
  });
2103
2124
  this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
2104
2125
  }
@@ -3274,11 +3295,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3274
3295
  _step9;
3275
3296
  try {
3276
3297
  for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3277
- var _product$metadata6, _ref24, _ref25, _existed$origin, _rawProduct$metadata;
3298
+ var _product$metadata7, _ref24, _ref25, _existed$origin, _rawProduct$metadata;
3278
3299
  var _step9$value = _slicedToArray(_step9.value, 2),
3279
3300
  index = _step9$value[0],
3280
3301
  product = _step9$value[1];
3281
- var uid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
3302
+ var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
3282
3303
  if (!uid) continue;
3283
3304
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
3284
3305
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
@@ -37,6 +37,31 @@ export * from "./types";
37
37
  import { QuotationModule } from "../../modules/Quotation";
38
38
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
39
39
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
40
+ function isBaseSalesManualProductDiscountProduct(product) {
41
+ var _product$metadata, _product$metadata2;
42
+ return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
43
+ return (item === null || item === void 0 ? void 0 : item.type) === 'product';
44
+ });
45
+ }
46
+ function getBaseSalesProductUid(product) {
47
+ var _product$metadata3;
48
+ var uid = (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
49
+ if (uid === undefined || uid === null || uid === '') return null;
50
+ return String(uid);
51
+ }
52
+ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
53
+ var previousByUid = new Map();
54
+ (previousProducts || []).forEach(function (product, index) {
55
+ var uid = getBaseSalesProductUid(product);
56
+ if (uid) previousByUid.set(uid, product);
57
+ previousByUid.set("__index__:".concat(index), product);
58
+ });
59
+ return (nextProducts || []).map(function (product, index) {
60
+ var uid = getBaseSalesProductUid(product);
61
+ var previous = (uid ? previousByUid.get(uid) : undefined) || previousByUid.get("__index__:".concat(index));
62
+ return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
63
+ });
64
+ }
40
65
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
41
66
  _inherits(BaseSalesImpl, _BaseModule);
42
67
  var _super = _createSuper(BaseSalesImpl);
@@ -342,7 +367,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
342
367
  _product$num,
343
368
  _ref8,
344
369
  _product$quantity,
345
- _product$metadata;
370
+ _product$metadata4;
346
371
  if (!authoritativeProduct) return product;
347
372
  var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
348
373
  var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
@@ -373,7 +398,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
373
398
  });
374
399
  }(),
375
400
  product_bundle: productBundle,
376
- metadata: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 ? _product$metadata : authoritativeProduct.metadata
401
+ metadata: (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 ? _product$metadata4 : authoritativeProduct.metadata
377
402
  });
378
403
  }
379
404
  }, {
@@ -1180,7 +1205,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1180
1205
  value: function () {
1181
1206
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
1182
1207
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
1183
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata2, _tempOrder$_extend3, _product$metadata3, _product$metadata$sou, _product$metadata4, _product$metadata5, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1208
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1184
1209
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1185
1210
  while (1) switch (_context12.prev = _context12.next) {
1186
1211
  case 0:
@@ -1291,7 +1316,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1291
1316
  discountList: nextDiscountList
1292
1317
  };
1293
1318
  if (result.productList) {
1294
- tempOrder.products = result.productList;
1319
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1295
1320
  }
1296
1321
  _iterator = _createForOfIteratorHelper(tempOrder.products || []);
1297
1322
  _context12.prev = 45;
@@ -1302,9 +1327,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1302
1327
  break;
1303
1328
  }
1304
1329
  product = _step.value;
1305
- productUid = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number;
1330
+ productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
1306
1331
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
1307
- if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.is_manual_discount)) {
1332
+ if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1308
1333
  _context12.next = 53;
1309
1334
  break;
1310
1335
  }
@@ -1314,7 +1339,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1314
1339
  return sum + Number(pd.amount || 0);
1315
1340
  }, 0);
1316
1341
  optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
1317
- sourcePrice = (_product$metadata$sou = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
1342
+ sourcePrice = (_product$metadata$sou = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
1318
1343
  newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1319
1344
  newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1320
1345
  if (product.metadata) {
@@ -1427,7 +1452,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1427
1452
  orderTotalAmount: Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0)
1428
1453
  }) || result;
1429
1454
  if (result.productList) {
1430
- tempOrder.products = result.productList;
1455
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1431
1456
  }
1432
1457
  if (!result.discountList) {
1433
1458
  _context13.next = 23;
@@ -1525,7 +1550,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1525
1550
  key: "setDiscountSelected",
1526
1551
  value: function () {
1527
1552
  var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1528
- var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata6, _tempOrder$_extend4, _product$metadata7, _product$metadata$sou2, _product$metadata8, _product$metadata9, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1553
+ var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1529
1554
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1530
1555
  while (1) switch (_context15.prev = _context15.next) {
1531
1556
  case 0:
@@ -1569,7 +1594,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1569
1594
  discountList: updated
1570
1595
  };
1571
1596
  if (result !== null && result !== void 0 && result.productList) {
1572
- tempOrder.products = result.productList;
1597
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1573
1598
  }
1574
1599
  if (result !== null && result !== void 0 && result.discountList) {
1575
1600
  nextDiscountList = result.discountList;
@@ -1610,9 +1635,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1610
1635
  break;
1611
1636
  }
1612
1637
  product = _step3.value;
1613
- productUid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
1638
+ productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
1614
1639
  runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
1615
- if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.is_manual_discount)) {
1640
+ if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1616
1641
  _context15.next = 25;
1617
1642
  break;
1618
1643
  }
@@ -1630,7 +1655,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1630
1655
  return sum + (pd.amount || 0);
1631
1656
  }, 0); // TODO 这块逻辑需要拿掉
1632
1657
  optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
1633
- sourcePrice = (_product$metadata$sou2 = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
1658
+ sourcePrice = (_product$metadata$sou2 = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
1634
1659
  newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1635
1660
  newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1636
1661
  if (product.metadata) {
@@ -1717,7 +1742,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1717
1742
  orderStore = this.store.order.store || {};
1718
1743
  discountModule = orderStore.discount;
1719
1744
  if (result.productList) {
1720
- tempOrder.products = result.productList;
1745
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1721
1746
  }
1722
1747
  if (!result.discountList) {
1723
1748
  _context16.next = 14;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 5 | 4;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -88,6 +88,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
88
88
  );
89
89
  const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
90
90
  const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(product);
91
+ const discountList = product.discount_list || [];
91
92
  const other = {
92
93
  product_id: resolvedId,
93
94
  product_variant_id: product.product_variant_id ?? 0,
@@ -135,6 +136,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
135
136
  ...productOptionString ? { product_option_string: productOptionString } : {},
136
137
  note: product.note,
137
138
  order_detail_id: product.order_detail_id ?? null,
139
+ discount_list: discountList,
138
140
  new: 0,
139
141
  autoClose: true,
140
142
  _extend: extend
@@ -265,7 +265,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
265
265
  private logSubmitBackendRejected;
266
266
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
267
267
  createOrder(params: CommitOrderParams['query']): {
268
- type: "appointment_booking" | "virtual";
268
+ type: "virtual" | "appointment_booking";
269
269
  platform: string;
270
270
  sales_channel: string;
271
271
  order_sales_channel: string;
@@ -60,6 +60,10 @@ function isSameDiscountList(left, right) {
60
60
  normalizeDiscountListSignature(right)
61
61
  );
62
62
  }
63
+ function isManualProductDiscountProduct(product) {
64
+ var _a, _b;
65
+ return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_manual_discount) === true || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_manual_discount) === 1 || ((product == null ? void 0 : product.discount_list) || []).some((item) => (item == null ? void 0 : item.type) === "product");
66
+ }
63
67
  var OrderModule = class extends import_BaseModule.BaseModule {
64
68
  constructor(name, version) {
65
69
  super(name || "order", version);
@@ -119,8 +123,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
119
123
  }
120
124
  applyProductDiscountPrices(products) {
121
125
  return (products || []).map((product) => {
122
- var _a, _b, _c;
123
- if ((_a = product.metadata) == null ? void 0 : _a.is_manual_discount)
126
+ var _a, _b;
127
+ if (isManualProductDiscountProduct(product))
124
128
  return product;
125
129
  const discountItems = Array.isArray(product.discount_list) ? product.discount_list : [];
126
130
  const hasOnlyPersistedDiscountSnapshots = product.order_detail_id !== void 0 && product.order_detail_id !== null && discountItems.length > 0 && discountItems.every((discount) => (discount == null ? void 0 : discount.order_discount_id) !== void 0 && (discount == null ? void 0 : discount.order_discount_id) !== null);
@@ -129,7 +133,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
129
133
  }
130
134
  const totalPerUnitDiscount = (0, import_utils.resolveEffectivePerUnitDiscount)(product);
131
135
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
132
- const sourcePrice = ((_b = product.metadata) == null ? void 0 : _b.source_product_price) ?? (((_c = product.metadata) == null ? void 0 : _c.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
136
+ const sourcePrice = ((_a = product.metadata) == null ? void 0 : _a.source_product_price) ?? (((_b = product.metadata) == null ? void 0 : _b.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
133
137
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
134
138
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
135
139
  if (product.metadata) {
@@ -346,6 +350,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
346
350
  (result.productList || []).map((product, index) => {
347
351
  const uid = (0, import_utils.getOrderProductLineUid)(product);
348
352
  const previous = (uid ? previousProductsByUid.get(uid) : void 0) ?? previousProductsByUid.get(`__index__:${index}`);
353
+ if (isManualProductDiscountProduct(previous)) {
354
+ return previous;
355
+ }
349
356
  const mergedProduct = previous ? (0, import_utils.mergeOrderProductDisplayFields)(previous, product) : product;
350
357
  return {
351
358
  ...mergedProduct,
@@ -1511,9 +1518,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1511
1518
  normalizedProduct.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
1512
1519
  normalizedProduct.discount_list
1513
1520
  );
1521
+ const nextNum = (0, import_utils3.getSafeProductNum)(targetProduct.num + normalizedProduct.num);
1522
+ const targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
1523
+ const nextDiscountList = targetIsManualProductDiscount ? (0, import_utils.normalizeOrderProductDiscountList)(
1524
+ (0, import_manualProductDiscount.syncManualProductDiscountProductNum)(
1525
+ targetProduct.discount_list,
1526
+ nextNum
1527
+ )
1528
+ ) : normalizedProduct.discount_list;
1514
1529
  tempOrder.products[matchedIndex] = {
1515
1530
  ...targetProduct,
1516
1531
  ...normalizedProduct,
1532
+ discount_list: nextDiscountList,
1517
1533
  metadata: {
1518
1534
  ...targetProduct.metadata || {},
1519
1535
  ...normalizedProduct.metadata || {},
@@ -1524,9 +1540,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1524
1540
  ...normalizedProduct.product_sku || { option: [] },
1525
1541
  option: (0, import_utils.getProductSkuOptions)(normalizedProduct)
1526
1542
  },
1543
+ ...targetIsManualProductDiscount ? {
1544
+ selling_price: targetProduct.selling_price,
1545
+ original_price: targetProduct.original_price,
1546
+ payment_price: targetProduct.payment_price,
1547
+ metadata: {
1548
+ ...normalizedProduct.metadata || {},
1549
+ ...targetProduct.metadata || {},
1550
+ unique_identification_number: targetUid
1551
+ }
1552
+ } : {},
1527
1553
  note: targetProduct.note,
1528
1554
  order_detail_id: targetProduct.order_detail_id,
1529
- num: (0, import_utils3.getSafeProductNum)(targetProduct.num + normalizedProduct.num)
1555
+ num: nextNum
1530
1556
  };
1531
1557
  this.captureProductRuntime(
1532
1558
  tempOrder,
@@ -44,6 +44,31 @@ __reExport(BaseSales_exports, require("./types"), module.exports);
44
44
  var import_Quotation = require("../../modules/Quotation");
45
45
  var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
46
46
  var import_quotationPrice = require("./utils/quotationPrice");
47
+ function isBaseSalesManualProductDiscountProduct(product) {
48
+ var _a, _b;
49
+ return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_manual_discount) === true || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_manual_discount) === 1 || ((product == null ? void 0 : product.discount_list) || []).some((item) => (item == null ? void 0 : item.type) === "product");
50
+ }
51
+ function getBaseSalesProductUid(product) {
52
+ var _a;
53
+ const uid = ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.unique_identification_number) || (product == null ? void 0 : product.unique_identification_number);
54
+ if (uid === void 0 || uid === null || uid === "")
55
+ return null;
56
+ return String(uid);
57
+ }
58
+ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
59
+ const previousByUid = /* @__PURE__ */ new Map();
60
+ (previousProducts || []).forEach((product, index) => {
61
+ const uid = getBaseSalesProductUid(product);
62
+ if (uid)
63
+ previousByUid.set(uid, product);
64
+ previousByUid.set(`__index__:${index}`, product);
65
+ });
66
+ return (nextProducts || []).map((product, index) => {
67
+ const uid = getBaseSalesProductUid(product);
68
+ const previous = (uid ? previousByUid.get(uid) : void 0) || previousByUid.get(`__index__:${index}`);
69
+ return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
70
+ });
71
+ }
47
72
  var BaseSalesImpl = class extends import_BaseModule.BaseModule {
48
73
  constructor(name, version) {
49
74
  super(name, version);
@@ -772,7 +797,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
772
797
  });
773
798
  }
774
799
  async loadDiscountConfig(params) {
775
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
800
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
776
801
  if (!this.store.order)
777
802
  throw new Error("order 模块未初始化");
778
803
  const tempOrder = this.store.order.ensureTempOrder();
@@ -852,19 +877,22 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
852
877
  orderTotalAmount: Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0)
853
878
  }) || { productList: tempOrder.products, discountList: nextDiscountList };
854
879
  if (result.productList) {
855
- tempOrder.products = result.productList;
880
+ tempOrder.products = preserveManualProductDiscountProducts(
881
+ tempOrder.products,
882
+ result.productList
883
+ );
856
884
  }
857
885
  for (const product of tempOrder.products || []) {
858
886
  const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
859
887
  const runtimeOrigin = productUid ? (_r = (_q = (_p = tempOrder._extend) == null ? void 0 : _p.productsByUid) == null ? void 0 : _q[productUid]) == null ? void 0 : _r.origin : void 0;
860
- if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || ((_s = product.metadata) == null ? void 0 : _s.is_manual_discount))
888
+ if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
861
889
  continue;
862
890
  const totalPerUnitDiscount = (product.discount_list || []).reduce(
863
891
  (sum, pd) => sum + Number(pd.amount || 0),
864
892
  0
865
893
  );
866
894
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
867
- const sourcePrice = ((_t = product.metadata) == null ? void 0 : _t.source_product_price) ?? (((_u = product.metadata) == null ? void 0 : _u.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
895
+ const sourcePrice = ((_s = product.metadata) == null ? void 0 : _s.source_product_price) ?? (((_t = product.metadata) == null ? void 0 : _t.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
868
896
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
869
897
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
870
898
  if (product.metadata) {
@@ -928,7 +956,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
928
956
  orderTotalAmount: Number(((_e = orderStore.summary) == null ? void 0 : _e.total_amount) || 0)
929
957
  }) || result;
930
958
  if (result.productList) {
931
- tempOrder.products = result.productList;
959
+ tempOrder.products = preserveManualProductDiscountProducts(
960
+ tempOrder.products,
961
+ result.productList
962
+ );
932
963
  }
933
964
  if (result.discountList) {
934
965
  nextDiscountList = this.mergeHistoricalDiscountList(
@@ -974,7 +1005,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
974
1005
  }
975
1006
  // TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
976
1007
  async setDiscountSelected(params) {
977
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1008
+ var _a, _b, _c, _d, _e, _f, _g, _h;
978
1009
  try {
979
1010
  if (!this.store.order)
980
1011
  throw new Error("order 模块未初始化");
@@ -1008,7 +1039,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1008
1039
  }
1009
1040
  ) || { productList: tempOrder.products, discountList: updated };
1010
1041
  if (result == null ? void 0 : result.productList) {
1011
- tempOrder.products = result.productList;
1042
+ tempOrder.products = preserveManualProductDiscountProducts(
1043
+ tempOrder.products,
1044
+ result.productList
1045
+ );
1012
1046
  }
1013
1047
  if (result == null ? void 0 : result.discountList) {
1014
1048
  nextDiscountList = result.discountList;
@@ -1031,7 +1065,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1031
1065
  for (const product of tempOrder.products) {
1032
1066
  const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
1033
1067
  const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
1034
- if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || ((_g = product.metadata) == null ? void 0 : _g.is_manual_discount))
1068
+ if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
1035
1069
  continue;
1036
1070
  product.discount_list = (product.discount_list || []).filter((pd) => {
1037
1071
  var _a2;
@@ -1043,7 +1077,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1043
1077
  0
1044
1078
  );
1045
1079
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(product));
1046
- const sourcePrice = ((_h = product.metadata) == null ? void 0 : _h.source_product_price) ?? (((_i = product.metadata) == null ? void 0 : _i.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1080
+ const sourcePrice = ((_g = product.metadata) == null ? void 0 : _g.source_product_price) ?? (((_h = product.metadata) == null ? void 0 : _h.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1047
1081
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1048
1082
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1049
1083
  if (product.metadata) {
@@ -1080,7 +1114,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1080
1114
  const orderStore = this.store.order.store || {};
1081
1115
  const discountModule = orderStore.discount;
1082
1116
  if (result.productList) {
1083
- tempOrder.products = result.productList;
1117
+ tempOrder.products = preserveManualProductDiscountProducts(
1118
+ tempOrder.products,
1119
+ result.productList
1120
+ );
1084
1121
  }
1085
1122
  if (result.discountList) {
1086
1123
  import_Order.OrderModule.populateSavedAmounts(
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 5 | 4;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.194",
4
+ "version": "2.2.195",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",