# Overview.Admin

## What it does for you

Equestrian Clinics provides the public-facing foundation for riding clinic discovery, coach timetables, host requests, slot booking workflows, waitlists, horse eligibility checks, facility planning, and billing records. It is a specialist add-on for equestrian sites that already have an operational process around clinic scheduling and fulfilment.

## Your screens

- **Public clinic discovery**: riders can browse available tour days and clinic slots.
- **Signed coach timetable**: coaches can view a clinic schedule surface through its signed timetable URL.
- **Host request form**: riders or venues can submit interest in hosting a clinic.
- **Customer Portal**: linked portal accounts can see scoped rider and horse summaries plus upcoming held or confirmed bookings. Private medical, emergency-contact, care-note, and booking-note fields are not included.

## What you can do

- Expose public clinic discovery and signed coach timetable routes.
- Record public host requests.
- Use package Actions for slot generation, booking requests, payment confirmation, waitlist promotion, horse allocation, care worklists, facility reporting, and billing export state.
- Build a custom admin or operations workflow on top of the package models and Actions.

## Where to find it

This package currently ships frontend routes and backend Actions, not a Filament clinic-management area. Wire the public routes into the site experience and manage operational workflows through the consuming application until an admin UI is added.

## Setup and access boundaries

Install Address, Core, Customer Portal, Media Library, and Payments first, then run this package's migration. There are no package-owned admin permissions or policies. The Actions operate on the models supplied to them, so the consuming application must authenticate the actor and resolve the venue, tour day, slot, rider, horse, portal account, payment, and site inside the actor's allowed scope before calling an Action.

The built-in discovery controller is installation-wide: it does not pass a site ID to the discovery Action. On a multi-site installation, expose that shared catalogue only deliberately or provide a site-aware controller that calls `BuildClinicDiscoveryAction` with the current site ID. Public discovery includes venue address, postcode, facility notes, map URL, slot price, capacity, and waitlist counts, so do not put private access or contact instructions in those public fields.

## Booking and payment lifecycle

- New booking requests close `booking_lock_hours` before the tour day starts; the database default is 24 hours. This is a booking cutoff, not a checkout hold.
- An online Stripe or PayPal request creates a **Held** booking for `checkout_hold_minutes`, 10 minutes by default. Active holds reserve capacity even though public discovery's remaining-spots figure counts confirmed bookings only, so availability can differ briefly while another customer checks out.
- `BuildSlotBookingCheckoutSessionDataAction` only builds a handoff for the Payments package. `ConfirmSlotBookingPaymentAction` changes an active hold to **Confirmed/Paid**, but does not itself query a provider transaction. Call it only from a server-side, provider-verified payment completion path; never from a browser success URL alone.
- Cash creates an immediate **Confirmed/Cash approved** booking and is accepted only when the rider profile already has cash approval.
- Method-specific payment fees require the legal-acknowledgement flag while that guard is enabled. The universal booking fee comes from `CAPELL_EQUESTRIAN_BOOKING_FEE_PENCE`.
- Cancelling a held or confirmed booking releases confirmed capacity and records whether the cancellation occurred inside the refund window, 48 hours before the tour day by default. It does not issue a provider refund or change the payment status to **Refunded**; the consuming payment workflow must do that separately.

## Waitlists and eligibility

Waitlisting is allowed only when confirmed bookings plus active holds fill the slot. Promotion is a separate, oldest-first Action; cancellation and hold expiry do not automatically contact or promote the next rider. An offered entry has a private claim window of 120 minutes by default. Claiming it creates the normal online hold or approved-cash booking, and an expired offer is only marked expired.

The built-in eligibility Action checks the slot's skill tier against the rider and, when supplied, the horse's suitable tiers. It does not enforce active-profile state, age, vaccination, waiver, medical review, horse availability, or payment entitlement. Add those gates in the consuming workflow where the business requires them. Horse allocation separately enforces the configured daily workload-minute limit.

## Scheduling and recovery

Keep the scheduler running. Every five minutes, single-server, non-overlapping commands mark expired online holds as **Expired/Failed** and expired waitlist offers as **Expired**. Capacity checks and checkout handoff use the actual expiry timestamp, but without the scheduler stale statuses remain visible in operational records.

## Good to know

- There are no package-owned Filament resources or admin pages yet.
- Clinic discovery shows public, published tour days starting today or later and supports venue, postcode, and coordinate-based distance filtering. Draft, full, cancelled, completed, or non-public tour days are excluded.
- The coach timetable route is signed, private/no-store, and marked noindex. Treat its URL as bearer access and do not publish it as a normal public navigation link.
- The host-request endpoint accepts at most five requests per minute for the same email-and-IP key. It stores the request as **new** but does not notify staff or provide an admin queue; the consuming application must add the review workflow.
- Host requests, rider contact and medical details, guardian/emergency contacts, waiver snapshots, horse health notes, communication recipients, and operational notes are stored in package tables without field-level encryption. Apply least-privilege access, retention, backup, and deletion controls in the consuming application.
- Keep public discovery output restricted to its supplied view data; it intentionally excludes rider, horse, booking, medical, payment, and internal notes.
- Diagnostics checks the clinic model/action surface, routes, scheduled expiry commands, and operational storage assumptions.
- Public Blade must stay free of private rider, horse, medical, payment, and admin metadata.
- Enable this only on sites that actually run equestrian clinics and have staff ready to handle the operational workflow.