@pisell/pisellos 2.3.185 → 2.3.187
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/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +17 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +5 -0
- package/dist/modules/Rules/index.js +30 -19
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +298 -209
- package/dist/solution/BaseSales/types.d.ts +3 -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 +2 -2
- package/dist/solution/UnifiedBookingSales/index.js +34 -16
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +18 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +5 -0
- package/lib/modules/Rules/index.js +19 -9
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +95 -36
- package/lib/solution/BaseSales/types.d.ts +3 -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 +2 -2
- package/lib/solution/UnifiedBookingSales/index.js +23 -1
- package/package.json +1 -1
- package/dist/apis/picoding.d.ts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/effects/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/inventory/index.d.ts.map +0 -1
- package/dist/model/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts.map +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts.map +0 -1
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts.map +0 -1
- package/dist/model/strategy/adapter/dataVariant/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/dataVariant/type.d.ts.map +0 -1
- package/dist/model/strategy/adapter/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts.map +0 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts.map +0 -1
- package/dist/model/strategy/adapter/itemRule/examples.d.ts.map +0 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts.map +0 -1
- package/dist/model/strategy/adapter/promotion/adapter.d.ts.map +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts.map +0 -1
- package/dist/model/strategy/adapter/promotion/examples.d.ts.map +0 -1
- package/dist/model/strategy/adapter/promotion/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts.map +0 -1
- package/dist/model/strategy/adapter/type.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/example.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/index.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/type.d.ts.map +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts.map +0 -1
- package/dist/model/strategy/engine.d.ts.map +0 -1
- package/dist/model/strategy/index.d.ts.map +0 -1
- package/dist/model/strategy/strategy-example.d.ts.map +0 -1
- package/dist/model/strategy/type.d.ts.map +0 -1
- package/dist/modules/Account/index.d.ts.map +0 -1
- package/dist/modules/Account/types.d.ts.map +0 -1
- package/dist/modules/AccountList/index.d.ts.map +0 -1
- package/dist/modules/AccountList/types.d.ts.map +0 -1
- package/dist/modules/AccountList/utils.d.ts.map +0 -1
- package/dist/modules/BaseModule.d.ts.map +0 -1
- package/dist/modules/BookingContext/index.d.ts.map +0 -1
- package/dist/modules/BookingContext/types.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/flexible.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/index.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/noResource.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/productExtend.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/resources.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts.map +0 -1
- package/dist/modules/BookingContext/utils/timeSlices.d.ts.map +0 -1
- package/dist/modules/BusinessAvailability/index.d.ts.map +0 -1
- package/dist/modules/Cart/index.d.ts.map +0 -1
- package/dist/modules/Cart/types.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartAccount.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartDate.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartDiscount.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartNote.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartProduct.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartRelationForms.d.ts.map +0 -1
- package/dist/modules/Cart/utils/cartResource.d.ts.map +0 -1
- package/dist/modules/Cart/utils/changePrice.d.ts.map +0 -1
- package/dist/modules/Cart/utils/index.d.ts.map +0 -1
- package/dist/modules/Customer/constants.d.ts.map +0 -1
- package/dist/modules/Customer/index.d.ts.map +0 -1
- package/dist/modules/Customer/types.d.ts.map +0 -1
- package/dist/modules/Date/index.d.ts.map +0 -1
- package/dist/modules/Date/types.d.ts.map +0 -1
- package/dist/modules/Date/utils.d.ts.map +0 -1
- package/dist/modules/Discount/availability.d.ts.map +0 -1
- package/dist/modules/Discount/entitlementPass.d.ts.map +0 -1
- package/dist/modules/Discount/index.d.ts.map +0 -1
- package/dist/modules/Discount/types.d.ts.map +0 -1
- package/dist/modules/FulfillmentTiming/index.d.ts.map +0 -1
- package/dist/modules/FulfillmentTiming/types.d.ts.map +0 -1
- package/dist/modules/Guests/index.d.ts.map +0 -1
- package/dist/modules/Guests/types.d.ts.map +0 -1
- package/dist/modules/Holder/index.d.ts.map +0 -1
- package/dist/modules/Holder/types.d.ts.map +0 -1
- package/dist/modules/Holder/utils.d.ts.map +0 -1
- package/dist/modules/OpenData/contactInfo.d.ts.map +0 -1
- package/dist/modules/OpenData/index.d.ts.map +0 -1
- package/dist/modules/OpenData/salesSettings.d.ts.map +0 -1
- package/dist/modules/OpenData/types.d.ts.map +0 -1
- package/dist/modules/OpenData/utils.d.ts.map +0 -1
- package/dist/modules/Order/holderRelations.d.ts.map +0 -1
- package/dist/modules/Order/index.d.ts.map +0 -1
- package/dist/modules/Order/localEftposState.d.ts.map +0 -1
- package/dist/modules/Order/payment-utils.d.ts.map +0 -1
- package/dist/modules/Order/pickupTiming.d.ts.map +0 -1
- package/dist/modules/Order/salesNotes.d.ts.map +0 -1
- package/dist/modules/Order/types.d.ts.map +0 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts.map +0 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts.map +0 -1
- package/dist/modules/Order/utils/manualProductDiscount.d.ts.map +0 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts.map +0 -1
- package/dist/modules/Order/utils/productVoucherGroups.d.ts.map +0 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts.map +0 -1
- package/dist/modules/Order/utils/weighedProduct.d.ts.map +0 -1
- package/dist/modules/Order/utils.d.ts.map +0 -1
- package/dist/modules/Payment/cash.d.ts.map +0 -1
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts.map +0 -1
- package/dist/modules/Payment/eftpos.d.ts.map +0 -1
- package/dist/modules/Payment/index.d.ts.map +0 -1
- package/dist/modules/Payment/mx51.d.ts.map +0 -1
- package/dist/modules/Payment/types.d.ts.map +0 -1
- package/dist/modules/Payment/utils.d.ts.map +0 -1
- package/dist/modules/Payment/walletpass.d.ts.map +0 -1
- package/dist/modules/Product/index.d.ts.map +0 -1
- package/dist/modules/Product/types.d.ts.map +0 -1
- package/dist/modules/Product/utils.d.ts.map +0 -1
- package/dist/modules/ProductList/clientDataVariants.d.ts.map +0 -1
- package/dist/modules/ProductList/index.d.ts.map +0 -1
- package/dist/modules/ProductList/types.d.ts.map +0 -1
- package/dist/modules/Quotation/index.d.ts.map +0 -1
- package/dist/modules/Quotation/types.d.ts.map +0 -1
- package/dist/modules/Resource/index.d.ts.map +0 -1
- package/dist/modules/Resource/types.d.ts.map +0 -1
- package/dist/modules/Resource/utils.d.ts.map +0 -1
- package/dist/modules/ResourcePlanner/index.d.ts.map +0 -1
- package/dist/modules/ResourcePlanner/localClock.d.ts.map +0 -1
- package/dist/modules/ResourcePlanner/planner.d.ts.map +0 -1
- package/dist/modules/ResourcePlanner/types.d.ts.map +0 -1
- package/dist/modules/Rules/index.d.ts.map +0 -1
- package/dist/modules/Rules/promotionSelection.d.ts.map +0 -1
- package/dist/modules/Rules/types.d.ts.map +0 -1
- package/dist/modules/SalesSummary/index.d.ts.map +0 -1
- package/dist/modules/SalesSummary/types.d.ts.map +0 -1
- package/dist/modules/SalesSummary/utils.d.ts.map +0 -1
- package/dist/modules/ScanOrderLogger/index.d.ts.map +0 -1
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts.map +0 -1
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts.map +0 -1
- package/dist/modules/ScanOrderLogger/types.d.ts.map +0 -1
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts.map +0 -1
- package/dist/modules/Schedule/index.d.ts.map +0 -1
- package/dist/modules/Schedule/type.d.ts.map +0 -1
- package/dist/modules/Schedule/types.d.ts.map +0 -1
- package/dist/modules/Schedule/utils.d.ts.map +0 -1
- package/dist/modules/Step/index.d.ts.map +0 -1
- package/dist/modules/Step/tyeps.d.ts.map +0 -1
- package/dist/modules/Summary/index.d.ts.map +0 -1
- package/dist/modules/Summary/types.d.ts.map +0 -1
- package/dist/modules/Summary/utils.d.ts.map +0 -1
- package/dist/modules/SurchargeList/index.d.ts.map +0 -1
- package/dist/modules/SurchargeList/types.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/plugins/app.d.ts.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/request.d.ts.map +0 -1
- package/dist/plugins/shopStore.d.ts.map +0 -1
- package/dist/plugins/user.d.ts.map +0 -1
- package/dist/plugins/window.d.ts.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/modules/floor-plan/index.d.ts.map +0 -1
- package/dist/server/modules/floor-plan/types.d.ts.map +0 -1
- package/dist/server/modules/form/index.d.ts.map +0 -1
- package/dist/server/modules/form/types.d.ts.map +0 -1
- package/dist/server/modules/index.d.ts.map +0 -1
- package/dist/server/modules/menu/index.d.ts.map +0 -1
- package/dist/server/modules/menu/types.d.ts.map +0 -1
- package/dist/server/modules/order/index.d.ts.map +0 -1
- package/dist/server/modules/order/types.d.ts.map +0 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts.map +0 -1
- package/dist/server/modules/order/utils/filterOrders.d.ts.map +0 -1
- package/dist/server/modules/payment/index.d.ts.map +0 -1
- package/dist/server/modules/payment/types.d.ts.map +0 -1
- package/dist/server/modules/products/index.d.ts.map +0 -1
- package/dist/server/modules/products/replication.d.ts.map +0 -1
- package/dist/server/modules/products/types.d.ts.map +0 -1
- package/dist/server/modules/quotation/index.d.ts.map +0 -1
- package/dist/server/modules/quotation/types.d.ts.map +0 -1
- package/dist/server/modules/resource/index.d.ts.map +0 -1
- package/dist/server/modules/resource/types.d.ts.map +0 -1
- package/dist/server/modules/schedule/index.d.ts.map +0 -1
- package/dist/server/modules/schedule/types.d.ts.map +0 -1
- package/dist/server/modules/schedule/utils.d.ts.map +0 -1
- package/dist/server/types.d.ts.map +0 -1
- package/dist/server/utils/index.d.ts.map +0 -1
- package/dist/server/utils/product.d.ts.map +0 -1
- package/dist/server/utils/schedule.d.ts.map +0 -1
- package/dist/server/utils/small-ticket.d.ts.map +0 -1
- package/dist/server/utils/time.d.ts.map +0 -1
- package/dist/shared/payment/loadPaymentMethods.d.ts.map +0 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts.map +0 -1
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts.map +0 -1
- package/dist/shared/receipt/small-ticket.d.ts.map +0 -1
- package/dist/shared/receipt/templateVisibility.d.ts.map +0 -1
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts.map +0 -1
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts.map +0 -1
- package/dist/solution/BaseSales/index.d.ts.map +0 -1
- package/dist/solution/BaseSales/pickupTiming.d.ts.map +0 -1
- package/dist/solution/BaseSales/types.d.ts.map +0 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts.map +0 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts.map +0 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts.map +0 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts.map +0 -1
- package/dist/solution/BaseSales/utils.d.ts.map +0 -1
- package/dist/solution/BookingByStep/index.d.ts.map +0 -1
- package/dist/solution/BookingByStep/types.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/capacity.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/stock.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts.map +0 -1
- package/dist/solution/BookingTicket/index.d.ts.map +0 -1
- package/dist/solution/BookingTicket/types.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/cartView.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/exampleData.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/index.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts.map +0 -1
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts.map +0 -1
- package/dist/solution/BuyTickets/index.d.ts.map +0 -1
- package/dist/solution/BuyTickets/types.d.ts.map +0 -1
- package/dist/solution/Checkout/index.d.ts.map +0 -1
- package/dist/solution/Checkout/types.d.ts.map +0 -1
- package/dist/solution/Checkout/utils/index.d.ts.map +0 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts.map +0 -1
- package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
- package/dist/solution/RegisterAndLogin/config.d.ts.map +0 -1
- package/dist/solution/RegisterAndLogin/index.d.ts.map +0 -1
- package/dist/solution/RegisterAndLogin/types.d.ts.map +0 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts.map +0 -1
- package/dist/solution/Sales/index.d.ts.map +0 -1
- package/dist/solution/Sales/types.d.ts.map +0 -1
- package/dist/solution/ScanOrder/index.d.ts.map +0 -1
- package/dist/solution/ScanOrder/menuAvailability.d.ts.map +0 -1
- package/dist/solution/ScanOrder/types.d.ts.map +0 -1
- package/dist/solution/ScanOrder/utils.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/index.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts.map +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts.map +0 -1
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts.map +0 -1
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts.map +0 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts.map +0 -1
- package/dist/solution/VenueBooking/index.d.ts.map +0 -1
- package/dist/solution/VenueBooking/types.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils/resource.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts.map +0 -1
- package/dist/solution/VenueBooking/utils.d.ts.map +0 -1
- package/dist/solution/index.d.ts.map +0 -1
- package/dist/store/createStore.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/os-private-payload.d.ts.map +0 -1
- package/dist/utils/payment-number.d.ts.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/task.d.ts.map +0 -1
- package/dist/utils/watch.d.ts.map +0 -1
|
@@ -348,6 +348,9 @@ export interface BaseSalesProductBookingPriceResult {
|
|
|
348
348
|
unit_price: string;
|
|
349
349
|
total_price: string;
|
|
350
350
|
quantity: number;
|
|
351
|
+
pricing_method?: {
|
|
352
|
+
type: 'fixed_price' | 'duration_based';
|
|
353
|
+
};
|
|
351
354
|
duration?: BaseSalesQuotationDurationConfig;
|
|
352
355
|
quotation_shelf_id: number;
|
|
353
356
|
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: {
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -4024,10 +4024,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4024
4024
|
}, {
|
|
4025
4025
|
key: "buildUnifiedOrderProduct",
|
|
4026
4026
|
value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
|
|
4027
|
-
var _ref42, _sourceProduct$
|
|
4027
|
+
var _sourceProduct$_exten, _this$otherParams36, _bookingQuote$pricing, _ref42, _sourceProduct$_exten2, _sourceProduct$_exten3, _sourceProduct$metada, _sourceProduct$id, _ref43, _sourceProduct$produc, _ref44, _ref45, _sourceProduct$quanti, _sourceProduct$price, _ref46, _ref47, _sourceProduct$sellin;
|
|
4028
4028
|
var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
|
|
4029
|
-
var
|
|
4030
|
-
var
|
|
4029
|
+
var bookingQuote = (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.bookingPriceQuote;
|
|
4030
|
+
var isPos = normalizeRuntimePlatform((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.platform) === 'pos';
|
|
4031
|
+
var quoteMethod = isPos ? bookingQuote === null || bookingQuote === void 0 || (_bookingQuote$pricing = bookingQuote.pricing_method) === null || _bookingQuote$pricing === void 0 ? void 0 : _bookingQuote$pricing.type : undefined;
|
|
4032
|
+
var hasDurationQuote = quoteMethod === 'duration_based';
|
|
4033
|
+
var quoteSourcePrice = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.sourceUnitPrice;
|
|
4034
|
+
var quoteDuration = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.duration;
|
|
4035
|
+
if (hasDurationQuote && (quoteSourcePrice === undefined || quoteSourcePrice === null || quoteSourcePrice === '' || !Number.isFinite(Number(quoteSourcePrice)) || Number(quoteSourcePrice) < 0 || (quoteDuration === null || quoteDuration === void 0 ? void 0 : quoteDuration.type) !== 'minutes' || !Number.isFinite(Number(quoteDuration.value)) || Number(quoteDuration.value) <= 0)) {
|
|
4036
|
+
throw Object.assign(new Error('按时长计价结果无效,请重新选择预约时间。'), {
|
|
4037
|
+
code: 'DURATION_PRICING_UNAVAILABLE'
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
var quotationShelfId = (_ref42 = (_sourceProduct$_exten2 = (_sourceProduct$_exten3 = sourceProduct._extend) === null || _sourceProduct$_exten3 === void 0 ? void 0 : _sourceProduct$_exten3.quotation_shelf_id) !== null && _sourceProduct$_exten2 !== void 0 ? _sourceProduct$_exten2 : sourceProduct.quotation_shelf_id) !== null && _ref42 !== void 0 ? _ref42 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
|
|
4041
|
+
var orderProduct = this.transformBaseProductToOrderProduct(_objectSpread({
|
|
4031
4042
|
payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
|
|
4032
4043
|
id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
|
|
4033
4044
|
product_id: (_ref43 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref43 !== void 0 ? _ref43 : product === null || product === void 0 ? void 0 : product.id,
|
|
@@ -4037,11 +4048,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4037
4048
|
metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
|
|
4038
4049
|
}),
|
|
4039
4050
|
sourceProduct: sourceProduct
|
|
4040
|
-
}
|
|
4051
|
+
}, hasDurationQuote ? {
|
|
4052
|
+
quotedSourceProductPrice: quoteSourcePrice
|
|
4053
|
+
} : {}));
|
|
4041
4054
|
if (orderProduct && _typeof(orderProduct) === 'object') {
|
|
4042
4055
|
// BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
|
|
4043
4056
|
// quotation shelf after that transform so neither booking adds nor edits lose quote identity.
|
|
4044
|
-
orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true),
|
|
4057
|
+
orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), hasDurationQuote || quoteMethod === 'fixed_price' ? {
|
|
4058
|
+
pricing_method: {
|
|
4059
|
+
type: quoteMethod
|
|
4060
|
+
},
|
|
4061
|
+
duration: hasDurationQuote ? _objectSpread({}, quoteDuration) : undefined
|
|
4062
|
+
} : {}), quotationShelfId !== undefined ? {
|
|
4045
4063
|
quotation_shelf_id: quotationShelfId
|
|
4046
4064
|
} : {});
|
|
4047
4065
|
}
|
|
@@ -5606,7 +5624,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5606
5624
|
value: (function () {
|
|
5607
5625
|
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(contextId) {
|
|
5608
5626
|
var _this$otherParams$pla2,
|
|
5609
|
-
_this$
|
|
5627
|
+
_this$otherParams37,
|
|
5610
5628
|
_context$prepareParam,
|
|
5611
5629
|
_extractFixedOffsetMi,
|
|
5612
5630
|
_this16 = this;
|
|
@@ -5636,7 +5654,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5636
5654
|
context = _yield$this$ensureAva.context;
|
|
5637
5655
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
5638
5656
|
contextVersion = context.activeVersion;
|
|
5639
|
-
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$
|
|
5657
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
5640
5658
|
isEditingContext = Boolean((_context$prepareParam = context.prepareParams.editingProductLineUids) === null || _context$prepareParam === void 0 ? void 0 : _context$prepareParam.length);
|
|
5641
5659
|
editingOffset = (_extractFixedOffsetMi = extractFixedOffsetMinutes(projectionEntry.projection.meta.now)) !== null && _extractFixedOffsetMi !== void 0 ? _extractFixedOffsetMi : this.getAvailabilityRuntimeOffsetMinutes(); // This new editing input represents an absolute instant. Normalize it once
|
|
5642
5660
|
// to the projection's fixed business clock before the wall-clock planner.
|
|
@@ -5704,7 +5722,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5704
5722
|
key: "queryBookingAvailability",
|
|
5705
5723
|
value: (function () {
|
|
5706
5724
|
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(contextId, request) {
|
|
5707
|
-
var _this$otherParams$pla3, _this$
|
|
5725
|
+
var _this$otherParams$pla3, _this$otherParams38, _context$prepareParam2;
|
|
5708
5726
|
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, queryRequest, result, contextVersion, contextualResult;
|
|
5709
5727
|
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5710
5728
|
while (1) switch (_context54.prev = _context54.next) {
|
|
@@ -5717,7 +5735,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5717
5735
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
5718
5736
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
5719
5737
|
this.assertContextualQueryFreshness(context, request);
|
|
5720
|
-
isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$
|
|
5738
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
|
|
5721
5739
|
queryRequest = request.target === 'date' || request.target === 'product' ? _objectSpread(_objectSpread({}, request), {}, {
|
|
5722
5740
|
dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
|
|
5723
5741
|
}) : request;
|
|
@@ -5834,14 +5852,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5834
5852
|
value: function () {
|
|
5835
5853
|
var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(startDate) {
|
|
5836
5854
|
var _this$getTempOrder5,
|
|
5837
|
-
_this$
|
|
5855
|
+
_this$otherParams39,
|
|
5838
5856
|
_this17 = this;
|
|
5839
5857
|
var products, targetDate, identities;
|
|
5840
5858
|
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5841
5859
|
while (1) switch (_context55.prev = _context55.next) {
|
|
5842
5860
|
case 0:
|
|
5843
5861
|
products = ((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || [];
|
|
5844
|
-
if (!(((_this$
|
|
5862
|
+
if (!(((_this$otherParams39 = this.otherParams) === null || _this$otherParams39 === void 0 ? void 0 : _this$otherParams39.enforceSingleBookingStartDate) !== true)) {
|
|
5845
5863
|
_context55.next = 3;
|
|
5846
5864
|
break;
|
|
5847
5865
|
}
|
|
@@ -5881,12 +5899,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5881
5899
|
value: (function () {
|
|
5882
5900
|
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(contextId, params) {
|
|
5883
5901
|
var _this$otherParams$pla4,
|
|
5884
|
-
_this$
|
|
5902
|
+
_this$otherParams40,
|
|
5885
5903
|
_params$availabilityC,
|
|
5886
5904
|
_this$store$order11,
|
|
5887
5905
|
_this$store$order11$e,
|
|
5888
5906
|
_this18 = this;
|
|
5889
|
-
var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref57, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$
|
|
5907
|
+
var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref57, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams41, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams42, _ref58, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref59, _ref60, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref61, _transformed$product_4, _this$getTempOrder6, _this$getTempOrder7, _params$salesNotes, _params$salesNotes2, _ref62, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
|
|
5890
5908
|
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5891
5909
|
while (1) switch (_context56.prev = _context56.next) {
|
|
5892
5910
|
case 0:
|
|
@@ -5900,7 +5918,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5900
5918
|
});
|
|
5901
5919
|
case 3:
|
|
5902
5920
|
isRememberedSelection = params.selectionIntent === 'remembered';
|
|
5903
|
-
if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$
|
|
5921
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
|
|
5904
5922
|
_context56.next = 6;
|
|
5905
5923
|
break;
|
|
5906
5924
|
}
|
|
@@ -6089,7 +6107,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6089
6107
|
selectedProduct = baseProjection.products.find(function (item) {
|
|
6090
6108
|
return sameAvailabilityId(item.id, params.candidate.productId);
|
|
6091
6109
|
});
|
|
6092
|
-
if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$
|
|
6110
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
|
|
6093
6111
|
_context56.next = 67;
|
|
6094
6112
|
break;
|
|
6095
6113
|
}
|
|
@@ -6152,7 +6170,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6152
6170
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
6153
6171
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
6154
6172
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
6155
|
-
allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$
|
|
6173
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
|
|
6156
6174
|
candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
|
|
6157
6175
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
6158
6176
|
productIds: [params.candidate.productId],
|
|
@@ -128,7 +128,9 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
|
|
|
128
128
|
*
|
|
129
129
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
130
130
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
131
|
-
* (`metadata.source_product_price
|
|
131
|
+
* (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
|
|
132
|
+
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
133
|
+
* Rules 内部 `getProductTotalPrice` /
|
|
132
134
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
133
135
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
134
136
|
* total(source + option + bundle)对齐。
|
|
@@ -651,7 +651,9 @@ function getBundleSellingMagnitude(bundle) {
|
|
|
651
651
|
*
|
|
652
652
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
653
653
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
654
|
-
* (`metadata.source_product_price
|
|
654
|
+
* (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
|
|
655
|
+
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
656
|
+
* Rules 内部 `getProductTotalPrice` /
|
|
655
657
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
656
658
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
657
659
|
* total(source + option + bundle)对齐。
|
|
@@ -934,7 +936,8 @@ function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
934
936
|
_id: product.metadata?.unique_identification_number ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, _utils2.buildProductLineFingerprint)(getProductSkuOptions(product), product.product_bundle)}`,
|
|
935
937
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
936
938
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
937
|
-
|
|
939
|
+
// 赠品基础价不再参与卡券;source 元数据保留原价,供后续与赠送优惠相抵。
|
|
940
|
+
price: metadataAny._giftInfo ? '0.00' : sourcePrice,
|
|
938
941
|
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
939
942
|
total: new _decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
940
943
|
origin_total: new _decimal.default(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
@@ -1275,6 +1278,19 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
|
|
|
1275
1278
|
cleanMetadata[key] = rawMetadata[key];
|
|
1276
1279
|
}
|
|
1277
1280
|
}
|
|
1281
|
+
// Persist only an applied pricing snapshot, so reopening a saved order can
|
|
1282
|
+
// compare it with the latest catalog without reinterpreting legacy duration.
|
|
1283
|
+
const pricingMethod = rawMetadata.pricing_method?.type;
|
|
1284
|
+
if (pricingMethod === 'duration_based' || pricingMethod === 'fixed_price') {
|
|
1285
|
+
cleanMetadata.pricing_method = {
|
|
1286
|
+
type: pricingMethod
|
|
1287
|
+
};
|
|
1288
|
+
if (pricingMethod === 'duration_based' && rawMetadata.duration) {
|
|
1289
|
+
cleanMetadata.duration = {
|
|
1290
|
+
...rawMetadata.duration
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1278
1294
|
cleanMetadata.product_discount_difference = rawMetadata.product_discount_difference ?? '';
|
|
1279
1295
|
if (rawMetadata.price_breakdown) {
|
|
1280
1296
|
cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -42,6 +42,9 @@ export interface ProductSettlementOption extends Record<string, any> {
|
|
|
42
42
|
available: boolean;
|
|
43
43
|
disabled_reason?: string;
|
|
44
44
|
}
|
|
45
|
+
export interface ProductPricingMethod {
|
|
46
|
+
type: 'fixed_price' | 'duration_based';
|
|
47
|
+
}
|
|
45
48
|
/**
|
|
46
49
|
* 商品基本信息接口
|
|
47
50
|
*/
|
|
@@ -74,6 +77,8 @@ export interface ProductData {
|
|
|
74
77
|
sum_stock: number;
|
|
75
78
|
/** 商品价格 */
|
|
76
79
|
price: string;
|
|
80
|
+
/** POS booking pricing; missing configuration retains existing fixed pricing. */
|
|
81
|
+
pricing_method?: ProductPricingMethod;
|
|
77
82
|
/** 当前上下文解析出的可选结算货币 */
|
|
78
83
|
available_settlement_options?: ProductSettlementOption[];
|
|
79
84
|
/** 商品原价 */
|