@pisell/pisellos 2.1.126 → 2.1.127
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/itemRule/adapter.js +6 -2
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/dist/model/strategy/adapter/itemRule/index.js +1 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +4 -38
- package/dist/modules/Order/utils.d.ts +24 -0
- package/dist/modules/Order/utils.js +87 -11
- package/dist/modules/SalesSummary/types.d.ts +2 -1
- package/dist/modules/SalesSummary/utils.js +10 -10
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.d.ts +5 -0
- package/dist/solution/ScanOrder/index.js +177 -60
- package/dist/solution/ScanOrder/types.d.ts +19 -5
- package/dist/solution/ScanOrder/utils.d.ts +14 -0
- package/dist/solution/ScanOrder/utils.js +138 -63
- package/dist/solution/VenueBooking/index.js +40 -44
- package/lib/model/strategy/adapter/itemRule/adapter.js +10 -2
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/lib/model/strategy/adapter/itemRule/index.js +2 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +9 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +2 -35
- package/lib/modules/Order/utils.d.ts +24 -0
- package/lib/modules/Order/utils.js +65 -4
- package/lib/modules/SalesSummary/types.d.ts +2 -1
- package/lib/modules/SalesSummary/utils.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.d.ts +5 -0
- package/lib/solution/ScanOrder/index.js +76 -19
- package/lib/solution/ScanOrder/types.d.ts +19 -5
- package/lib/solution/ScanOrder/utils.d.ts +14 -0
- package/lib/solution/ScanOrder/utils.js +82 -20
- package/lib/solution/VenueBooking/index.js +10 -16
- package/package.json +1 -1
|
@@ -36,6 +36,7 @@ __export(utils_exports, {
|
|
|
36
36
|
normalizeEnabledItemRuleIds: () => normalizeEnabledItemRuleIds,
|
|
37
37
|
normalizeItemRuleStrategies: () => normalizeItemRuleStrategies,
|
|
38
38
|
normalizeOrderProduct: () => normalizeOrderProduct,
|
|
39
|
+
pickFirstCustomCapacityPaxBounds: () => pickFirstCustomCapacityPaxBounds,
|
|
39
40
|
pickFirstDurationMinutesFromProducts: () => pickFirstDurationMinutesFromProducts,
|
|
40
41
|
resolveSkuMatchedQuantityLimits: () => resolveSkuMatchedQuantityLimits,
|
|
41
42
|
toBoolean: () => toBoolean,
|
|
@@ -163,18 +164,20 @@ function buildQuantityLimitIndex(limits) {
|
|
|
163
164
|
const exactLimitMap = /* @__PURE__ */ new Map();
|
|
164
165
|
const productLimitMap = /* @__PURE__ */ new Map();
|
|
165
166
|
for (const limit of limits) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
const targets = limit.targets || [];
|
|
168
|
+
if (targets.length !== 1)
|
|
169
|
+
continue;
|
|
170
|
+
const target = targets[0];
|
|
171
|
+
const productId = Number(target.product_id);
|
|
172
|
+
if (!Number.isFinite(productId) || productId <= 0)
|
|
173
|
+
continue;
|
|
174
|
+
const variantId = Number(target.product_variant_id);
|
|
175
|
+
const hasVariant = Number.isFinite(variantId) && variantId > 0;
|
|
176
|
+
if (hasVariant) {
|
|
177
|
+
const exactKey = buildProductKey(productId, variantId);
|
|
178
|
+
const existed = exactLimitMap.get(exactKey) || [];
|
|
179
|
+
exactLimitMap.set(exactKey, [...existed, limit]);
|
|
180
|
+
} else {
|
|
178
181
|
const existed = productLimitMap.get(productId) || [];
|
|
179
182
|
productLimitMap.set(productId, [...existed, limit]);
|
|
180
183
|
}
|
|
@@ -198,31 +201,63 @@ function aggregateItemRuleLimit(matchedLimits) {
|
|
|
198
201
|
let remainingMax;
|
|
199
202
|
let exact;
|
|
200
203
|
let mustInclude = false;
|
|
204
|
+
let maxSourceLimit;
|
|
205
|
+
let remainingMaxSourceLimit;
|
|
206
|
+
let exactSourceLimit;
|
|
207
|
+
let minSourceLimit;
|
|
208
|
+
let firstMessagedLimit;
|
|
201
209
|
for (const limit of matchedLimits) {
|
|
202
210
|
if (typeof limit.requiredMin === "number" && Number.isFinite(limit.requiredMin)) {
|
|
203
|
-
|
|
211
|
+
if (min === void 0 || limit.requiredMin > min) {
|
|
212
|
+
min = limit.requiredMin;
|
|
213
|
+
minSourceLimit = limit;
|
|
214
|
+
}
|
|
204
215
|
}
|
|
205
216
|
if (typeof limit.requiredMax === "number" && Number.isFinite(limit.requiredMax)) {
|
|
206
|
-
|
|
217
|
+
if (max === void 0 || limit.requiredMax < max) {
|
|
218
|
+
max = limit.requiredMax;
|
|
219
|
+
maxSourceLimit = limit;
|
|
220
|
+
}
|
|
207
221
|
}
|
|
208
222
|
if (typeof limit.remainingMax === "number" && Number.isFinite(limit.remainingMax)) {
|
|
209
|
-
|
|
223
|
+
if (remainingMax === void 0 || limit.remainingMax < remainingMax) {
|
|
224
|
+
remainingMax = limit.remainingMax;
|
|
225
|
+
remainingMaxSourceLimit = limit;
|
|
226
|
+
}
|
|
210
227
|
}
|
|
211
228
|
if (typeof limit.requiredExact === "number" && Number.isFinite(limit.requiredExact)) {
|
|
212
229
|
exact = limit.requiredExact;
|
|
230
|
+
exactSourceLimit = limit;
|
|
213
231
|
}
|
|
214
232
|
mustInclude = mustInclude || Boolean(limit.mustInclude);
|
|
233
|
+
if (!firstMessagedLimit && limit.validationMessage) {
|
|
234
|
+
firstMessagedLimit = limit;
|
|
235
|
+
}
|
|
215
236
|
}
|
|
216
237
|
if (typeof exact === "number" && Number.isFinite(exact)) {
|
|
217
238
|
min = exact;
|
|
218
239
|
max = exact;
|
|
219
240
|
}
|
|
241
|
+
const maxMessageSource = maxSourceLimit || remainingMaxSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
242
|
+
const minMessageSource = minSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
243
|
+
const maxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.validationMessage;
|
|
244
|
+
const rawMaxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.rawValidationMessage;
|
|
245
|
+
const minValidationMessage = minMessageSource == null ? void 0 : minMessageSource.validationMessage;
|
|
246
|
+
const rawMinValidationMessage = minMessageSource == null ? void 0 : minMessageSource.rawValidationMessage;
|
|
247
|
+
const validationMessage = maxValidationMessage ?? minValidationMessage;
|
|
248
|
+
const rawValidationMessage = rawMaxValidationMessage ?? rawMinValidationMessage;
|
|
220
249
|
return {
|
|
221
250
|
min,
|
|
222
251
|
max,
|
|
223
252
|
remainingMax,
|
|
224
253
|
exact,
|
|
225
|
-
mustInclude
|
|
254
|
+
mustInclude,
|
|
255
|
+
validationMessage,
|
|
256
|
+
rawValidationMessage,
|
|
257
|
+
maxValidationMessage,
|
|
258
|
+
rawMaxValidationMessage,
|
|
259
|
+
minValidationMessage,
|
|
260
|
+
rawMinValidationMessage
|
|
226
261
|
};
|
|
227
262
|
}
|
|
228
263
|
function buildItemRuleBusinessData(params) {
|
|
@@ -302,13 +337,13 @@ function getProductIdentityIndex(products, identity) {
|
|
|
302
337
|
return products.findIndex((item) => isIdentityMatch(item, identity));
|
|
303
338
|
}
|
|
304
339
|
function normalizeOrderProduct(product) {
|
|
305
|
-
var _a;
|
|
340
|
+
var _a, _b;
|
|
306
341
|
const metadata = { ...product.metadata || {} };
|
|
307
342
|
if (product.identity_key && !metadata.unique_identification_number) {
|
|
308
343
|
metadata.unique_identification_number = product.identity_key;
|
|
309
344
|
}
|
|
310
|
-
const resolvedOriginalPrice = product.original_price || "0.00";
|
|
311
345
|
const resolvedSellingPrice = product.selling_price || "0.00";
|
|
346
|
+
const resolvedOriginalPrice = product.original_price || resolvedSellingPrice;
|
|
312
347
|
if (metadata.main_product_original_price === void 0) {
|
|
313
348
|
metadata.main_product_original_price = resolvedOriginalPrice;
|
|
314
349
|
}
|
|
@@ -316,7 +351,7 @@ function normalizeOrderProduct(product) {
|
|
|
316
351
|
metadata.main_product_selling_price = resolvedSellingPrice;
|
|
317
352
|
}
|
|
318
353
|
if (metadata.source_product_price === void 0) {
|
|
319
|
-
metadata.source_product_price = ((_a = product._origin) == null ? void 0 : _a.
|
|
354
|
+
metadata.source_product_price = ((_a = product._origin) == null ? void 0 : _a.price) ?? ((_b = product._origin) == null ? void 0 : _b.base_price) ?? resolvedSellingPrice;
|
|
320
355
|
}
|
|
321
356
|
const normalizedBundle = (product.product_bundle || []).map((item) => ({
|
|
322
357
|
...item,
|
|
@@ -332,7 +367,6 @@ function normalizeOrderProduct(product) {
|
|
|
332
367
|
product_option_item: product.product_option_item || [],
|
|
333
368
|
selling_price: resolvedSellingPrice,
|
|
334
369
|
original_price: resolvedOriginalPrice,
|
|
335
|
-
payment_price: product.payment_price || "0.00",
|
|
336
370
|
tax_fee: product.tax_fee || "0.00",
|
|
337
371
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
338
372
|
discount_list: product.discount_list || [],
|
|
@@ -377,6 +411,33 @@ function hasCustomCapacityProduct(products) {
|
|
|
377
411
|
return ((_a = p == null ? void 0 : p.capacity) == null ? void 0 : _a.type) === "custom";
|
|
378
412
|
});
|
|
379
413
|
}
|
|
414
|
+
function pickFirstCustomCapacityPaxBounds(products) {
|
|
415
|
+
for (const p of products) {
|
|
416
|
+
const cap = p == null ? void 0 : p.capacity;
|
|
417
|
+
if (!cap || cap.type !== "custom")
|
|
418
|
+
continue;
|
|
419
|
+
if (!Array.isArray(cap.custom) || cap.custom.length === 0)
|
|
420
|
+
continue;
|
|
421
|
+
const row = cap.custom[0];
|
|
422
|
+
if (!row || typeof row !== "object")
|
|
423
|
+
continue;
|
|
424
|
+
const raw = row;
|
|
425
|
+
const out = {};
|
|
426
|
+
if (raw.min !== null && raw.min !== void 0 && raw.min !== "") {
|
|
427
|
+
const min = Number(raw.min);
|
|
428
|
+
if (Number.isFinite(min))
|
|
429
|
+
out.min = min;
|
|
430
|
+
}
|
|
431
|
+
if (raw.max !== null && raw.max !== void 0 && raw.max !== "") {
|
|
432
|
+
const max = Number(raw.max);
|
|
433
|
+
if (Number.isFinite(max))
|
|
434
|
+
out.max = max;
|
|
435
|
+
}
|
|
436
|
+
if (out.min !== void 0 || out.max !== void 0)
|
|
437
|
+
return out;
|
|
438
|
+
}
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
380
441
|
// Annotate the CommonJS export names for ESM import in node:
|
|
381
442
|
0 && (module.exports = {
|
|
382
443
|
aggregateItemRuleLimit,
|
|
@@ -396,6 +457,7 @@ function hasCustomCapacityProduct(products) {
|
|
|
396
457
|
normalizeEnabledItemRuleIds,
|
|
397
458
|
normalizeItemRuleStrategies,
|
|
398
459
|
normalizeOrderProduct,
|
|
460
|
+
pickFirstCustomCapacityPaxBounds,
|
|
399
461
|
pickFirstDurationMinutesFromProducts,
|
|
400
462
|
resolveSkuMatchedQuantityLimits,
|
|
401
463
|
toBoolean,
|
|
@@ -876,7 +876,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
876
876
|
num: 1,
|
|
877
877
|
selling_price: group.totalPrice,
|
|
878
878
|
original_price: group.totalPrice,
|
|
879
|
-
payment_price: group.totalPrice,
|
|
880
879
|
is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
|
|
881
880
|
metadata: {
|
|
882
881
|
venue_booking: true,
|
|
@@ -1052,7 +1051,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1052
1051
|
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
1053
1052
|
if (merged.length === 1) {
|
|
1054
1053
|
product.selling_price = merged[0].totalPrice;
|
|
1055
|
-
product.
|
|
1054
|
+
product.original_price = merged[0].totalPrice;
|
|
1056
1055
|
product.metadata.price_breakdown = (0, import_slotMerge.buildPriceBreakdown)({
|
|
1057
1056
|
group: merged[0],
|
|
1058
1057
|
productId: mapping.productId,
|
|
@@ -1067,7 +1066,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1067
1066
|
});
|
|
1068
1067
|
if (quotationPrice !== null) {
|
|
1069
1068
|
product.selling_price = quotationPrice;
|
|
1070
|
-
product.
|
|
1069
|
+
product.original_price = quotationPrice;
|
|
1071
1070
|
}
|
|
1072
1071
|
}
|
|
1073
1072
|
}
|
|
@@ -1162,15 +1161,14 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1162
1161
|
return rid != null && selectedResourceIds.has(rid);
|
|
1163
1162
|
});
|
|
1164
1163
|
if (product.discount_list.length < before) {
|
|
1165
|
-
const
|
|
1164
|
+
const totalPerUnitDiscount = product.discount_list.reduce(
|
|
1166
1165
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1167
1166
|
0
|
|
1168
1167
|
);
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
product.payment_price = paymentStr;
|
|
1168
|
+
const newSellingPrice = new import_decimal.default(product.original_price || product.selling_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1169
|
+
product.selling_price = newSellingPrice;
|
|
1172
1170
|
if (product.metadata) {
|
|
1173
|
-
product.metadata.main_product_selling_price =
|
|
1171
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1174
1172
|
}
|
|
1175
1173
|
}
|
|
1176
1174
|
}
|
|
@@ -1267,10 +1265,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1267
1265
|
});
|
|
1268
1266
|
if (quotationPrice !== null) {
|
|
1269
1267
|
product.selling_price = quotationPrice;
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
product.payment_price = quotationPrice;
|
|
1268
|
+
product.original_price = quotationPrice;
|
|
1269
|
+
} else if (product.selling_price != null) {
|
|
1270
|
+
product.original_price = product.selling_price;
|
|
1274
1271
|
}
|
|
1275
1272
|
}
|
|
1276
1273
|
const products = await this.store.order.addProductToOrder(product);
|
|
@@ -1515,16 +1512,13 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1515
1512
|
});
|
|
1516
1513
|
if (productIndex === -1) {
|
|
1517
1514
|
const sellingPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price), "0.00");
|
|
1518
|
-
const originalPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.original_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice, sellingPrice);
|
|
1519
|
-
const paymentPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.payment_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice, sellingPrice);
|
|
1520
1515
|
tempOrder.products.push(
|
|
1521
1516
|
(0, import_utils.normalizeOrderProduct)({
|
|
1522
1517
|
product_id: productId,
|
|
1523
1518
|
product_variant_id: productVariantId,
|
|
1524
1519
|
num: targetQuantity,
|
|
1525
1520
|
selling_price: sellingPrice,
|
|
1526
|
-
original_price:
|
|
1527
|
-
payment_price: paymentPrice,
|
|
1521
|
+
original_price: sellingPrice,
|
|
1528
1522
|
metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
|
|
1529
1523
|
_origin: { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
|
|
1530
1524
|
})
|