Aller au contenu principal
Petanque Life

Staff & Event Linking (PL-T194)

F22.12 27 fonctionnalités

En bref

Staff scheduling for chain venues with role-aware shifts, certification tracking with expiry validation (alcohol_license, first_aid), per-location assignments, ShiftTemplates that expand into concrete shifts via role quotas and time offsets, and bidirectional linking between shifts and bookings — including booking-cancellation auto-unlink with audit trail, cross-midnight shift support, and a drag-drop staff calendar in admin with SSE-live updates.

Comment ça fonctionne

StaffMember is the per-tenant staff record — roles (guide, server, kitchen, bartender, manager, host), free-form skills (petanque_intro, dj, sommelier), certifications with expiry (alcohol_license, first_aid, food_hygiene), location assignments, hourly rate with currency, and active/inactive status. A duplicate-guard ensures one StaffMember per user per tenant. Shifts have start and end datetimes (cross-midnight supported), a conflict detector that 409s on overlap, certification validation (a bartender shift requires a valid alcohol_license), and location-access validation (you can't assign a staff member to a location they're not on).

The status flow runs scheduled → confirmed → in_progress → completed. Soft-delete on staff warns if active shifts exist. ShiftTemplate captures recurring patterns — role quotas ("a corporate event needs 2 guides + 1 host + 1 bartender") with time offsets ("start 30 min before booking, end 1 h after") and an applicable_event_types filter.

Apply-template expands the template into concrete shifts. Booking ↔ shift links are bidirectional: POST /chain/bookings/{id}/staff links a shift, GET lists, DELETE unlinks; applying a template to a booking auto-links every created shift. NEW: when a booking is cancelled, linked shifts are automatically unlinked with an audit-trail entry — operators don't have to chase orphan shifts.

The admin UI provides a staff calendar with drag-drop scheduling. SSE on a shift channel keeps the schedule live across managers' screens.

Capacités clés

  • StaffMember with roles, skills, certifications (with expiry), location assignments
  • Shift conflict detection + cross-midnight + certification validation
  • ShiftTemplate with role quotas + time offsets + event-type filter
  • Bidirectional booking ↔ shift links (link / unlink / list)
  • Apply-template to booking auto-links all created shifts
  • Booking cancellation auto-unlinks shifts with audit trail
  • Drag-drop staff calendar + soft-delete with active-shift warning

En pratique

A corporate client books out the venue for a Friday-night team event for 40 people. The operator clicks Apply Shift Template on the booking and picks the "Corporate event 30+" template — it requires 2 guides (start −30 min, end +60 min), 1 host (booking duration), 1 bartender (booking duration), and 1 kitchen runner (start −60 min, end +30 min). The system expands the template into five concrete shifts, validates each candidate against certifications and location access (the bartender slot rejects two candidates lacking alcohol_license), and writes the shifts linked to the booking.

The shift calendar updates live via SSE and each assigned staff member sees the new shift on their phone. Two weeks later the client cancels — the booking flips to CANCELLED and all five linked shifts are automatically unlinked with audit entries explaining why, freeing those staff slots for redeployment.

Fonctionnalités de ce sous-système

27
ID Status Fonctionnalités
F22.12.01 Livré StaffMember model (roles, skills, certifications, hourly rate)
F22.12.02 Livré Roles: guide, server, kitchen, bartender, manager, host
F22.12.03 Livré Free-form skills tagging (petanque_intro, dj, etc.)
F22.12.04 Livré Certifications with expiry (alcohol_license, first_aid)
F22.12.05 Livré Per-staff location assignments
F22.12.06 Livré Hourly rate + currency tracking
F22.12.07 Livré Active/inactive status
F22.12.08 Livré Duplicate-guard: one StaffMember per user per tenant
F22.12.09 Livré Shift model with start/end datetimes
F22.12.10 Livré Shift conflict detection (409 on overlap)
F22.12.11 Livré Cross-midnight shift support
F22.12.12 Livré Certification expiry validation (bartender → alcohol_license)
F22.12.13 Livré Location-access validation per shift
F22.12.14 Livré Shift status flow (scheduled → confirmed → in_progress → completed)
F22.12.15 Livré Soft-delete with active-shift warning on staff delete
F22.12.16 Livré Staff schedule view (GET /chain/staff/{id}/shifts)
F22.12.17 Livré SSE stream for real-time shift events
F22.12.18 Livré ShiftTemplate with role quotas + time offsets
F22.12.19 Livré Template apply → expand into concrete shifts
F22.12.20 Livré Applicable event-type filter on templates
F22.12.21 Livré Template active/inactive management
F22.12.22 Livré Link shift to booking (POST /chain/bookings/{id}/staff)
F22.12.23 Livré Unlink shift from booking
F22.12.24 Livré List booking staff (GET /chain/bookings/{id}/staff)
F22.12.25 Livré Apply template to booking (auto-link all created shifts)
F22.12.26 Livré Booking cancellation → unlink shifts with audit trail ✅ — BookingService.cancel calls unlink_shifts_for_booking() and records unlinked_shifts_count in booking audit (PL-T211)
F22.12.27 Livré Drag-drop on staff calendar (admin UI)