Booking — Discount rule
A discount rule is an automatic price reduction applied during booking pricing: sibling, early bird, by attendee count, by profile… It is a price rule, distinct from the combine booking rule (which is about edit scope only).
Root entity: Tux/src/Tux.Data/Models/Discount.cs. Enums: Tux/src/Tux.Core/Enums/DiscountType.cs.
Discount classification (DiscountType)
| Type | Code | Meaning |
|---|---|---|
FamilyDiscount | 1 | Family (sibling) discount. |
Booking | 2 | Booking discount (early bird). |
Profile | 3 | Account/attendee profile discount. |
Manual | 9 | Manual discount. |
Apply conditions (DiscountCondition)
| Condition | Code | When eligible |
|---|---|---|
SiblingDiscountBySession | 1 | Enough siblings by session; applies to all attendees in a billing. |
SiblingDiscountByTermProgramSet | 2 | Enough siblings by TermProgramSet. |
AttendeeDiscountBySession | 6 | Applies to attendees in a range (e.g. 2nd, 3rd…) by session. |
AttendeeDiscountByTermProgramSet | 7 | As above, by TermProgramSet. |
EarlyBird | 3 | Booked before a course time threshold. |
ProfileDiscount | 5 | Account/attendee present in ProfileDiscount. |
ManualDiscount | 99 | Applied manually. |
MinValue/MaxValue are count thresholds (sibling/attendee). ValidFrom/ValidTo bound validity.
Value type (DiscountValueType)
| Type | Code | Computation |
|---|---|---|
Percentage | 1 | Total × (1 − DiscountRate). |
FixedAmountPerSession | 2 | Total − DiscountAmount × session count (floored at 0). |
DiscountValueCap caps the maximum discount (when set).
Discount stacking rule (DiscountRuleType)
Configured on ProgramCategory:
| Rule | Code | Behaviour |
|---|---|---|
Highest | 0 | Keep only the single highest discount. |
HighestEachType | 1 | Keep the highest per type (up to 3 — matches the 3 line slots). |
Each TermBookingOrderLine/TermBookingLine has up to 3 slots: DiscountId, Discount2Id, Discount3Id.
Where it is evaluated & applied
| Step | Code |
|---|---|
| Eligibility (preview, state-isolated) | Tux/src/Services/Tux.Service/Calculation/DiscountEligibilityService.cs |
| In-memory eligibility helpers (shared) | .../Calculation/DiscountEligibilityHelpers.cs |
| Auto-apply discounts to the order | BookingHelper.ApplyDiscount (.../Helpers/BookingHelper.cs) |
| Discount management API | Tux/src/Tux.Api/Controllers/DiscountController.cs |
Flow: load discounts available for the TermProgramSet (TermProgramSetDiscount) → filter eligible lines → group by TermProgramSet → apply per rule (Highest / HighestEachType) → write discount slots on the line.
Related tables
| Table | Role |
|---|---|
Discount | Rule definition. |
TermProgramSetDiscount | Which discount applies to which course. |
TermBookingOrderDiscount / TermBookingDiscount | Discounts applied to order / booking. |
ProfileDiscount | Discount config by account/attendee. |
EnrollmentDiscount | Discount for subscription enrollment (separate path). |
DiscountApplication / DiscountApplicationAllocation | Records & allocates discount to lines (billing audit). |
Source type (
DiscountSourceType):Calculated(0),Admin_Applied(1),Customer_Applied(2).
Next: Combine booking rule.