@ticketboothapp/booking 1.2.167 → 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.
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 +163 -145
  7. package/src/components/booking/ChangeBookingFlow.tsx +6 -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
@@ -15,6 +15,7 @@ import type {
15
15
  } from './booking-flow-ui';
16
16
  import { AdminChangeReceiptComparison } from './AdminChangeReceiptComparison';
17
17
  import type { AdminReleaseRefundDisposition } from './admin-refund-disposition';
18
+ import type { AdminAdjustmentComponentOption } from './admin-adjustment-components';
18
19
  import {
19
20
  AdminChangePricingAdjustments,
20
21
  AdminChangePricingMessages,
@@ -23,9 +24,7 @@ import {
23
24
 
24
25
  type TranslationFn = (key: string, params?: Record<string, string>) => string;
25
26
 
26
- type AdminCustomReceiptLinePatch = Partial<
27
- Pick<AdminCustomReceiptLine, 'label' | 'amountInput' | 'amountSign'>
28
- >;
27
+ type AdminCustomReceiptLinePatch = Partial<Omit<AdminCustomReceiptLine, 'id'>>;
29
28
 
30
29
  export interface AdminChangeCheckoutPanelProps {
31
30
  priceSummaryLines: PriceSummaryLine[];
@@ -37,8 +36,13 @@ export interface AdminChangeCheckoutPanelProps {
37
36
  originalReceipt: ChangeBookingFlowProps['originalReceipt'];
38
37
  priceSummaryLinesIncludeTaxRow: boolean;
39
38
  serverAmendmentLines: PriceSummaryLine[] | null;
39
+ serverResultingReceiptLines?: PriceSummaryLine[] | null;
40
40
  serverAmountDue: number | null;
41
41
  serverUpdatedTotal: number | null;
42
+ serverNetPaid?: number | null;
43
+ serverCurrentPaymentCredit?: number;
44
+ serverProjectedPaymentCredit?: number;
45
+ serverRefundCandidate?: number;
42
46
  serverQuoteError?: string | null;
43
47
  refundDecisionOperations?: AdminAmendmentOperationSnapshot[];
44
48
  returnPriceTreatmentOperations?: AdminAmendmentOperationSnapshot[];
@@ -50,6 +54,8 @@ export interface AdminChangeCheckoutPanelProps {
50
54
  disposition: AdminReleaseRefundDisposition | null,
51
55
  ) => void;
52
56
  refundQuoteLoading?: boolean;
57
+ sourceProductName?: string | null;
58
+ targetProductName?: string | null;
53
59
  isTaxIncludedInPrice: boolean;
54
60
  taxRate?: number;
55
61
  currency: Currency;
@@ -58,15 +64,18 @@ export interface AdminChangeCheckoutPanelProps {
58
64
  showProviderPricingInlineEditor: boolean;
59
65
  providerPricingUi?: ProviderDashboardChangePricingUi;
60
66
  providerQuotedLines: ProviderDashboardPricingLine[];
61
- debugPanel: ReactNode;
62
67
  promoEditor?: ReactNode;
63
68
  promoCode?: string | null;
64
69
  showChangeFlowManualPriceLines: boolean;
65
70
  showAdminCustomLineEditor: boolean;
66
71
  adminCustomReceiptLines: AdminCustomReceiptLine[];
67
- onAddAdminCustomReceiptLine: () => void;
72
+ hasPendingAdminCustomReceiptLineChanges: boolean;
73
+ pendingAdminCustomReceiptLineIds: string[];
74
+ adjustmentComponentOptions: AdminAdjustmentComponentOption[];
75
+ onAddAdminCustomReceiptLine: () => string;
68
76
  onUpdateAdminCustomReceiptLine: (id: string, patch: AdminCustomReceiptLinePatch) => void;
69
77
  onRemoveAdminCustomReceiptLine: (id: string) => void;
78
+ onApplyAdminCustomReceiptLines: () => void;
70
79
  firstName: string;
71
80
  lastName: string;
72
81
  email: string;
@@ -122,8 +131,13 @@ export function AdminChangeCheckoutPanel({
122
131
  originalReceipt,
123
132
  priceSummaryLinesIncludeTaxRow,
124
133
  serverAmendmentLines,
134
+ serverResultingReceiptLines,
125
135
  serverAmountDue,
126
136
  serverUpdatedTotal,
137
+ serverNetPaid,
138
+ serverCurrentPaymentCredit,
139
+ serverProjectedPaymentCredit,
140
+ serverRefundCandidate,
127
141
  serverQuoteError,
128
142
  refundDecisionOperations,
129
143
  returnPriceTreatmentOperations,
@@ -132,6 +146,8 @@ export function AdminChangeCheckoutPanel({
132
146
  refundDispositionsByOperationId,
133
147
  onRefundDispositionChange,
134
148
  refundQuoteLoading,
149
+ sourceProductName,
150
+ targetProductName,
135
151
  isTaxIncludedInPrice,
136
152
  taxRate,
137
153
  currency,
@@ -140,15 +156,18 @@ export function AdminChangeCheckoutPanel({
140
156
  showProviderPricingInlineEditor,
141
157
  providerPricingUi,
142
158
  providerQuotedLines,
143
- debugPanel,
144
159
  promoEditor,
145
160
  promoCode,
146
161
  showChangeFlowManualPriceLines,
147
162
  showAdminCustomLineEditor,
148
163
  adminCustomReceiptLines,
164
+ hasPendingAdminCustomReceiptLineChanges,
165
+ pendingAdminCustomReceiptLineIds,
166
+ adjustmentComponentOptions,
149
167
  onAddAdminCustomReceiptLine,
150
168
  onUpdateAdminCustomReceiptLine,
151
169
  onRemoveAdminCustomReceiptLine,
170
+ onApplyAdminCustomReceiptLines,
152
171
  firstName,
153
172
  lastName,
154
173
  email,
@@ -193,13 +212,14 @@ export function AdminChangeCheckoutPanel({
193
212
  onLineAmountReset,
194
213
  lineLabelInputs,
195
214
  }: AdminChangeCheckoutPanelProps) {
196
- const translatedTotalLabel = t('booking.totalOwedForBookingChange');
197
215
  const totalSummaryLabel =
198
- changeFlowAmountDue < -0.005
199
- ? 'Refund owed (vs original booking)'
200
- : translatedTotalLabel && translatedTotalLabel !== 'booking.totalOwedForBookingChange'
201
- ? translatedTotalLabel
202
- : 'Total owed for booking difference';
216
+ (serverRefundCandidate ?? 0) > 0.005
217
+ ? 'Amount to refund customer'
218
+ : changeFlowAmountDue < -0.005
219
+ ? 'Balance reduction'
220
+ : changeFlowAmountDue > 0.005
221
+ ? 'Amount due from customer'
222
+ : 'No payment or refund due';
203
223
  const pricingAdjustments = (
204
224
  <AdminChangePricingAdjustments
205
225
  showChangeFlowManualPriceLines={showChangeFlowManualPriceLines}
@@ -207,9 +227,13 @@ export function AdminChangeCheckoutPanel({
207
227
  providerPricingUi={providerPricingUi}
208
228
  showAdminCustomLineEditor={showAdminCustomLineEditor}
209
229
  adminCustomReceiptLines={adminCustomReceiptLines}
230
+ hasPendingAdminCustomReceiptLineChanges={hasPendingAdminCustomReceiptLineChanges}
231
+ pendingAdminCustomReceiptLineIds={pendingAdminCustomReceiptLineIds}
232
+ adjustmentComponentOptions={adjustmentComponentOptions}
210
233
  onAddAdminCustomReceiptLine={onAddAdminCustomReceiptLine}
211
234
  onUpdateAdminCustomReceiptLine={onUpdateAdminCustomReceiptLine}
212
235
  onRemoveAdminCustomReceiptLine={onRemoveAdminCustomReceiptLine}
236
+ onApplyAdminCustomReceiptLines={onApplyAdminCustomReceiptLines}
213
237
  />
214
238
  );
215
239
  const adminReceiptComparison =
@@ -217,8 +241,13 @@ export function AdminChangeCheckoutPanel({
217
241
  <AdminChangeReceiptComparison
218
242
  originalReceipt={originalReceipt}
219
243
  amendmentLines={serverAmendmentLines}
244
+ resultingReceiptLines={serverResultingReceiptLines}
220
245
  amountDue={serverAmountDue}
221
246
  updatedTotal={serverUpdatedTotal}
247
+ netPaid={serverNetPaid}
248
+ currentPaymentCredit={serverCurrentPaymentCredit}
249
+ projectedPaymentCredit={serverProjectedPaymentCredit}
250
+ refundCandidate={serverRefundCandidate}
222
251
  selectionChanged={hasEffectiveChangeSelection}
223
252
  quoteError={serverQuoteError}
224
253
  refundDecisionOperations={refundDecisionOperations}
@@ -228,6 +257,8 @@ export function AdminChangeCheckoutPanel({
228
257
  refundDispositionsByOperationId={refundDispositionsByOperationId}
229
258
  onRefundDispositionChange={onRefundDispositionChange}
230
259
  refundQuoteLoading={refundQuoteLoading}
260
+ sourceProductName={sourceProductName}
261
+ targetProductName={targetProductName}
231
262
  amountDueLabel={totalSummaryLabel}
232
263
  currency={currency}
233
264
  locale={locale}
@@ -260,7 +291,6 @@ export function AdminChangeCheckoutPanel({
260
291
  showProviderPricingInlineEditor={showProviderPricingInlineEditor}
261
292
  providerPricingUi={providerPricingUi}
262
293
  providerQuotedLines={providerQuotedLines}
263
- debugPanel={debugPanel}
264
294
  />
265
295
  }
266
296
  extraBeforeSubtotal={