PhoenixKitBookings.Schemas.AvailabilityRule (PhoenixKitBookings v0.1.1)

Copy Markdown View Source

One availability rule of a service. Maps 1:1 onto PhoenixLiveCalendar.Availability:

  • Weekly ruledays_of_week set (ISO 1=Mon..7=Sun), date nil.
  • Date overridedate set; overrides every weekly rule on that date (the lib's precedence rule).
  • available: false turns either shape into a block-out (a closed weekday or a blackout date).

For minute-unit services start_time/end_time bound the bookable window (both required). For day/night services the rule is date-granular and times stay nil — a weekly rule marks open days (arrival days), a date override closes or opens a specific date.

Summary

Functions

service_uuid is never cast from attrs — the context passes it explicitly (ownership pattern, mirrors phoenix_kit_calendar).

Types

t()

@type t() :: %PhoenixKitBookings.Schemas.AvailabilityRule{
  __meta__: term(),
  available: term(),
  date: term(),
  days_of_week: term(),
  end_time: term(),
  inserted_at: term(),
  service_uuid: term(),
  start_time: term(),
  updated_at: term(),
  uuid: term()
}

Functions

changeset(rule, attrs, time_unit)

service_uuid is never cast from attrs — the context passes it explicitly (ownership pattern, mirrors phoenix_kit_calendar).

time_unit is the owning service's unit, so the changeset can require times for minute services and forbid them for day/night services.