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.
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). - Edited booking: confirm builds a shared
BookingConfirmationPlanfromTermBookingOrderIdsbefore applying real side effects (invariantINV-BOOK-23).
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.