@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.
Files changed (65) hide show
  1. package/package.json +1 -1
  2. package/src/components/booking/AdminChangeBookingContent.tsx +15 -1
  3. package/src/components/booking/AdminChangeBookingFlow.tsx +274 -94
  4. package/src/components/booking/AdminChangeCheckoutPanel.tsx +49 -13
  5. package/src/components/booking/AdminChangePricingPanel.tsx +400 -134
  6. package/src/components/booking/AdminChangePromoEditor.tsx +97 -0
  7. package/src/components/booking/AdminChangeReceiptComparison.tsx +172 -147
  8. package/src/components/booking/ChangeBookingFlow.tsx +6 -3
  9. package/src/components/booking/ChangeBookingQuoteStatusPlaceholder.tsx +7 -2
  10. package/src/components/booking/ChangeBookingSelectionControlsPanel.tsx +6 -0
  11. package/src/components/booking/ChangeBookingTicketsAndAddOnsPanel.tsx +80 -0
  12. package/src/components/booking/NewBookingFlow.tsx +14 -2
  13. package/src/components/booking/PickupLocationSelector.module.css +22 -0
  14. package/src/components/booking/PickupLocationSelector.tsx +3 -3
  15. package/src/components/booking/PriceBreakdown.tsx +66 -15
  16. package/src/components/booking/PriceSummary.tsx +16 -0
  17. package/src/components/booking/PrivateShuttleBookingFlow.tsx +52 -14
  18. package/src/components/booking/PrivateShuttleCheckoutSection.tsx +95 -54
  19. package/src/components/booking/admin-adjustment-components.ts +44 -0
  20. package/src/components/booking/admin-adjustment-tax-behavior.ts +50 -0
  21. package/src/components/booking/admin-change-flow-state-helpers.ts +10 -0
  22. package/src/components/booking/admin-change-provider-payload.ts +12 -1
  23. package/src/components/booking/admin-change-quote-request-key.ts +41 -1
  24. package/src/components/booking/admin-change-receipt-lines.ts +49 -0
  25. package/src/components/booking/admin-change-v2-quote-request.ts +109 -0
  26. package/src/components/booking/admin-refund-decision-context.ts +122 -0
  27. package/src/components/booking/admin-refund-disposition.ts +71 -2
  28. package/src/components/booking/availability-date-selection.ts +16 -0
  29. package/src/components/booking/booking-flow-types.ts +4 -0
  30. package/src/components/booking/booking-flow.css +5 -0
  31. package/src/components/booking/change-booking-error-message.ts +137 -0
  32. package/src/components/booking/change-booking-flow-helpers.ts +77 -2
  33. package/src/components/booking/change-booking-quote-guards.ts +4 -1
  34. package/src/components/booking/change-booking-quote-state.ts +44 -1
  35. package/src/components/booking/incompatible-add-on-selections.ts +19 -0
  36. package/src/components/booking/private-shuttle-availability.ts +14 -0
  37. package/src/components/booking/private-shuttle-cancellation-policy.ts +9 -0
  38. package/src/components/booking/private-shuttle-checkout-controller.ts +5 -0
  39. package/src/components/booking/private-shuttle-provider-change-runner.ts +21 -0
  40. package/src/components/booking/private-shuttle-reservation-runner.ts +5 -3
  41. package/src/components/booking/provider-dashboard-change-booking.ts +18 -2
  42. package/src/components/booking/use-standard-booking-availability.ts +5 -2
  43. package/src/components/booking/useAdminChangeCheckoutController.ts +56 -1
  44. package/src/components/booking/useAdminChangeProductReset.ts +6 -0
  45. package/src/components/booking/useAdminChangeProtectedPricing.ts +4 -0
  46. package/src/components/booking/useAdminChangeQuoteDisplayState.tsx +8 -6
  47. package/src/components/booking/useAdminChangeQuotePreview.ts +146 -61
  48. package/src/components/booking/useAdminCustomReceiptLines.ts +171 -10
  49. package/src/components/booking/useAdminProviderPricingAdjustments.ts +50 -19
  50. package/src/components/booking/useBookingAvailabilityAddOns.ts +26 -4
  51. package/src/components/booking/useBookingPromoAndQuantityController.ts +16 -2
  52. package/src/components/booking/useChangeBookingAddOnFloorController.ts +15 -9
  53. package/src/components/booking/useChangeBookingAutoSelections.ts +60 -17
  54. package/src/components/booking/useChangeBookingInitialHydration.ts +10 -7
  55. package/src/components/booking/useChangeBookingQuotePreview.ts +3 -1
  56. package/src/components/booking/useChangeBookingSelectionDetails.ts +23 -17
  57. package/src/components/booking/useStandardBookingAutoSelections.ts +55 -7
  58. package/src/lib/booking/booking-cutoffs.ts +22 -0
  59. package/src/lib/booking/change-booking-server-preview.ts +92 -5
  60. package/src/lib/booking/change-flow-pricing.ts +12 -0
  61. package/src/lib/booking/i18n/messages/en.json +1 -0
  62. package/src/lib/booking/i18n/messages/fr.json +1 -0
  63. package/src/lib/booking-api.ts +76 -1
  64. package/test/change-booking-helpers.test.ts +1319 -7
  65. 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,13 +64,18 @@ export interface AdminChangeCheckoutPanelProps {
58
64
  showProviderPricingInlineEditor: boolean;
59
65
  providerPricingUi?: ProviderDashboardChangePricingUi;
60
66
  providerQuotedLines: ProviderDashboardPricingLine[];
61
- debugPanel: ReactNode;
67
+ promoEditor?: ReactNode;
68
+ promoCode?: string | null;
62
69
  showChangeFlowManualPriceLines: boolean;
63
70
  showAdminCustomLineEditor: boolean;
64
71
  adminCustomReceiptLines: AdminCustomReceiptLine[];
65
- onAddAdminCustomReceiptLine: () => void;
72
+ hasPendingAdminCustomReceiptLineChanges: boolean;
73
+ pendingAdminCustomReceiptLineIds: string[];
74
+ adjustmentComponentOptions: AdminAdjustmentComponentOption[];
75
+ onAddAdminCustomReceiptLine: () => string;
66
76
  onUpdateAdminCustomReceiptLine: (id: string, patch: AdminCustomReceiptLinePatch) => void;
67
77
  onRemoveAdminCustomReceiptLine: (id: string) => void;
78
+ onApplyAdminCustomReceiptLines: () => void;
68
79
  firstName: string;
69
80
  lastName: string;
70
81
  email: string;
@@ -120,8 +131,13 @@ export function AdminChangeCheckoutPanel({
120
131
  originalReceipt,
121
132
  priceSummaryLinesIncludeTaxRow,
122
133
  serverAmendmentLines,
134
+ serverResultingReceiptLines,
123
135
  serverAmountDue,
124
136
  serverUpdatedTotal,
137
+ serverNetPaid,
138
+ serverCurrentPaymentCredit,
139
+ serverProjectedPaymentCredit,
140
+ serverRefundCandidate,
125
141
  serverQuoteError,
126
142
  refundDecisionOperations,
127
143
  returnPriceTreatmentOperations,
@@ -130,6 +146,8 @@ export function AdminChangeCheckoutPanel({
130
146
  refundDispositionsByOperationId,
131
147
  onRefundDispositionChange,
132
148
  refundQuoteLoading,
149
+ sourceProductName,
150
+ targetProductName,
133
151
  isTaxIncludedInPrice,
134
152
  taxRate,
135
153
  currency,
@@ -138,13 +156,18 @@ export function AdminChangeCheckoutPanel({
138
156
  showProviderPricingInlineEditor,
139
157
  providerPricingUi,
140
158
  providerQuotedLines,
141
- debugPanel,
159
+ promoEditor,
160
+ promoCode,
142
161
  showChangeFlowManualPriceLines,
143
162
  showAdminCustomLineEditor,
144
163
  adminCustomReceiptLines,
164
+ hasPendingAdminCustomReceiptLineChanges,
165
+ pendingAdminCustomReceiptLineIds,
166
+ adjustmentComponentOptions,
145
167
  onAddAdminCustomReceiptLine,
146
168
  onUpdateAdminCustomReceiptLine,
147
169
  onRemoveAdminCustomReceiptLine,
170
+ onApplyAdminCustomReceiptLines,
148
171
  firstName,
149
172
  lastName,
150
173
  email,
@@ -189,13 +212,14 @@ export function AdminChangeCheckoutPanel({
189
212
  onLineAmountReset,
190
213
  lineLabelInputs,
191
214
  }: AdminChangeCheckoutPanelProps) {
192
- const translatedTotalLabel = t('booking.totalOwedForBookingChange');
193
215
  const totalSummaryLabel =
194
- changeFlowAmountDue < -0.005
195
- ? 'Refund owed (vs original booking)'
196
- : translatedTotalLabel && translatedTotalLabel !== 'booking.totalOwedForBookingChange'
197
- ? translatedTotalLabel
198
- : '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';
199
223
  const pricingAdjustments = (
200
224
  <AdminChangePricingAdjustments
201
225
  showChangeFlowManualPriceLines={showChangeFlowManualPriceLines}
@@ -203,9 +227,13 @@ export function AdminChangeCheckoutPanel({
203
227
  providerPricingUi={providerPricingUi}
204
228
  showAdminCustomLineEditor={showAdminCustomLineEditor}
205
229
  adminCustomReceiptLines={adminCustomReceiptLines}
230
+ hasPendingAdminCustomReceiptLineChanges={hasPendingAdminCustomReceiptLineChanges}
231
+ pendingAdminCustomReceiptLineIds={pendingAdminCustomReceiptLineIds}
232
+ adjustmentComponentOptions={adjustmentComponentOptions}
206
233
  onAddAdminCustomReceiptLine={onAddAdminCustomReceiptLine}
207
234
  onUpdateAdminCustomReceiptLine={onUpdateAdminCustomReceiptLine}
208
235
  onRemoveAdminCustomReceiptLine={onRemoveAdminCustomReceiptLine}
236
+ onApplyAdminCustomReceiptLines={onApplyAdminCustomReceiptLines}
209
237
  />
210
238
  );
211
239
  const adminReceiptComparison =
@@ -213,8 +241,13 @@ export function AdminChangeCheckoutPanel({
213
241
  <AdminChangeReceiptComparison
214
242
  originalReceipt={originalReceipt}
215
243
  amendmentLines={serverAmendmentLines}
244
+ resultingReceiptLines={serverResultingReceiptLines}
216
245
  amountDue={serverAmountDue}
217
246
  updatedTotal={serverUpdatedTotal}
247
+ netPaid={serverNetPaid}
248
+ currentPaymentCredit={serverCurrentPaymentCredit}
249
+ projectedPaymentCredit={serverProjectedPaymentCredit}
250
+ refundCandidate={serverRefundCandidate}
218
251
  selectionChanged={hasEffectiveChangeSelection}
219
252
  quoteError={serverQuoteError}
220
253
  refundDecisionOperations={refundDecisionOperations}
@@ -224,11 +257,15 @@ export function AdminChangeCheckoutPanel({
224
257
  refundDispositionsByOperationId={refundDispositionsByOperationId}
225
258
  onRefundDispositionChange={onRefundDispositionChange}
226
259
  refundQuoteLoading={refundQuoteLoading}
260
+ sourceProductName={sourceProductName}
261
+ targetProductName={targetProductName}
227
262
  amountDueLabel={totalSummaryLabel}
228
263
  currency={currency}
229
264
  locale={locale}
230
265
  t={t}
231
266
  taxRate={taxRate}
267
+ promoEditor={promoEditor}
268
+ promoCode={promoCode}
232
269
  adjustments={pricingAdjustments}
233
270
  />
234
271
  ) : null;
@@ -254,7 +291,6 @@ export function AdminChangeCheckoutPanel({
254
291
  showProviderPricingInlineEditor={showProviderPricingInlineEditor}
255
292
  providerPricingUi={providerPricingUi}
256
293
  providerQuotedLines={providerQuotedLines}
257
- debugPanel={debugPanel}
258
294
  />
259
295
  }
260
296
  extraBeforeSubtotal={