@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
@@ -1265,6 +1265,27 @@ export interface AdminAmendmentOperationSnapshot {
1265
1265
  metadata?: Record<string, string>;
1266
1266
  }
1267
1267
 
1268
+ export interface AdminAmendmentActiveAdjustmentSnapshot {
1269
+ adjustmentId: string;
1270
+ operationId: string;
1271
+ mode: 'FIXED_AMOUNT' | 'PERCENTAGE_DISCOUNT' | 'PERCENTAGE_SURCHARGE';
1272
+ scope:
1273
+ | 'POSITIVE_AMENDMENT_VALUE'
1274
+ | 'CURRENT_ACTIVE_TICKETS'
1275
+ | 'CURRENT_ACTIVE_BOOKING'
1276
+ | 'SELECTED_COMPONENTS';
1277
+ basisCents: number;
1278
+ percentageBasisPoints?: number | null;
1279
+ amountCents: number;
1280
+ taxDeltaCents: number;
1281
+ affectedComponentIds: string[];
1282
+ taxBehavior: 'NON_TAXABLE' | 'TAXABLE' | 'PRE_TAX_DISCOUNT' | 'POST_TAX_DISCOUNT';
1283
+ reasonCode: string;
1284
+ referenceCode?: string | null;
1285
+ reason?: string | null;
1286
+ createdAt: string;
1287
+ }
1288
+
1268
1289
  export interface ChangeBookingQuoteRequest {
1269
1290
  bookingReference: string;
1270
1291
  lastName: string;
@@ -1299,6 +1320,25 @@ export interface ChangeBookingQuoteRequest {
1299
1320
  } | null;
1300
1321
  /** Explicit admin treatment for server-classified removed paid value. Never defaulted by the client. */
1301
1322
  refundDispositionsByOperationId?: Record<string, AdminAmendmentRefundDisposition>;
1323
+ /** Server-resolved admin adjustments to append to the immutable amendment ledger. */
1324
+ structuredAdjustments?: Array<{
1325
+ adjustmentId: string;
1326
+ mode: 'FIXED_AMOUNT' | 'PERCENTAGE_DISCOUNT' | 'PERCENTAGE_SURCHARGE';
1327
+ fixedAmount?: number | null;
1328
+ percentageBasisPoints?: number | null;
1329
+ scope:
1330
+ | 'POSITIVE_AMENDMENT_VALUE'
1331
+ | 'CURRENT_ACTIVE_TICKETS'
1332
+ | 'CURRENT_ACTIVE_BOOKING'
1333
+ | 'SELECTED_COMPONENTS';
1334
+ selectedComponentIds?: string[];
1335
+ taxBehavior: 'NON_TAXABLE' | 'TAXABLE' | 'PRE_TAX_DISCOUNT' | 'POST_TAX_DISCOUNT';
1336
+ reasonCode: string;
1337
+ referenceCode?: string | null;
1338
+ reason?: string | null;
1339
+ }>;
1340
+ /** Existing immutable adjustment ids to reverse as part of this amendment. */
1341
+ reverseAdjustmentIds?: string[];
1302
1342
  }
1303
1343
 
1304
1344
  /** FE-authored receipt payload for admin quote path (major units, booking currency). */
@@ -1329,6 +1369,7 @@ export interface AdminChangeBookingQuoteV2Data {
1329
1369
  oldReceipt: {
1330
1370
  currency?: string | null;
1331
1371
  grossSubtotal?: number | null;
1372
+ paymentCreditTotal?: number | null;
1332
1373
  taxAmount?: number | null;
1333
1374
  payableTotal?: number | null;
1334
1375
  lines?: PricingV2QuoteLineSnapshot[] | null;
@@ -1348,6 +1389,7 @@ export interface AdminChangeBookingQuoteV2Data {
1348
1389
  returnPriceTreatmentOperations?: AdminAmendmentOperationSnapshot[];
1349
1390
  allowedRefundDispositionsByOperationId?: Record<string, AdminAmendmentRefundDisposition[]>;
1350
1391
  removedValueByOperationId?: Record<string, number>;
1392
+ reversibleAdjustments?: AdminAmendmentActiveAdjustmentSnapshot[];
1351
1393
  }
1352
1394
 
1353
1395
  export interface ChangeBookingQuoteReceipt {
@@ -1355,11 +1397,17 @@ export interface ChangeBookingQuoteReceipt {
1355
1397
  tax?: number;
1356
1398
  total: number;
1357
1399
  currency?: string;
1400
+ /** Non-cash value currently allocated to the booking, such as gift-card credit. */
1401
+ paymentCreditTotal?: number;
1358
1402
  lineItems?: Array<{
1359
1403
  label?: string;
1360
1404
  amount?: number;
1361
1405
  type?: string;
1362
1406
  quantity?: number;
1407
+ reference?: string | null;
1408
+ identity?: {
1409
+ componentId?: string | null;
1410
+ } | null;
1363
1411
  priceBasis?: PriceBasisSnapshot | null;
1364
1412
  }>;
1365
1413
  }
@@ -1453,6 +1501,7 @@ export interface ChangeBookingQuoteResponse {
1453
1501
  quote?: PricingV2QuoteSnapshot | null;
1454
1502
  paymentCreditTotal?: number;
1455
1503
  balanceDelta?: number;
1504
+ amountPreviouslyPaid?: number;
1456
1505
  amountToCharge?: number;
1457
1506
  refundCandidate?: number;
1458
1507
  /**
@@ -1496,6 +1545,8 @@ export interface ChangeBookingQuoteResponse {
1496
1545
  allowedRefundDispositionsByOperationId?: Record<string, AdminAmendmentRefundDisposition[]>;
1497
1546
  /** Original paid basis plus allocated refundable tax for each removal operation. */
1498
1547
  removedValueByOperationId?: Record<string, number>;
1548
+ /** Active immutable adjustments that an admin may edit (reverse + replace) or remove. */
1549
+ reversibleAdjustments?: AdminAmendmentActiveAdjustmentSnapshot[];
1499
1550
  /** When price check fails / disagrees: optional breakdown for UI line-vs-line comparison. */
1500
1551
  pricingDriftDetail?: ChangeBookingQuotePricingDriftDetail;
1501
1552
  /** Optional BE debug: receipt-floor vs catalog ticket math (same-parent Rule A/B). */
@@ -1690,6 +1741,7 @@ export function mapAdminChangeBookingQuoteV2Data(
1690
1741
  pricingQuote: newQuote,
1691
1742
  quote: newQuote,
1692
1743
  balanceDelta: data.balanceDelta ?? newQuote?.balanceDelta ?? undefined,
1744
+ amountPreviouslyPaid: newQuote?.amountPreviouslyPaid ?? undefined,
1693
1745
  amountToCharge: data.amountToCharge ?? newQuote?.amountToCharge ?? undefined,
1694
1746
  refundCandidate: data.refundCandidate ?? newQuote?.refundCandidate ?? undefined,
1695
1747
  priceDiff: data.balanceDelta ?? newQuote?.balanceDelta ?? 0,
@@ -1701,11 +1753,13 @@ export function mapAdminChangeBookingQuoteV2Data(
1701
1753
  allowedRefundDispositionsByOperationId:
1702
1754
  data.allowedRefundDispositionsByOperationId ?? {},
1703
1755
  removedValueByOperationId: data.removedValueByOperationId ?? {},
1756
+ reversibleAdjustments: data.reversibleAdjustments ?? [],
1704
1757
  originalReceipt: {
1705
1758
  subtotal: oldReceipt.grossSubtotal ?? undefined,
1706
1759
  tax: oldReceipt.taxAmount ?? undefined,
1707
1760
  total: oldReceipt.payableTotal ?? 0,
1708
1761
  currency: oldReceipt.currency ?? undefined,
1762
+ paymentCreditTotal: oldReceipt.paymentCreditTotal ?? 0,
1709
1763
  lineItems: oldReceipt.lines?.map((line) => ({
1710
1764
  label: line.label ?? undefined,
1711
1765
  amount: line.amount ?? undefined,
@@ -2249,6 +2303,16 @@ export interface PricingV2QuoteSnapshot {
2249
2303
  relatedChangeIntentId?: string | null;
2250
2304
  amendment?: {
2251
2305
  operations?: AdminAmendmentOperationSnapshot[] | null;
2306
+ updatedReceipt?: ChangeBookingQuoteReceipt | null;
2307
+ targetState?: {
2308
+ nonPriceState?: {
2309
+ /**
2310
+ * The amendment service stores the canonical itinerary as JSON in non-price state.
2311
+ * Accept an array as well so clients remain compatible if the API stops stringifying it.
2312
+ */
2313
+ itinerary?: string | ItineraryDisplayStep[] | null;
2314
+ } | null;
2315
+ } | null;
2252
2316
  } | null;
2253
2317
  metadata?: Record<string, string> | null;
2254
2318
  [key: string]: unknown;