@pisell/pisellos 2.2.245 → 2.2.246
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 +9 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Order/index.d.ts +4 -1
- package/dist/modules/Order/index.js +320 -202
- package/dist/server/modules/order/index.js +7 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +5 -2
- package/lib/modules/Order/index.d.ts +4 -1
- package/lib/modules/Order/index.js +76 -5
- package/lib/server/modules/order/index.js +7 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1063,7 +1063,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
return _context11.abrupt("continue", 44);
|
|
1065
1065
|
case 40:
|
|
1066
|
-
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder
|
|
1066
|
+
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder, {
|
|
1067
|
+
preferIncomingProducts: true
|
|
1068
|
+
});
|
|
1067
1069
|
pendingMap.delete(_storageKey);
|
|
1068
1070
|
memoryPendingMap.delete(_storageKey);
|
|
1069
1071
|
mergeActions[_storageKey] = 'update';
|
|
@@ -1953,7 +1955,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1953
1955
|
}
|
|
1954
1956
|
}, {
|
|
1955
1957
|
key: "mergeOrderRecords",
|
|
1956
|
-
value: function mergeOrderRecords(existing, incoming) {
|
|
1958
|
+
value: function mergeOrderRecords(existing, incoming, options) {
|
|
1957
1959
|
var preferred = this.pickPreferredOrder(existing, incoming);
|
|
1958
1960
|
var secondary = preferred === existing ? incoming : existing;
|
|
1959
1961
|
var merged = _objectSpread(_objectSpread({}, secondary), preferred);
|
|
@@ -1973,6 +1975,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1973
1975
|
mergedRecord[field] = secondaryRecord[field];
|
|
1974
1976
|
}
|
|
1975
1977
|
}
|
|
1978
|
+
var hasIncomingProducts = Object.prototype.hasOwnProperty.call(incomingRecord, 'products');
|
|
1979
|
+
var shouldUseIncomingProductsSnapshot = (options === null || options === void 0 ? void 0 : options.preferIncomingProducts) === true && hasIncomingProducts && incomingRecord.products !== undefined && incomingRecord.products !== null;
|
|
1976
1980
|
for (var _i4 = 0, _incomingPatchFields = incomingPatchFields; _i4 < _incomingPatchFields.length; _i4++) {
|
|
1977
1981
|
var _field = _incomingPatchFields[_i4];
|
|
1978
1982
|
if (!Object.prototype.hasOwnProperty.call(incomingRecord, _field)) continue;
|
|
@@ -1980,7 +1984,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1980
1984
|
if (typeof incomingRecord[_field] === 'string' && incomingRecord[_field] === '') continue;
|
|
1981
1985
|
mergedRecord[_field] = cloneDeep(incomingRecord[_field]);
|
|
1982
1986
|
}
|
|
1983
|
-
mergedRecord.products = this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1987
|
+
mergedRecord.products = shouldUseIncomingProductsSnapshot ? cloneDeep(incomingRecord.products) : this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1984
1988
|
if (!this.isPendingSyncOrder(preferred) || !this.isPendingSyncOrder(secondary)) {
|
|
1985
1989
|
merged.need_sync = 0;
|
|
1986
1990
|
}
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -78,7 +78,7 @@ function mapOrderBundleToOtherBundle(bundle) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function buildNormalProductCacheItemFromOrderLine(input) {
|
|
81
|
-
var _a, _b, _c, _d;
|
|
81
|
+
var _a, _b, _c, _d, _e;
|
|
82
82
|
const { product, sourceProduct } = input;
|
|
83
83
|
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
84
84
|
const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
|
|
@@ -117,6 +117,9 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
117
117
|
skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
118
118
|
_skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
119
119
|
isNormalProduct: true,
|
|
120
|
+
metadata: {
|
|
121
|
+
product_add_schedule_time: (_e = product.metadata) == null ? void 0 : _e.product_add_schedule_time
|
|
122
|
+
},
|
|
120
123
|
...productOptionString ? { product_option_string: productOptionString } : {},
|
|
121
124
|
...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
|
|
122
125
|
...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
|
|
@@ -132,7 +135,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
132
135
|
id: resolvedId,
|
|
133
136
|
product_id: resolvedId,
|
|
134
137
|
_id: uid,
|
|
135
|
-
title: sourceProduct == null ? void 0 : sourceProduct.title,
|
|
138
|
+
title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? product.product_title ?? "",
|
|
136
139
|
price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
|
|
137
140
|
selling_price: product.selling_price,
|
|
138
141
|
original_price: product.original_price,
|
|
@@ -179,6 +179,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
179
179
|
private buildOrderProductsFingerprint;
|
|
180
180
|
private buildProductStructuralFingerprintItem;
|
|
181
181
|
private buildOrderProductsStructuralFingerprint;
|
|
182
|
+
private getManualDepositOverride;
|
|
183
|
+
private setManualDepositOverride;
|
|
184
|
+
private clearManualDepositOverride;
|
|
182
185
|
private getOriginalSalesSnapshot;
|
|
183
186
|
private isSnapshotPayableAmountUnchanged;
|
|
184
187
|
private restoreOriginalSnapshotIfProductsUnchanged;
|
|
@@ -422,7 +425,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
422
425
|
generateIdempotencyToken(): string;
|
|
423
426
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
424
427
|
createOrder(params: CommitOrderParams['query']): {
|
|
425
|
-
type: "
|
|
428
|
+
type: "virtual" | "appointment_booking";
|
|
426
429
|
platform: string;
|
|
427
430
|
sales_channel: string;
|
|
428
431
|
order_sales_channel: string;
|
|
@@ -1256,6 +1256,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1256
1256
|
items.sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
1257
1257
|
return JSON.stringify(items);
|
|
1258
1258
|
}
|
|
1259
|
+
getManualDepositOverride(tempOrder) {
|
|
1260
|
+
var _a;
|
|
1261
|
+
const override = (_a = tempOrder._extend) == null ? void 0 : _a.manualDepositOverride;
|
|
1262
|
+
if (!override || typeof override !== "object")
|
|
1263
|
+
return null;
|
|
1264
|
+
if (typeof override.amount !== "string")
|
|
1265
|
+
return null;
|
|
1266
|
+
if (typeof override.productStructuralFingerprint !== "string")
|
|
1267
|
+
return null;
|
|
1268
|
+
return override;
|
|
1269
|
+
}
|
|
1270
|
+
setManualDepositOverride(tempOrder, amount) {
|
|
1271
|
+
tempOrder._extend = {
|
|
1272
|
+
...tempOrder._extend || {},
|
|
1273
|
+
manualDepositOverride: {
|
|
1274
|
+
amount,
|
|
1275
|
+
productStructuralFingerprint: this.buildOrderProductsStructuralFingerprint(tempOrder.products)
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
clearManualDepositOverride(tempOrder) {
|
|
1280
|
+
var _a;
|
|
1281
|
+
if (!((_a = tempOrder._extend) == null ? void 0 : _a.manualDepositOverride))
|
|
1282
|
+
return;
|
|
1283
|
+
tempOrder._extend = { ...tempOrder._extend };
|
|
1284
|
+
delete tempOrder._extend.manualDepositOverride;
|
|
1285
|
+
}
|
|
1259
1286
|
getOriginalSalesSnapshot(tempOrder) {
|
|
1260
1287
|
var _a;
|
|
1261
1288
|
const snapshot = (_a = tempOrder._extend) == null ? void 0 : _a.originalSalesSnapshot;
|
|
@@ -1717,18 +1744,28 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1717
1744
|
const depositSummary = (0, import_utils.calculateOrderProductsDeposit)(tempOrder.products || [], {
|
|
1718
1745
|
productsByUid: (_a = tempOrder._extend) == null ? void 0 : _a.productsByUid
|
|
1719
1746
|
});
|
|
1747
|
+
const manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
1748
|
+
const currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : "";
|
|
1749
|
+
const shouldUseManualDepositOverride = Boolean(
|
|
1750
|
+
manualDepositOverride && manualDepositOverride.productStructuralFingerprint === currentStructuralFingerprint
|
|
1751
|
+
);
|
|
1752
|
+
if (manualDepositOverride && !shouldUseManualDepositOverride) {
|
|
1753
|
+
this.clearManualDepositOverride(tempOrder);
|
|
1754
|
+
}
|
|
1755
|
+
const depositAmount = shouldUseManualDepositOverride ? manualDepositOverride.amount : depositSummary.totalText;
|
|
1756
|
+
const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
|
|
1720
1757
|
const nextSummary = {
|
|
1721
1758
|
...summary,
|
|
1722
|
-
deposit_amount:
|
|
1723
|
-
deposit:
|
|
1724
|
-
total:
|
|
1759
|
+
deposit_amount: depositAmount,
|
|
1760
|
+
deposit: hasDepositAmount ? {
|
|
1761
|
+
total: depositAmount,
|
|
1725
1762
|
deposit_policy_ids: depositSummary.deposit_policy_ids,
|
|
1726
1763
|
deposit_policy_data: depositSummary.protocols,
|
|
1727
1764
|
hasDeposit: true
|
|
1728
1765
|
} : void 0
|
|
1729
1766
|
};
|
|
1730
|
-
tempOrder.deposit_amount =
|
|
1731
|
-
tempOrder.is_deposit =
|
|
1767
|
+
tempOrder.deposit_amount = depositAmount;
|
|
1768
|
+
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
1732
1769
|
return nextSummary;
|
|
1733
1770
|
}
|
|
1734
1771
|
async recalculateSummary(options) {
|
|
@@ -1887,6 +1924,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1887
1924
|
},
|
|
1888
1925
|
depositAmount
|
|
1889
1926
|
);
|
|
1927
|
+
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
1890
1928
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1891
1929
|
const summary = {
|
|
1892
1930
|
...summaryWithDeposit,
|
|
@@ -2858,10 +2896,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2858
2896
|
* await order.removeProductsFromOrder([identityA, identityB]);
|
|
2859
2897
|
*/
|
|
2860
2898
|
async removeProductsFromOrder(identities) {
|
|
2899
|
+
var _a, _b, _c, _d;
|
|
2861
2900
|
const tempOrder = this.ensureTempOrder();
|
|
2862
2901
|
if (!identities.length) {
|
|
2863
2902
|
return tempOrder.products;
|
|
2864
2903
|
}
|
|
2904
|
+
const productsBeforeRemove = tempOrder.products || [];
|
|
2905
|
+
const bookingsBeforeRemove = tempOrder.bookings || [];
|
|
2906
|
+
const matchedProducts = productsBeforeRemove.filter((item) => {
|
|
2907
|
+
return identities.some((identity) => (0, import_utils3.isIdentityMatch)(item, identity));
|
|
2908
|
+
});
|
|
2865
2909
|
const removedProducts = [];
|
|
2866
2910
|
tempOrder.products = tempOrder.products.filter((item) => {
|
|
2867
2911
|
const shouldRemove = identities.some((identity) => (0, import_utils3.isIdentityMatch)(item, identity));
|
|
@@ -2872,6 +2916,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2872
2916
|
for (const product of removedProducts) {
|
|
2873
2917
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
2874
2918
|
}
|
|
2919
|
+
const linkedBookingUidsToRemove = /* @__PURE__ */ new Set();
|
|
2920
|
+
for (const product of matchedProducts) {
|
|
2921
|
+
const productUid = ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.unique_identification_number) || (product == null ? void 0 : product.unique_identification_number);
|
|
2922
|
+
const productBookingUid = (product == null ? void 0 : product.booking_uid) || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.booking_uid);
|
|
2923
|
+
const isAddTimeProduct = ((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.product_add_schedule_time) !== void 0 && ((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.product_add_schedule_time) !== null;
|
|
2924
|
+
if (isAddTimeProduct)
|
|
2925
|
+
continue;
|
|
2926
|
+
if (productBookingUid !== void 0 && productBookingUid !== null && productBookingUid !== "") {
|
|
2927
|
+
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
2928
|
+
}
|
|
2929
|
+
if (productUid !== void 0 && productUid !== null && productUid !== "") {
|
|
2930
|
+
bookingsBeforeRemove.forEach((booking) => {
|
|
2931
|
+
const bookingUid = this.getBookingUniqueIdentificationNumber(booking);
|
|
2932
|
+
if (bookingUid && String((booking == null ? void 0 : booking.product_uid) || "") === String(productUid)) {
|
|
2933
|
+
linkedBookingUidsToRemove.add(bookingUid);
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
if (linkedBookingUidsToRemove.size > 0) {
|
|
2939
|
+
tempOrder.products = (tempOrder.products || []).filter((line) => {
|
|
2940
|
+
var _a2, _b2, _c2;
|
|
2941
|
+
const lineBookingUid = ((_a2 = line == null ? void 0 : line.metadata) == null ? void 0 : _a2.booking_uid) || (line == null ? void 0 : line.booking_uid);
|
|
2942
|
+
const isAddTimeProduct = ((_b2 = line == null ? void 0 : line.metadata) == null ? void 0 : _b2.product_add_schedule_time) !== void 0 && ((_c2 = line == null ? void 0 : line.metadata) == null ? void 0 : _c2.product_add_schedule_time) !== null;
|
|
2943
|
+
return !(isAddTimeProduct && lineBookingUid !== void 0 && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
2944
|
+
});
|
|
2945
|
+
}
|
|
2875
2946
|
await this.finalizeAfterProductsMutation(tempOrder);
|
|
2876
2947
|
return tempOrder.products;
|
|
2877
2948
|
}
|
|
@@ -621,7 +621,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
621
621
|
const matchIndex = this.findOrderIndexByIdentity(updatedList, pendingOrder);
|
|
622
622
|
if (matchIndex < 0)
|
|
623
623
|
continue;
|
|
624
|
-
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder
|
|
624
|
+
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder, {
|
|
625
|
+
preferIncomingProducts: true
|
|
626
|
+
});
|
|
625
627
|
pendingMap.delete(storageKey);
|
|
626
628
|
memoryPendingMap.delete(storageKey);
|
|
627
629
|
mergeActions[storageKey] = "update";
|
|
@@ -1181,7 +1183,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1181
1183
|
}
|
|
1182
1184
|
return result;
|
|
1183
1185
|
}
|
|
1184
|
-
mergeOrderRecords(existing, incoming) {
|
|
1186
|
+
mergeOrderRecords(existing, incoming, options) {
|
|
1185
1187
|
const preferred = this.pickPreferredOrder(existing, incoming);
|
|
1186
1188
|
const secondary = preferred === existing ? incoming : existing;
|
|
1187
1189
|
const merged = {
|
|
@@ -1219,6 +1221,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1219
1221
|
mergedRecord[field] = secondaryRecord[field];
|
|
1220
1222
|
}
|
|
1221
1223
|
}
|
|
1224
|
+
const hasIncomingProducts = Object.prototype.hasOwnProperty.call(incomingRecord, "products");
|
|
1225
|
+
const shouldUseIncomingProductsSnapshot = (options == null ? void 0 : options.preferIncomingProducts) === true && hasIncomingProducts && incomingRecord.products !== void 0 && incomingRecord.products !== null;
|
|
1222
1226
|
for (const field of incomingPatchFields) {
|
|
1223
1227
|
if (!Object.prototype.hasOwnProperty.call(incomingRecord, field))
|
|
1224
1228
|
continue;
|
|
@@ -1228,7 +1232,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1228
1232
|
continue;
|
|
1229
1233
|
mergedRecord[field] = (0, import_lodash_es.cloneDeep)(incomingRecord[field]);
|
|
1230
1234
|
}
|
|
1231
|
-
mergedRecord.products = this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1235
|
+
mergedRecord.products = shouldUseIncomingProductsSnapshot ? (0, import_lodash_es.cloneDeep)(incomingRecord.products) : this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1232
1236
|
if (!this.isPendingSyncOrder(preferred) || !this.isPendingSyncOrder(secondary)) {
|
|
1233
1237
|
merged.need_sync = 0;
|
|
1234
1238
|
}
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|