Booking — Codebase flow
This page traces API → service → validation for normal booking. Key files:
- Controller:
Tux/src/Tux.Api/Controllers/Consumer/ConsumerBookingController.cs - Service:
Tux/src/Services/Tux.Service/BookingService.cs - Helper:
Tux/src/Services/Tux.Service/Helpers/BookingHelper.cs
Overall
Flow 1 — Create order (cart)
- API:
CreateBookingOrder. - Creates
TermBookingOrder+TermBookingOrderLine(statusCreated). - Validates: valid attendee/term product, org settings, measurement (height/weight) if enabled, double-booking (unless
IgnoreDoubleBooking). - Does not create Billing yet.
Flow 2 — Submit
- API:
SubmitBookingOrders→BookingService.SubmitBookingAsync. - Accepts only order types
BookingandTrialSession. - Creates
Billing(financial summary); validates Pay Later eligibility (viaBookingHelper). - May arm an auto-cancel timeout if the payment option requires one (PayNow/Deposit/Direct Debit).
- Final double-booking check. Status →
Submitted. Does not create the Invoice yet. - Returns the complete set of
TermBookingOrderIdsfor the later confirm (full or attendance), so the UI does not have to guess.
Flow 3 — Confirm / Quote
- API:
ConfirmBookingOrders→BookingService.ConfirmBookingAsync(orGenerateQuotesAsync/AcceptQuoteAsync). - Creates
TermBookingfromTermBookingOrder; copies Line/Extra/Discount. - Applies discounts, computes totals (see Discount rule).
- Creates
TermAttendanceper session; triggers billing to generate invoices. - Status →
Approved(orAttendance_Approved, orQuote). - Action type
Confirm_Attendance(1050) → confirms attendance only, statusAttendance_Approved, no full confirm; used for adminSubmit & Confirm Attendance, does not open Billing Difference. - Edited booking: confirm builds a shared
BookingConfirmationPlanfromTermBookingOrderIdsbefore applying real side effects (invariantINV-BOOK-23).BookingConfirmationPlanis the projection source of truth from order → booking (header/line/extra/discount); preview code does not duplicate this projection algorithm.- Edit confirm recreates lines and replaces
TermAttendancebecause price/discount changed → keeps the old roll call (status, times, sign-in/out,RollCallHistory) when the old attendance hasRollCallStatusId > 0(invariantINV-BOOK-27); a retry does not duplicate history.
Flow 4 — Cancel
- API:
DeleteBookingOrdersAsync→BookingService.CancelBookingAsync. - Status →
Canceled; reverses invoices via credit note; deactivatesTermAttendance(even if some lines previously leftApproved).
Main validation
| Type | Where |
|---|---|
| Capacity | TermProduct.Capacity, TermProgramSetCapacity; checked at create/submit/confirm. |
| Double-booking | Attendee × session overlap on date/time; bypass via IgnoreDoubleBooking. |
| Measurement | Height/weight vs course config; admin overrides each rule. |
| Lock & pending | Locked booking / conflicting pending order → edit blocked. |
| Discount eligibility | DiscountEligibilityService + BookingHelper.ApplyDiscount. |
Next: Discount rule.