@pisell/pisellos 0.10.88 → 0.10.91
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.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +185 -129
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +19 -3
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +51 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +19 -3
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { OrderModule } from '../../modules/Order';
|
|
2
|
+
import type { ShopServiceType } from '../../modules/Order/types';
|
|
2
3
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
3
4
|
import { type PickupTimingAvailability, type PickupTimingSelection, type PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
|
|
4
5
|
interface PickupTimingHost {
|
|
5
6
|
getOrder: () => OrderModule;
|
|
7
|
+
setServiceType?: (serviceType: ShopServiceType) => unknown | Promise<unknown>;
|
|
6
8
|
getSchedule: () => ScheduleModule | undefined;
|
|
7
9
|
loadOpenData: (force: boolean) => Promise<Record<string, unknown>>;
|
|
8
10
|
getTimezone: () => string;
|
|
@@ -24,6 +26,8 @@ export declare class PickupTimingController {
|
|
|
24
26
|
private getRuntime;
|
|
25
27
|
private loadConfig;
|
|
26
28
|
private loadSchedules;
|
|
29
|
+
/** Preserve an existing POS choice without adding it to the shared settings cache. */
|
|
30
|
+
private getEffectiveConfig;
|
|
27
31
|
private snapshot;
|
|
28
32
|
getAvailability(params?: {
|
|
29
33
|
date?: string;
|
|
@@ -217,7 +217,20 @@ export var PickupTimingController = /*#__PURE__*/function () {
|
|
|
217
217
|
return _loadSchedules.apply(this, arguments);
|
|
218
218
|
}
|
|
219
219
|
return loadSchedules;
|
|
220
|
-
}()
|
|
220
|
+
}() /** Preserve an existing POS choice without adding it to the shared settings cache. */
|
|
221
|
+
}, {
|
|
222
|
+
key: "getEffectiveConfig",
|
|
223
|
+
value: function getEffectiveConfig(config) {
|
|
224
|
+
var _this$host$getOrder$g;
|
|
225
|
+
if (!this.host.isPos()) return config;
|
|
226
|
+
var serviceType = (_this$host$getOrder$g = this.host.getOrder().getTempOrder()) === null || _this$host$getOrder$g === void 0 || (_this$host$getOrder$g = _this$host$getOrder$g.metadata) === null || _this$host$getOrder$g === void 0 || (_this$host$getOrder$g = _this$host$getOrder$g.shop_service_data) === null || _this$host$getOrder$g === void 0 ? void 0 : _this$host$getOrder$g.service_type;
|
|
227
|
+
if (serviceType !== 'dine_in' && serviceType !== 'takeaway' || config.handoverModes.includes(serviceType)) {
|
|
228
|
+
return config;
|
|
229
|
+
}
|
|
230
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
231
|
+
handoverModes: [].concat(_toConsumableArray(config.handoverModes), [serviceType])
|
|
232
|
+
});
|
|
233
|
+
}
|
|
221
234
|
}, {
|
|
222
235
|
key: "snapshot",
|
|
223
236
|
value: function () {
|
|
@@ -271,7 +284,10 @@ export var PickupTimingController = /*#__PURE__*/function () {
|
|
|
271
284
|
error: error
|
|
272
285
|
};
|
|
273
286
|
this.latest = result;
|
|
274
|
-
|
|
287
|
+
// Read the live order after async loading; cached snapshots retain only configured modes.
|
|
288
|
+
return _context5.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
289
|
+
config: this.getEffectiveConfig(config)
|
|
290
|
+
}));
|
|
275
291
|
case 23:
|
|
276
292
|
case "end":
|
|
277
293
|
return _context5.stop();
|
|
@@ -339,7 +355,7 @@ export var PickupTimingController = /*#__PURE__*/function () {
|
|
|
339
355
|
var order = this.host.getOrder();
|
|
340
356
|
var tempOrder = order.getTempOrder();
|
|
341
357
|
var booking = order.getPickupTimingBooking();
|
|
342
|
-
var config = ((_this$latest = this.latest) === null || _this$latest === void 0 ? void 0 : _this$latest.scope) === this.host.getScope() ? this.latest.config : undefined;
|
|
358
|
+
var config = ((_this$latest = this.latest) === null || _this$latest === void 0 ? void 0 : _this$latest.scope) === this.host.getScope() ? this.getEffectiveConfig(this.latest.config) : undefined;
|
|
343
359
|
var storedServiceType = String((tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.shop_service_data) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.service_type) || '');
|
|
344
360
|
var serviceType = config !== null && config !== void 0 && config.handoverModes.length ? config.handoverModes.includes(storedServiceType) ? storedServiceType : config.handoverModes[0] : storedServiceType;
|
|
345
361
|
var details = serviceType === 'pick_up' ? booking === null || booking === void 0 ? void 0 : booking.metadata.fulfillment_timing : undefined;
|
|
@@ -459,21 +475,32 @@ export var PickupTimingController = /*#__PURE__*/function () {
|
|
|
459
475
|
return _context9.abrupt("return", this.getSelection());
|
|
460
476
|
case 17:
|
|
461
477
|
if (!(selection.serviceType !== 'pick_up')) {
|
|
462
|
-
_context9.next =
|
|
478
|
+
_context9.next = 25;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
if (!this.host.setServiceType) {
|
|
482
|
+
_context9.next = 23;
|
|
463
483
|
break;
|
|
464
484
|
}
|
|
485
|
+
_context9.next = 21;
|
|
486
|
+
return this.host.setServiceType(selection.serviceType);
|
|
487
|
+
case 21:
|
|
488
|
+
_context9.next = 24;
|
|
489
|
+
break;
|
|
490
|
+
case 23:
|
|
465
491
|
order.updateTempOrderServiceType(selection.serviceType);
|
|
492
|
+
case 24:
|
|
466
493
|
return _context9.abrupt("return", this.getSelection());
|
|
467
|
-
case
|
|
494
|
+
case 25:
|
|
468
495
|
slot = selection.mode === 'asap' ? getAsapPickupTiming(_objectSpread(_objectSpread({}, snapshot), {}, {
|
|
469
496
|
now: now
|
|
470
497
|
})) : result.slot;
|
|
471
498
|
if (slot) {
|
|
472
|
-
_context9.next =
|
|
499
|
+
_context9.next = 28;
|
|
473
500
|
break;
|
|
474
501
|
}
|
|
475
502
|
throw new Error('Please choose a pickup time.');
|
|
476
|
-
case
|
|
503
|
+
case 28:
|
|
477
504
|
// Validate everything before either field is changed; notify once after the combined update.
|
|
478
505
|
tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
|
|
479
506
|
shop_service_data: _objectSpread(_objectSpread({}, ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.shop_service_data) || {}), {}, {
|
|
@@ -490,7 +517,7 @@ export var PickupTimingController = /*#__PURE__*/function () {
|
|
|
490
517
|
frozen: (_options$frozen = options.frozen) !== null && _options$frozen !== void 0 ? _options$frozen : false
|
|
491
518
|
});
|
|
492
519
|
return _context9.abrupt("return", this.getSelection());
|
|
493
|
-
case
|
|
520
|
+
case 31:
|
|
494
521
|
case "end":
|
|
495
522
|
return _context9.stop();
|
|
496
523
|
}
|
|
@@ -13,6 +13,7 @@ import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
|
13
13
|
export declare const BaseSalesHookNames: {
|
|
14
14
|
readonly onInited: "onInited";
|
|
15
15
|
readonly onDestroy: "onDestroy";
|
|
16
|
+
readonly onOrderSessionChanged: "onOrderSessionChanged";
|
|
16
17
|
readonly onRetryInit: "onRetryInit";
|
|
17
18
|
readonly onRefresh: "onRefresh";
|
|
18
19
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
@@ -348,6 +349,9 @@ export interface BaseSalesProductBookingPriceResult {
|
|
|
348
349
|
unit_price: string;
|
|
349
350
|
total_price: string;
|
|
350
351
|
quantity: number;
|
|
352
|
+
pricing_method?: {
|
|
353
|
+
type: 'fixed_price' | 'duration_based';
|
|
354
|
+
};
|
|
351
355
|
duration?: BaseSalesQuotationDurationConfig;
|
|
352
356
|
quotation_shelf_id: number;
|
|
353
357
|
segments: BaseSalesProductBookingPriceSegment[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesQuotationDurationConfig } from '../types';
|
|
2
|
+
export interface PosDurationPricingPlan {
|
|
3
|
+
duration: BaseSalesQuotationDurationConfig;
|
|
4
|
+
segments: Array<{
|
|
5
|
+
start: string;
|
|
6
|
+
end: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export declare function durationPricingUnavailable(message: string): Error & {
|
|
10
|
+
code: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function hasDurationBasedPricing(product: Record<string, any> | null | undefined): boolean;
|
|
13
|
+
/** Days/Flexible retain their existing quotation behavior. */
|
|
14
|
+
export declare function usesPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
|
|
15
|
+
/** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
|
|
16
|
+
export declare function hasAppliedPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
|
|
17
|
+
export declare function buildPosDurationPricingPlan(params: BaseSalesCalculateProductBookingPriceParams, product: Record<string, any>): PosDurationPricingPlan;
|
|
18
|
+
/** Never use a previously accumulated order price as one unit's fallback. */
|
|
19
|
+
export declare function resolveDurationPricingProduct(product: Record<string, any>, selected: Record<string, any>): Record<string, any>;
|
|
20
|
+
export declare function combinePosDurationPrices(plan: PosDurationPricingPlan, prices: BaseSalesProductBookingPriceResult[]): BaseSalesProductBookingPriceResult;
|
|
21
|
+
export declare function forEachPriceQueryGroup<T>(groups: T[], resolve: (group: T) => Promise<void>, concurrency: number): Promise<void>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
|
+
import Decimal from 'decimal.js';
|
|
12
|
+
export function durationPricingUnavailable(message) {
|
|
13
|
+
return Object.assign(new Error(message), {
|
|
14
|
+
code: 'DURATION_PRICING_UNAVAILABLE'
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function hasDurationBasedPricing(product) {
|
|
18
|
+
var _product$pricing_meth;
|
|
19
|
+
return (product === null || product === void 0 || (_product$pricing_meth = product.pricing_method) === null || _product$pricing_meth === void 0 ? void 0 : _product$pricing_meth.type) === 'duration_based';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Days/Flexible retain their existing quotation behavior. */
|
|
23
|
+
export function usesPosDurationPricing(product) {
|
|
24
|
+
var _product$duration;
|
|
25
|
+
var type = String((product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.type) || '').trim().toLowerCase();
|
|
26
|
+
return hasDurationBasedPricing(product) && !['day', 'days', 'flexible'].includes(type);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
|
|
30
|
+
export function hasAppliedPosDurationPricing(product) {
|
|
31
|
+
var _product$_extend, _product$_extend2;
|
|
32
|
+
return usesPosDurationPricing(product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bookingPriceQuote) || usesPosDurationPricing(product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 || (_product$_extend2 = _product$_extend2.bookingPrice) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.quote) || usesPosDurationPricing(product === null || product === void 0 ? void 0 : product.metadata);
|
|
33
|
+
}
|
|
34
|
+
function bookingDateTime(date, time) {
|
|
35
|
+
var dateText = typeof date === 'string' ? date.trim() : '';
|
|
36
|
+
var timeText = typeof time === 'string' ? time.trim() : '';
|
|
37
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateText) || !/^\d{2}:\d{2}(?::\d{2})?$/.test(timeText)) {
|
|
38
|
+
throw durationPricingUnavailable('A valid booking start and end are required for duration pricing.');
|
|
39
|
+
}
|
|
40
|
+
var text = "".concat(dateText, " ").concat(timeText.length === 5 ? "".concat(timeText, ":00") : timeText);
|
|
41
|
+
var value = dayjs(text);
|
|
42
|
+
if (!value.isValid() || value.format('YYYY-MM-DD HH:mm:ss') !== text) {
|
|
43
|
+
throw durationPricingUnavailable('The booking time is invalid for duration pricing.');
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
export function buildPosDurationPricingPlan(params, product) {
|
|
48
|
+
var _product$duration2, _product$duration3, _params$booking, _params$booking2, _params$booking3, _params$booking4;
|
|
49
|
+
var type = String(((_product$duration2 = product.duration) === null || _product$duration2 === void 0 ? void 0 : _product$duration2.type) || '').trim().toLowerCase();
|
|
50
|
+
var value = Number((_product$duration3 = product.duration) === null || _product$duration3 === void 0 ? void 0 : _product$duration3.value);
|
|
51
|
+
var minutes = ['hour', 'hours'].includes(type) ? value * 60 : value;
|
|
52
|
+
if (!['minute', 'minutes', 'hour', 'hours'].includes(type) || !Number.isFinite(minutes) || minutes <= 0) {
|
|
53
|
+
throw durationPricingUnavailable('A positive fixed billing duration is required.');
|
|
54
|
+
}
|
|
55
|
+
var start = bookingDateTime((_params$booking = params.booking) === null || _params$booking === void 0 ? void 0 : _params$booking.start_date, (_params$booking2 = params.booking) === null || _params$booking2 === void 0 ? void 0 : _params$booking2.start_time);
|
|
56
|
+
var end = bookingDateTime((_params$booking3 = params.booking) === null || _params$booking3 === void 0 ? void 0 : _params$booking3.end_date, (_params$booking4 = params.booking) === null || _params$booking4 === void 0 ? void 0 : _params$booking4.end_time);
|
|
57
|
+
var count = end.diff(start) / (minutes * 60000);
|
|
58
|
+
if (!Number.isInteger(count) || count < 1 || count > 10000) {
|
|
59
|
+
throw durationPricingUnavailable('The booking duration must be a whole multiple of its billing duration.');
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
duration: {
|
|
63
|
+
type: 'minutes',
|
|
64
|
+
value: minutes
|
|
65
|
+
},
|
|
66
|
+
segments: Array.from({
|
|
67
|
+
length: count
|
|
68
|
+
}, function (_, index) {
|
|
69
|
+
return {
|
|
70
|
+
start: start.add(index * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss'),
|
|
71
|
+
end: start.add((index + 1) * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss')
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Never use a previously accumulated order price as one unit's fallback. */
|
|
78
|
+
export function resolveDurationPricingProduct(product, selected) {
|
|
79
|
+
var _ref, _selected$product_var, _ref2, _product$product_vari, _product$_dataVariant, _ref3, _ref4, _priceSource$price;
|
|
80
|
+
var variantId = Number((_ref = (_selected$product_var = selected.product_variant_id) !== null && _selected$product_var !== void 0 ? _selected$product_var : selected.variant_id) !== null && _ref !== void 0 ? _ref : 0);
|
|
81
|
+
var authoritativeVariantId = Number((_ref2 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref2 !== void 0 ? _ref2 : 0);
|
|
82
|
+
var variant = variantId > 0 && Array.isArray(product.variant) ? product.variant.find(function (item) {
|
|
83
|
+
return Number(item === null || item === void 0 ? void 0 : item.id) === variantId;
|
|
84
|
+
}) : undefined;
|
|
85
|
+
if (variantId > 0 && !variant && authoritativeVariantId !== variantId) {
|
|
86
|
+
throw durationPricingUnavailable('The selected SKU is missing from the authoritative price response.');
|
|
87
|
+
}
|
|
88
|
+
var appliedFields = (_product$_dataVariant = product._dataVariant) === null || _product$_dataVariant === void 0 ? void 0 : _product$_dataVariant.appliedFields;
|
|
89
|
+
var hasAppliedPrice = Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(function (field) {
|
|
90
|
+
return appliedFields.includes(field);
|
|
91
|
+
});
|
|
92
|
+
var priceSource = variantId > 0 && authoritativeVariantId !== variantId && !hasAppliedPrice ? variant : product;
|
|
93
|
+
var price = (_ref3 = (_ref4 = (_priceSource$price = priceSource === null || priceSource === void 0 ? void 0 : priceSource.price) !== null && _priceSource$price !== void 0 ? _priceSource$price : priceSource === null || priceSource === void 0 ? void 0 : priceSource.selling_price) !== null && _ref4 !== void 0 ? _ref4 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.base_price) !== null && _ref3 !== void 0 ? _ref3 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.original_price;
|
|
94
|
+
if (!(typeof price === 'number' || typeof price === 'string' && price.trim() !== '') || !Number.isFinite(Number(price)) || Number(price) < 0) {
|
|
95
|
+
throw durationPricingUnavailable('An authoritative price is required for every billing unit.');
|
|
96
|
+
}
|
|
97
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
98
|
+
price: price
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function combinePosDurationPrices(plan, prices) {
|
|
102
|
+
var _prices$find;
|
|
103
|
+
if (prices.length !== plan.segments.length || prices.length === 0) {
|
|
104
|
+
throw durationPricingUnavailable('The duration price is incomplete.');
|
|
105
|
+
}
|
|
106
|
+
var unitPrice = prices.reduce(function (sum, price) {
|
|
107
|
+
return sum.plus(price.unit_price);
|
|
108
|
+
}, new Decimal(0));
|
|
109
|
+
return _objectSpread(_objectSpread({}, prices[0]), {}, {
|
|
110
|
+
pricing_method: {
|
|
111
|
+
type: 'duration_based'
|
|
112
|
+
},
|
|
113
|
+
duration: plan.duration,
|
|
114
|
+
unit_price: unitPrice.toFixed(2),
|
|
115
|
+
total_price: unitPrice.times(prices[0].quantity).toFixed(2),
|
|
116
|
+
quotation_shelf_id: ((_prices$find = prices.find(function (price) {
|
|
117
|
+
return price.quotation_shelf_id;
|
|
118
|
+
})) === null || _prices$find === void 0 ? void 0 : _prices$find.quotation_shelf_id) || 0,
|
|
119
|
+
segments: prices.map(function (price, index) {
|
|
120
|
+
return _objectSpread(_objectSpread({}, price.segments[0]), {}, {
|
|
121
|
+
start_datetime: plan.segments[index].start,
|
|
122
|
+
end_datetime: plan.segments[index].end,
|
|
123
|
+
time_point: plan.segments[index].start,
|
|
124
|
+
unit_price: price.unit_price,
|
|
125
|
+
total_price: price.unit_price,
|
|
126
|
+
quantity: 1
|
|
127
|
+
});
|
|
128
|
+
}),
|
|
129
|
+
// Options are composed by the caller; bundle pricing belongs to the first unit only.
|
|
130
|
+
product_bundle: prices[0].product_bundle
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
export function forEachPriceQueryGroup(_x, _x2, _x3) {
|
|
134
|
+
return _forEachPriceQueryGroup.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
function _forEachPriceQueryGroup() {
|
|
137
|
+
_forEachPriceQueryGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(groups, resolve, concurrency) {
|
|
138
|
+
var next;
|
|
139
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
140
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
141
|
+
case 0:
|
|
142
|
+
next = 0;
|
|
143
|
+
_context2.next = 3;
|
|
144
|
+
return Promise.all(Array.from({
|
|
145
|
+
length: Math.min(groups.length, concurrency)
|
|
146
|
+
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
147
|
+
var _group;
|
|
148
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
149
|
+
while (1) switch (_context.prev = _context.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
if (!(next < groups.length)) {
|
|
152
|
+
_context.next = 6;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
_group = groups[next++];
|
|
156
|
+
_context.next = 4;
|
|
157
|
+
return resolve(_group);
|
|
158
|
+
case 4:
|
|
159
|
+
_context.next = 0;
|
|
160
|
+
break;
|
|
161
|
+
case 6:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee);
|
|
166
|
+
}))));
|
|
167
|
+
case 3:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context2.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee2);
|
|
172
|
+
}));
|
|
173
|
+
return _forEachPriceQueryGroup.apply(this, arguments);
|
|
174
|
+
}
|
|
@@ -55,6 +55,8 @@ export interface TransformBaseProductToOrderProductParams {
|
|
|
55
55
|
fallbackProductId?: number | string | null;
|
|
56
56
|
sourceProduct?: ProductData | Record<string, any> | null;
|
|
57
57
|
sourceItem?: ProductData | Record<string, any> | null;
|
|
58
|
+
/** Validated booking quote's pre-discount main price, excluding options/bundles. */
|
|
59
|
+
quotedSourceProductPrice?: number | string;
|
|
58
60
|
}
|
|
59
61
|
export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
|
|
60
62
|
_origin?: Record<string, any>;
|
|
@@ -170,7 +170,7 @@ function findVariantById(origin, variantId) {
|
|
|
170
170
|
* 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
|
|
171
171
|
*/
|
|
172
172
|
export function transformBaseProductToOrderProduct(params) {
|
|
173
|
-
var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price,
|
|
173
|
+
var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _params$quotedSourceP, _ref24, _ref25, _payload$price, _ref26, _payload$line_total, _payload$_extend3, _ref27, _ref28, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref29, _ref30, _origin$base_price, _ref31, _ref32, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _find, _resolveProductHolder, _ref33, _ref34, _payload$tax_fee, _ref35, _ref36, _payload$is_charge_ta;
|
|
174
174
|
var payload = params.payload,
|
|
175
175
|
_params$fallbackProdu = params.fallbackProductId,
|
|
176
176
|
fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
|
|
@@ -193,11 +193,11 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
193
193
|
// 售价仍由 line_total - bundle 推导。
|
|
194
194
|
var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
|
|
195
195
|
var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
|
|
196
|
-
var sourceProductPrice = toPriceString(
|
|
197
|
-
var explicitLineTotal = (
|
|
196
|
+
var sourceProductPrice = toPriceString((_ref23 = (_params$quotedSourceP = params.quotedSourceProductPrice) !== null && _params$quotedSourceP !== void 0 ? _params$quotedSourceP : weighedSourcePrice) !== null && _ref23 !== void 0 ? _ref23 : hasPriceOverride ? (_ref24 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref24 !== void 0 ? _ref24 : payload.selling_price : (_ref25 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref25 !== void 0 ? _ref25 : catalogSourcePrice, '0.00');
|
|
197
|
+
var explicitLineTotal = (_ref26 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref26 !== void 0 ? _ref26 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
|
|
198
198
|
var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
199
199
|
var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
200
|
-
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((
|
|
200
|
+
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref27 = (_ref28 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref28 !== void 0 ? _ref28 : payload.options) !== null && _ref27 !== void 0 ? _ref27 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
|
|
201
201
|
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
|
|
202
202
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
203
203
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
@@ -212,10 +212,10 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
212
212
|
extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
|
|
213
213
|
originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
|
|
214
214
|
sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
|
|
215
|
-
catalogUnitPrice: (
|
|
215
|
+
catalogUnitPrice: (_ref29 = (_ref30 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
|
|
216
216
|
quantity: resolvedQuantity
|
|
217
217
|
});
|
|
218
|
-
var sellingTotal = Number((
|
|
218
|
+
var sellingTotal = Number((_ref31 = (_ref32 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref32 !== void 0 ? _ref32 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref31 !== void 0 ? _ref31 : lineCompositeTotal);
|
|
219
219
|
var discountReason = resolveManualDiscountReasonFromSources({
|
|
220
220
|
discountReason: payload.discount_reason,
|
|
221
221
|
extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
|
|
@@ -297,8 +297,8 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
297
297
|
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
298
298
|
selling_price: lineCompositeTotal,
|
|
299
299
|
original_price: lineOriginalPrice,
|
|
300
|
-
tax_fee: toPriceString((
|
|
301
|
-
is_charge_tax: toNumber((
|
|
300
|
+
tax_fee: toPriceString((_ref33 = (_ref34 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref34 !== void 0 ? _ref34 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
|
|
301
|
+
is_charge_tax: toNumber((_ref35 = (_ref36 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref36 !== void 0 ? _ref36 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
|
|
302
302
|
metadata: metadata
|
|
303
303
|
}, holderRelations !== undefined && !isBookingProduct(origin) && !isBookingProduct(payload) ? {
|
|
304
304
|
_extend: {
|
|
@@ -20,9 +20,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
20
20
|
private shopStore;
|
|
21
21
|
private store;
|
|
22
22
|
private otherParams;
|
|
23
|
+
private scheduleRuntimeParams;
|
|
23
24
|
private cacheId;
|
|
24
25
|
private otherData;
|
|
25
26
|
private platform;
|
|
27
|
+
private productDetailGeneration;
|
|
28
|
+
private sessionAvailabilityRequestVersion;
|
|
29
|
+
private lifecycleGeneration;
|
|
30
|
+
private disposed;
|
|
31
|
+
private resourcePreparation?;
|
|
32
|
+
private staleSelection;
|
|
33
|
+
private resourceSelectionKey;
|
|
34
|
+
/** Semantic selection token for async UI transitions. */
|
|
35
|
+
getBookingSelectionKey(): string;
|
|
36
|
+
private refreshCurrentProductSchedule;
|
|
26
37
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
27
38
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
28
39
|
getCurrentStep(): {
|
|
@@ -108,7 +119,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
108
119
|
* }
|
|
109
120
|
* @memberof BookingByStepImpl
|
|
110
121
|
*/
|
|
111
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<ITime[]>;
|
|
122
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, assertCurrent, }: LoadScheduleAvailableDateParams): Promise<ITime[]>;
|
|
112
123
|
addAccount(account: Account | IHolder, extra?: {
|
|
113
124
|
type: 'account' | 'holder';
|
|
114
125
|
customerId: number;
|
|
@@ -152,7 +163,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
152
163
|
startDate?: string;
|
|
153
164
|
endDate?: string;
|
|
154
165
|
type?: 'month' | 'day';
|
|
166
|
+
assertCurrent?: () => void;
|
|
155
167
|
}): Promise<ITime[]>;
|
|
168
|
+
/** Prepare the exact cart/date selection before synchronous resource checks. */
|
|
169
|
+
prepareResourcesForCurrentSelection(): Promise<void>;
|
|
156
170
|
/**
|
|
157
171
|
* 获取购物车汇总信息
|
|
158
172
|
*/
|
|
@@ -210,6 +224,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
210
224
|
* product: ProductData;
|
|
211
225
|
* date?: { startTime: string; endTime: string } | null;
|
|
212
226
|
* account?: Account | null;
|
|
227
|
+
* isLegacyOrder?: boolean;
|
|
213
228
|
* })} {
|
|
214
229
|
* product,
|
|
215
230
|
* date,
|
|
@@ -218,13 +233,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
218
233
|
* @return {*}
|
|
219
234
|
* @memberof BookingByStepImpl
|
|
220
235
|
*/
|
|
221
|
-
addProductToCart({ product, date, account, }: {
|
|
236
|
+
addProductToCart({ product, date, account, isLegacyOrder, }: {
|
|
222
237
|
product: ProductData;
|
|
223
238
|
date?: {
|
|
224
239
|
startTime: string;
|
|
225
240
|
endTime: string;
|
|
226
241
|
} | null;
|
|
227
242
|
account?: Account | null;
|
|
243
|
+
isLegacyOrder?: boolean;
|
|
228
244
|
}): {
|
|
229
245
|
success: boolean;
|
|
230
246
|
errorCode?: string;
|
|
@@ -326,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
342
|
date: string;
|
|
327
343
|
status: string;
|
|
328
344
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
346
|
}[]>;
|
|
331
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
348
|
private getScheduleDataByIds;
|