@ticketboothapp/booking 1.2.166 → 1.2.168
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/package.json +1 -1
- package/src/components/booking/AdminChangeBookingContent.tsx +15 -1
- package/src/components/booking/AdminChangeBookingFlow.tsx +274 -94
- package/src/components/booking/AdminChangeCheckoutPanel.tsx +49 -13
- package/src/components/booking/AdminChangePricingPanel.tsx +400 -134
- package/src/components/booking/AdminChangePromoEditor.tsx +97 -0
- package/src/components/booking/AdminChangeReceiptComparison.tsx +172 -147
- package/src/components/booking/ChangeBookingFlow.tsx +6 -3
- package/src/components/booking/ChangeBookingQuoteStatusPlaceholder.tsx +7 -2
- package/src/components/booking/ChangeBookingSelectionControlsPanel.tsx +6 -0
- package/src/components/booking/ChangeBookingTicketsAndAddOnsPanel.tsx +80 -0
- package/src/components/booking/NewBookingFlow.tsx +14 -2
- package/src/components/booking/PickupLocationSelector.module.css +22 -0
- package/src/components/booking/PickupLocationSelector.tsx +3 -3
- package/src/components/booking/PriceBreakdown.tsx +66 -15
- package/src/components/booking/PriceSummary.tsx +16 -0
- package/src/components/booking/PrivateShuttleBookingFlow.tsx +52 -14
- package/src/components/booking/PrivateShuttleCheckoutSection.tsx +95 -54
- package/src/components/booking/admin-adjustment-components.ts +44 -0
- package/src/components/booking/admin-adjustment-tax-behavior.ts +50 -0
- package/src/components/booking/admin-change-flow-state-helpers.ts +10 -0
- package/src/components/booking/admin-change-provider-payload.ts +12 -1
- package/src/components/booking/admin-change-quote-request-key.ts +41 -1
- package/src/components/booking/admin-change-receipt-lines.ts +49 -0
- package/src/components/booking/admin-change-v2-quote-request.ts +109 -0
- package/src/components/booking/admin-refund-decision-context.ts +122 -0
- package/src/components/booking/admin-refund-disposition.ts +71 -2
- package/src/components/booking/availability-date-selection.ts +16 -0
- package/src/components/booking/booking-flow-types.ts +4 -0
- package/src/components/booking/booking-flow.css +5 -0
- package/src/components/booking/change-booking-error-message.ts +137 -0
- package/src/components/booking/change-booking-flow-helpers.ts +77 -2
- package/src/components/booking/change-booking-quote-guards.ts +4 -1
- package/src/components/booking/change-booking-quote-state.ts +44 -1
- package/src/components/booking/incompatible-add-on-selections.ts +19 -0
- package/src/components/booking/private-shuttle-availability.ts +14 -0
- package/src/components/booking/private-shuttle-cancellation-policy.ts +9 -0
- package/src/components/booking/private-shuttle-checkout-controller.ts +5 -0
- package/src/components/booking/private-shuttle-provider-change-runner.ts +21 -0
- package/src/components/booking/private-shuttle-reservation-runner.ts +5 -3
- package/src/components/booking/provider-dashboard-change-booking.ts +18 -2
- package/src/components/booking/use-standard-booking-availability.ts +5 -2
- package/src/components/booking/useAdminChangeCheckoutController.ts +56 -1
- package/src/components/booking/useAdminChangeProductReset.ts +6 -0
- package/src/components/booking/useAdminChangeProtectedPricing.ts +4 -0
- package/src/components/booking/useAdminChangeQuoteDisplayState.tsx +8 -6
- package/src/components/booking/useAdminChangeQuotePreview.ts +146 -61
- package/src/components/booking/useAdminCustomReceiptLines.ts +171 -10
- package/src/components/booking/useAdminProviderPricingAdjustments.ts +50 -19
- package/src/components/booking/useBookingAvailabilityAddOns.ts +26 -4
- package/src/components/booking/useBookingPromoAndQuantityController.ts +16 -2
- package/src/components/booking/useChangeBookingAddOnFloorController.ts +15 -9
- package/src/components/booking/useChangeBookingAutoSelections.ts +60 -17
- package/src/components/booking/useChangeBookingInitialHydration.ts +10 -7
- package/src/components/booking/useChangeBookingQuotePreview.ts +3 -1
- package/src/components/booking/useChangeBookingSelectionDetails.ts +23 -17
- package/src/components/booking/useStandardBookingAutoSelections.ts +55 -7
- package/src/lib/booking/booking-cutoffs.ts +22 -0
- package/src/lib/booking/change-booking-server-preview.ts +92 -5
- package/src/lib/booking/change-flow-pricing.ts +12 -0
- package/src/lib/booking/i18n/messages/en.json +1 -0
- package/src/lib/booking/i18n/messages/fr.json +1 -0
- package/src/lib/booking-api.ts +76 -1
- package/test/change-booking-helpers.test.ts +1319 -7
- package/src/components/booking/useAdminChangePricingDebugPanel.tsx +0 -178
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { AdminFeAuthoritativeReceipt } from '../../lib/booking-api';
|
|
3
|
-
import { roundMoney } from '../../lib/booking/change-flow-pricing';
|
|
4
|
-
import { formatCurrencyAmount } from '../../lib/currency';
|
|
5
|
-
import type { ChangeBookingFlowProps } from './booking-flow-types';
|
|
6
|
-
import type { Currency } from './CurrencySwitcher';
|
|
7
|
-
import type { AdminChangeLatestQuote } from './useAdminChangeCheckoutController';
|
|
8
|
-
|
|
9
|
-
type DisplayedChangeAmounts = {
|
|
10
|
-
subtotal: number;
|
|
11
|
-
tax: number;
|
|
12
|
-
total: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type EditableSummaryDebugRow = {
|
|
16
|
-
label: string;
|
|
17
|
-
baseline: number;
|
|
18
|
-
edited: number;
|
|
19
|
-
delta: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export interface UseAdminChangePricingDebugPanelParams {
|
|
23
|
-
isAdmin: boolean;
|
|
24
|
-
hasSelectedAvailability: boolean;
|
|
25
|
-
totalQuantity: number;
|
|
26
|
-
useAdminFeAuthoritativeQuote: boolean;
|
|
27
|
-
currency: Currency;
|
|
28
|
-
locale: string;
|
|
29
|
-
originalReceipt: ChangeBookingFlowProps['originalReceipt'];
|
|
30
|
-
isCustomerSelfServeChange: boolean;
|
|
31
|
-
latestChangeQuote: AdminChangeLatestQuote | null;
|
|
32
|
-
changeQuoteFetchError: string | null;
|
|
33
|
-
displayLayerUsesExternalPricing: boolean;
|
|
34
|
-
selfServePricingConfirmed: boolean;
|
|
35
|
-
changeQuoteLoading: boolean;
|
|
36
|
-
effectiveSubtotal: number;
|
|
37
|
-
adminCustomAdjustmentTotal: number;
|
|
38
|
-
editableSummaryPreSubtotalDebugRows: EditableSummaryDebugRow[];
|
|
39
|
-
effectiveSubtotalForCheckout: number;
|
|
40
|
-
effectiveTax: number;
|
|
41
|
-
effectivePromoDiscountAmount: number;
|
|
42
|
-
totalPrice: number;
|
|
43
|
-
changeFlowNewBookingTotal: number;
|
|
44
|
-
displayedChangeAmountsRaw: DisplayedChangeAmounts;
|
|
45
|
-
editableSummaryPreSubtotalDelta: number;
|
|
46
|
-
displayChangeFlowProposedTotal: number;
|
|
47
|
-
displayChangeFlowProposedTotalWithEditableLines: number;
|
|
48
|
-
adminFeAuthoritativeReceipt: AdminFeAuthoritativeReceipt;
|
|
49
|
-
changeFlowClientEstimateDue: number;
|
|
50
|
-
changeFlowAmountDue: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function useAdminChangePricingDebugPanel({
|
|
54
|
-
isAdmin,
|
|
55
|
-
hasSelectedAvailability,
|
|
56
|
-
totalQuantity,
|
|
57
|
-
useAdminFeAuthoritativeQuote,
|
|
58
|
-
currency,
|
|
59
|
-
locale,
|
|
60
|
-
originalReceipt,
|
|
61
|
-
isCustomerSelfServeChange,
|
|
62
|
-
latestChangeQuote,
|
|
63
|
-
changeQuoteFetchError,
|
|
64
|
-
displayLayerUsesExternalPricing,
|
|
65
|
-
selfServePricingConfirmed,
|
|
66
|
-
changeQuoteLoading,
|
|
67
|
-
effectiveSubtotal,
|
|
68
|
-
adminCustomAdjustmentTotal,
|
|
69
|
-
editableSummaryPreSubtotalDebugRows,
|
|
70
|
-
effectiveSubtotalForCheckout,
|
|
71
|
-
effectiveTax,
|
|
72
|
-
effectivePromoDiscountAmount,
|
|
73
|
-
totalPrice,
|
|
74
|
-
changeFlowNewBookingTotal,
|
|
75
|
-
displayedChangeAmountsRaw,
|
|
76
|
-
editableSummaryPreSubtotalDelta,
|
|
77
|
-
displayChangeFlowProposedTotal,
|
|
78
|
-
displayChangeFlowProposedTotalWithEditableLines,
|
|
79
|
-
adminFeAuthoritativeReceipt,
|
|
80
|
-
changeFlowClientEstimateDue,
|
|
81
|
-
changeFlowAmountDue,
|
|
82
|
-
}: UseAdminChangePricingDebugPanelParams) {
|
|
83
|
-
return useMemo(() => {
|
|
84
|
-
if (!isAdmin || !hasSelectedAvailability || totalQuantity <= 0) return null;
|
|
85
|
-
const fmt = (n: number) => formatCurrencyAmount(roundMoney(n), currency, locale as 'en' | 'fr');
|
|
86
|
-
const path = (() => {
|
|
87
|
-
if (!originalReceipt) return 'totalPrice (no original receipt)';
|
|
88
|
-
if (isCustomerSelfServeChange && latestChangeQuote != null && !changeQuoteFetchError) {
|
|
89
|
-
if (
|
|
90
|
-
latestChangeQuote.quotePreviousTotalCents != null &&
|
|
91
|
-
latestChangeQuote.quoteNewTotalCents != null
|
|
92
|
-
) {
|
|
93
|
-
return 'POST /change/quote: (quoteNewTotalCents - quotePreviousTotalCents) / 100';
|
|
94
|
-
}
|
|
95
|
-
if (latestChangeQuote.serverDisplay != null) {
|
|
96
|
-
return 'POST /change/quote: serverDisplay.total - originalReceipt.total';
|
|
97
|
-
}
|
|
98
|
-
return 'POST /change/quote: priceDiff (API balance delta)';
|
|
99
|
-
}
|
|
100
|
-
return 'FE: displayChangeFlowProposedTotal - originalReceipt.total (signed; used when quote not driving amount-due)';
|
|
101
|
-
})();
|
|
102
|
-
const quoteTotalPreview =
|
|
103
|
-
latestChangeQuote?.serverDisplay != null ? fmt(latestChangeQuote.serverDisplay.total) : '-';
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<details className="mt-3 rounded-md border border-amber-200/80 bg-amber-50/50 p-2 text-left text-xs text-amber-950">
|
|
107
|
-
<summary className="cursor-pointer select-none font-medium text-stone-800">
|
|
108
|
-
Price calculation (admin debug)
|
|
109
|
-
</summary>
|
|
110
|
-
<pre className="mt-2 max-h-64 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-stone-800">
|
|
111
|
-
{[
|
|
112
|
-
`Amount-due path: ${path}`,
|
|
113
|
-
`adminFeAuthoritativeQuote: ${String(useAdminFeAuthoritativeQuote)}`,
|
|
114
|
-
`displayLayerUsesExternalPricing: ${String(displayLayerUsesExternalPricing)} (server/provider totals omit FE admin lines until overlaid)`,
|
|
115
|
-
`selfServePricingConfirmed: ${String(selfServePricingConfirmed)} | changeQuoteLoading: ${String(changeQuoteLoading)}`,
|
|
116
|
-
`Cart subtotal (excl. admin custom lines): ${fmt(effectiveSubtotal)}`,
|
|
117
|
-
`Admin custom lines (sum): ${fmt(adminCustomAdjustmentTotal)}`,
|
|
118
|
-
`Pre-subtotal line overrides:`,
|
|
119
|
-
...editableSummaryPreSubtotalDebugRows.map(
|
|
120
|
-
(row, idx) =>
|
|
121
|
-
` ${idx + 1}. ${row.label} | baseline ${fmt(row.baseline)} -> edited ${fmt(row.edited)} (delta ${fmt(row.delta)})`
|
|
122
|
-
),
|
|
123
|
-
`Checkout subtotal (incl. admin lines): ${fmt(effectiveSubtotalForCheckout)}`,
|
|
124
|
-
`effectiveTax | promo discount: ${fmt(effectiveTax)} | ${fmt(effectivePromoDiscountAmount)}`,
|
|
125
|
-
`totalPrice (subtotal + tax - promo): ${fmt(totalPrice)}`,
|
|
126
|
-
`changeFlowNewBookingTotal (after cent reconcile vs receipt): ${fmt(changeFlowNewBookingTotal)}`,
|
|
127
|
-
`Displayed layer subtotal / tax / total: ${fmt(displayedChangeAmountsRaw.subtotal)} / ${fmt(displayedChangeAmountsRaw.tax)} / ${fmt(displayedChangeAmountsRaw.total)}`,
|
|
128
|
-
`Pre-subtotal editable lines delta: ${fmt(editableSummaryPreSubtotalDelta)}`,
|
|
129
|
-
`displayChangeFlowProposedTotal (base): ${fmt(displayChangeFlowProposedTotal)}`,
|
|
130
|
-
`displayChangeFlowProposedTotal (with editable lines): ${fmt(displayChangeFlowProposedTotalWithEditableLines)}`,
|
|
131
|
-
`feReceipt sent subtotal/tax/total: ${fmt(adminFeAuthoritativeReceipt.subtotal)} / ${fmt(adminFeAuthoritativeReceipt.tax)} / ${fmt(adminFeAuthoritativeReceipt.total)}`,
|
|
132
|
-
`feReceipt sent lineItems count: ${String(adminFeAuthoritativeReceipt.lineItems.length)}`,
|
|
133
|
-
originalReceipt ? `originalReceipt.total: ${fmt(originalReceipt.total)}` : 'originalReceipt: -',
|
|
134
|
-
`Quote serverDisplay.total (if any): ${quoteTotalPreview}`,
|
|
135
|
-
`Quote serverDisplay subtotal/tax/total: ${
|
|
136
|
-
latestChangeQuote?.serverDisplay
|
|
137
|
-
? `${fmt(latestChangeQuote.serverDisplay.subtotal)} / ${fmt(latestChangeQuote.serverDisplay.tax)} / ${fmt(latestChangeQuote.serverDisplay.total)}`
|
|
138
|
-
: '-'
|
|
139
|
-
}`,
|
|
140
|
-
`changeFlowClientEstimateDue (before near-zero): ${fmt(changeFlowClientEstimateDue)}`,
|
|
141
|
-
`changeFlowAmountDue (PriceSummary total row): ${fmt(changeFlowAmountDue)}`,
|
|
142
|
-
].join('\n')}
|
|
143
|
-
</pre>
|
|
144
|
-
</details>
|
|
145
|
-
);
|
|
146
|
-
}, [
|
|
147
|
-
isAdmin,
|
|
148
|
-
hasSelectedAvailability,
|
|
149
|
-
totalQuantity,
|
|
150
|
-
useAdminFeAuthoritativeQuote,
|
|
151
|
-
currency,
|
|
152
|
-
locale,
|
|
153
|
-
originalReceipt,
|
|
154
|
-
isCustomerSelfServeChange,
|
|
155
|
-
latestChangeQuote,
|
|
156
|
-
changeQuoteFetchError,
|
|
157
|
-
displayLayerUsesExternalPricing,
|
|
158
|
-
selfServePricingConfirmed,
|
|
159
|
-
changeQuoteLoading,
|
|
160
|
-
effectiveSubtotal,
|
|
161
|
-
adminCustomAdjustmentTotal,
|
|
162
|
-
editableSummaryPreSubtotalDebugRows,
|
|
163
|
-
effectiveSubtotalForCheckout,
|
|
164
|
-
effectiveTax,
|
|
165
|
-
effectivePromoDiscountAmount,
|
|
166
|
-
totalPrice,
|
|
167
|
-
changeFlowNewBookingTotal,
|
|
168
|
-
displayedChangeAmountsRaw.subtotal,
|
|
169
|
-
displayedChangeAmountsRaw.tax,
|
|
170
|
-
displayedChangeAmountsRaw.total,
|
|
171
|
-
editableSummaryPreSubtotalDelta,
|
|
172
|
-
displayChangeFlowProposedTotal,
|
|
173
|
-
displayChangeFlowProposedTotalWithEditableLines,
|
|
174
|
-
adminFeAuthoritativeReceipt,
|
|
175
|
-
changeFlowClientEstimateDue,
|
|
176
|
-
changeFlowAmountDue,
|
|
177
|
-
]);
|
|
178
|
-
}
|