Skip to content

Booking extra

Purpose

TBD by human

Identity & key fields

  • Primary key: id (uuid, default gen_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, equals price for 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

  • bookingId ON DELETE CASCADE — deleting a booking removes its extras (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/bookings.schema.ts).
  • extraId ON 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).
  • coveredByEntitlementId ON 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).
  • quantity defaults to 1; pricePaid defaults to '0'; both price and pricePaid are 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) — bookingIdbookings.bookings.id, on-delete cascade. N:1.
  • Activity extra (ENT-006) — extraIdactivities.activity_extras.id, on-delete restrict. N:1.
  • Customer entitlement (ENT-027) — coveredByEntitlementIdpasses.customer_entitlement.id, on-delete set null. N:1, optional.

API surfaces

SurfaceExposedNotes
clientyes — BookingExtraResponseDto, BookingExtraItemDto, CoveredExtraClientDto schemas referenced from booking client endpointsSwagger UI
businessnoSwagger UI
super-adminno

Known gotchas / open questions

  • pricePaid is 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.