PhoenixKitBookings.Schemas.Booking (PhoenixKitBookings v0.1.1)

Copy Markdown View Source

A reservation of one seat of a service.

Exactly one time shape per row (DB CHECK bookings_time_shape, mirrors the phoenix_kit_calendar V141 convention):

  • Timed (minutes services): starts_at/ends_at UTC pair, exclusive end.
  • Dated (day/night services): starts_on/ends_on DATE pair, exclusive end — a Fri→Sun hotel stay is starts_on: Fri, ends_on: Sun (2 nights). Check-in/out clock times are service attributes, never range data.

The time fields, service_uuid, user_uuid, status and source are never cast from attrs — PhoenixKitBookings.Bookings computes and put_changes them after the engine validates the request. The changeset casts only what a customer types.

Lifecycle: pending (approval-required services) → confirmedcancelled. Cancelled rows keep their time fields but stop counting toward capacity.

Summary

Functions

True when the booking still occupies capacity.

Casts only customer-supplied fields.

Stamps the validated time range, ownership and lifecycle onto a customer changeset. range is {starts_at, ends_at} (DateTime) or {:dates, starts_on, ends_on} (Date).

Controlled status transition — never cast from attrs.

Types

t()

@type t() :: %PhoenixKitBookings.Schemas.Booking{
  __meta__: term(),
  cancel_reason: term(),
  cancelled_at: term(),
  currency: term(),
  customer_email: term(),
  customer_name: term(),
  customer_phone: term(),
  ends_at: term(),
  ends_on: term(),
  inserted_at: term(),
  metadata: term(),
  notes: term(),
  service_uuid: term(),
  source: term(),
  starts_at: term(),
  starts_on: term(),
  status: term(),
  total_price: term(),
  unit_uuid: term(),
  updated_at: term(),
  user_uuid: term(),
  uuid: term()
}

Functions

active?(booking)

True when the booking still occupies capacity.

customer_changeset(booking, attrs)

Casts only customer-supplied fields.

sources()

stamp_changeset(changeset, service_uuid, range, opts)

Stamps the validated time range, ownership and lifecycle onto a customer changeset. range is {starts_at, ends_at} (DateTime) or {:dates, starts_on, ends_on} (Date).

status_changeset(booking, status, opts \\ [])

Controlled status transition — never cast from attrs.

statuses()