@ticketboothapp/booking 1.2.167 → 1.2.169

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.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/src/components/booking/AdminChangeBookingContent.tsx +13 -1
  3. package/src/components/booking/AdminChangeBookingFlow.tsx +180 -65
  4. package/src/components/booking/AdminChangeCheckoutPanel.tsx +43 -13
  5. package/src/components/booking/AdminChangePricingPanel.tsx +400 -134
  6. package/src/components/booking/AdminChangeReceiptComparison.tsx +166 -145
  7. package/src/components/booking/ChangeBookingFlow.tsx +7 -3
  8. package/src/components/booking/ChangeBookingQuoteStatusPlaceholder.tsx +7 -2
  9. package/src/components/booking/ChangeBookingSelectionControlsPanel.tsx +6 -0
  10. package/src/components/booking/ChangeBookingTicketsAndAddOnsPanel.tsx +80 -0
  11. package/src/components/booking/PickupLocationSelector.module.css +22 -0
  12. package/src/components/booking/PickupLocationSelector.tsx +3 -3
  13. package/src/components/booking/PriceSummary.tsx +4 -0
  14. package/src/components/booking/PrivateShuttleBookingFlow.tsx +27 -13
  15. package/src/components/booking/PrivateShuttleCheckoutSection.tsx +95 -54
  16. package/src/components/booking/admin-adjustment-components.ts +44 -0
  17. package/src/components/booking/admin-adjustment-tax-behavior.ts +50 -0
  18. package/src/components/booking/admin-change-flow-state-helpers.ts +10 -0
  19. package/src/components/booking/admin-change-provider-payload.ts +3 -0
  20. package/src/components/booking/admin-change-quote-request-key.ts +27 -0
  21. package/src/components/booking/admin-change-v2-quote-request.ts +10 -2
  22. package/src/components/booking/admin-refund-decision-context.ts +37 -0
  23. package/src/components/booking/admin-refund-disposition.ts +71 -2
  24. package/src/components/booking/booking-flow-types.ts +4 -0
  25. package/src/components/booking/booking-flow.css +5 -0
  26. package/src/components/booking/change-booking-error-message.ts +137 -0
  27. package/src/components/booking/change-booking-flow-helpers.ts +77 -2
  28. package/src/components/booking/change-booking-quote-guards.ts +4 -1
  29. package/src/components/booking/change-booking-quote-state.ts +44 -1
  30. package/src/components/booking/incompatible-add-on-selections.ts +19 -0
  31. package/src/components/booking/private-shuttle-availability.ts +14 -0
  32. package/src/components/booking/private-shuttle-cancellation-policy.ts +9 -0
  33. package/src/components/booking/private-shuttle-checkout-controller.ts +5 -0
  34. package/src/components/booking/private-shuttle-provider-change-runner.ts +21 -0
  35. package/src/components/booking/private-shuttle-reservation-runner.ts +5 -3
  36. package/src/components/booking/provider-dashboard-change-booking.ts +16 -1
  37. package/src/components/booking/useAdminChangeCheckoutController.ts +16 -0
  38. package/src/components/booking/useAdminChangeProductReset.ts +6 -0
  39. package/src/components/booking/useAdminChangeProtectedPricing.ts +4 -0
  40. package/src/components/booking/useAdminChangeQuoteDisplayState.tsx +6 -4
  41. package/src/components/booking/useAdminChangeQuotePreview.ts +76 -20
  42. package/src/components/booking/useAdminCustomReceiptLines.ts +171 -10
  43. package/src/components/booking/useAdminProviderPricingAdjustments.ts +50 -19
  44. package/src/components/booking/useBookingAvailabilityAddOns.ts +19 -2
  45. package/src/components/booking/useChangeBookingAddOnFloorController.ts +15 -9
  46. package/src/components/booking/useChangeBookingInitialHydration.ts +10 -7
  47. package/src/components/booking/useChangeBookingQuotePreview.ts +3 -1
  48. package/src/components/booking/useChangeBookingSelectionDetails.ts +23 -17
  49. package/src/lib/booking/change-booking-server-preview.ts +26 -9
  50. package/src/lib/booking/change-flow-pricing.ts +12 -0
  51. package/src/lib/booking/i18n/messages/en.json +1 -0
  52. package/src/lib/booking/i18n/messages/fr.json +1 -0
  53. package/src/lib/booking-api.ts +64 -0
  54. package/test/change-booking-helpers.test.ts +853 -3
  55. 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
- }