Skip to content

Seat Approval

This page specifies subscription Seat approval and the separate Trip-seat approval rules used by Slice 4.

1. Definitions

Term Meaning
Subscription Seat An approved Passenger Membership (memberships.role=passenger, status=active). Counts against the Tier max_users; Managers and Drivers are free.
Trip seat One approved Booking on a specific Trip. Counts against trips.seat_capacity; pending/rejected/cancelled Bookings do not occupy a Trip seat.
Membership A user's link to one Company, with role and status (pending, active, rejected, suspended). Enrollment APIs expose active as approved.
Tier Subscription plan with min_users and max_users; max_users: null is unlimited. Billing is invoice-only.

The two seat concepts are related but distinct: an approved Passenger Membership makes a Passenger eligible to book, while an approved Booking occupies capacity on one Trip. There is no separate Trip-seat table; occupancy is derived from Bookings.

2. Enrollment approval invariants

  • A subscription Seat exists only for an active Passenger Membership.
  • Approving a Passenger Membership beyond the Tier max_users returns 422 with errors.seats and an upgrade message.
  • A suspended Company is blocked on every surface.
  • One Company per User.
  • Gender is required at enrollment (male or female) and stored on users.gender.
  • Passengers pay nothing; neither approval flow creates a payment path.

The existing enrollment endpoints remain:

Method Path Purpose
POST /api/auth/enroll-company Create a pending Passenger/Driver Membership.
GET /api/company/enrollments Manager enrollment queue.
POST /api/company/enrollments/{id}/approve Activate a pending Membership; enforce Tier limit for Passengers.
POST /api/company/enrollments/{id}/reject Reject a pending Membership.

3. Passenger booking eligibility

  • A Passenger may list available Trips and request/manage a Booking only with an active Passenger Membership in a non-suspended Company.
  • Pending, rejected, suspended, Driver, and Manager Memberships cannot use Passenger booking routes; an authenticated wrong-role request returns 403. A User without a Membership cannot resolve a Company and receives 404 from the company middleware.
  • Request creation and Manager approval both re-check Membership role/status and Company ownership. A Passenger whose Membership is no longer active cannot hold an approved Trip seat.
  • Manager approval of a Booking is Manager-only. A Driver or Passenger calling a Company approval route receives 403; a cross-company Booking/Trip returns 404.

4. Booking lifecycle and capacity

Booking status is exactly pending | approved | rejected | cancelled.

Current status Action Result
pending Manager approves approved; occupies one Trip seat if capacity and eligibility checks pass.
pending Manager rejects rejected; optional reason is stored as rejection_reason.
pending Passenger cancels cancelled.
approved Passenger cancels cancelled; releases the Trip seat.
pending Trip starts rejected by the system.
pending\|approved Trip is cancelled cancelled.
approved\|rejected\|cancelled Any approve/reject action 422 errors.status; terminal states do not transition.

A Passenger may have at most one active Booking (pending or approved) per Trip. Re-requesting after rejection/cancellation is allowed.

Approval performs these checks in one transaction while locking the Trip row:

  1. Booking belongs to the authenticated Company and Trip.
  2. Booking is pending; Trip is scheduled.
  3. Reservation deadline has not passed, when configured.
  4. Passenger still has an active Passenger Membership in the Company.
  5. Approved Passenger Membership count is within the Tier limit.
  6. Approved Booking count is below Trip seat_capacity.

Trip capacity failure returns 422 with errors.seats. Tier-integrity failure also returns 422 errors.seats. A concurrent approval cannot overbook because approvals serialize on the Trip row.

5. Tier limit interaction with Bookings

Booking does not create or approve a Membership and therefore consumes no additional subscription Seat. An active Passenger may book when the Company is exactly at max_users; that Passenger is already counted. Request/approval fails with 422 errors.seats only if stored active Passenger Membership count is greater than a finite max_users (an integrity violation), or if Membership approval itself would exceed the limit.

This preserves both constraints without preventing all existing Passengers from booking merely because their Company has filled its subscription plan.

6. Manager booking endpoints

Method Path Purpose
GET /api/company/trips/{id}/bookings Paginated Trip Bookings. Filters: status=pending\|approved\|rejected\|cancelled\|all, page, per_page.
POST /api/company/trips/{id}/bookings/{booking_id}/approve Approve a pending Booking.
POST /api/company/trips/{id}/bookings/{booking_id}/reject Reject a pending Booking; optional {reason} max 1000.

BookingResource contains id, company_id, trip_id, a Trip summary, Passenger {id,name}, status, rejection_reason, requested_at, decided_at, cancelled_at, boarded_at. It contains no charge, wallet, price, or payment fields.

7. Open questions (future slices)

  • Subscription Seat release audit: Exact audit/notification behavior when a Membership is rejected, suspended, or removed.
  • Bulk approval atomicity: Partial-failure behavior for bulk enrollment or booking approval.
  • Boarding privacy: Manifest/QR privacy rules belong to Live Ops.