Booking extra
Purpose
TBD by human
Identity & key fields
- Primary key:
id(uuid, defaultgen_random_uuid()). bookingId(uuid, FK →bookings.bookings.id, on-delete cascade).extraId(uuid, FK →activities.activity_extras.id, on-delete restrict) — the catalog row this snapshot references.name,price,quantity(defaults to 1) — catalog snapshot at booking time.pricePaid(decimal 10,2, default'0') — per-unit amount actually billed;'0.00'for covered units, equalspricefor not-covered units (see ADR D6 comment in schema).coveredByEntitlementId(nullable uuid, FK →passes.customer_entitlement.id, on-delete set null) — the customer entitlement that absorbed this extra (null for not-covered rows).
business meaning: TBD by human
Invariants
bookingIdON DELETE CASCADE — deleting a booking removes its extras (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/bookings.schema.ts).extraIdON DELETE RESTRICT — a catalog extra cannot be deleted while booking snapshots reference it (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/bookings.schema.ts).coveredByEntitlementIdON DELETE SET NULL — defensive: keeps the snapshot intact if the entitlement disappears (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/bookings.schema.ts).quantitydefaults to 1;pricePaiddefaults to'0'; bothpriceandpricePaidare NOT NULL (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/bookings.schema.ts).
business invariants: TBD by human
Lifecycle
No explicit state machine — rows are written at booking time and read for reporting.
Relationships
- Booking (ENT-003) —
bookingId→bookings.bookings.id, on-delete cascade. N:1. - Activity extra (ENT-006) —
extraId→activities.activity_extras.id, on-delete restrict. N:1. - Customer entitlement (ENT-027) —
coveredByEntitlementId→passes.customer_entitlement.id, on-delete set null. N:1, optional.
API surfaces
| Surface | Exposed | Notes |
|---|---|---|
| client | yes — BookingExtraResponseDto, BookingExtraItemDto, CoveredExtraClientDto schemas referenced from booking client endpoints | Swagger UI |
| business | no | Swagger UI |
| super-admin | no | — |
Known gotchas / open questions
pricePaidis denormalized to answer “total revenue from extras” without re-deriving coverage at read time (see schema comment referencing ADR D6).- OPEN: is the row idempotent on retry of booking creation? The unique-key surface in the schema is only
id.