Skip to content

Events: Cancellation + Waitlist promotion #242

@danielhe4rt

Description

@danielhe4rt

Parent

#237

What to build

Implement cancellation with deadline validation and automatic waitlist promotion (FIFO) when a confirmed participant cancels.

Action: CancelEnrollmentAction

  • Validates: enrollment status must be confirmed, waitlisted, or pending
  • Validates deadline: now() < event.starts_at - policy.cancellation_deadline_hours
  • Transitions enrollment to cancelled, sets cancelled_at timestamp
  • Records transition in audit trail (triggered_by=user, reason optional)
  • If the cancelled enrollment was confirmed AND there are waitlisted enrollments: trigger promotion

Action: PromoteFromWaitlistAction

  • Finds the oldest waitlisted enrollment (ordered by enrolled_at ASC, LIMIT 1)
  • Transitions it to confirmed, sets confirmed_at, clears waitlist_position
  • Records transition (triggered_by=system, reason="slot opened from cancellation")
  • Dispatches EnrollmentConfirmed domain event for the promoted enrollment
  • Recalculates waitlist_position for remaining waitlisted enrollments (optional optimization: just leave gaps)

App panel:

  • "Cancel" button visible on enrollment when:
    • Status is confirmed, waitlisted, or pending
    • Deadline has not passed
  • Shows "Cancellation deadline passed" message when deadline expired
  • Confirmation dialog before cancelling

Admin panel:

  • "Cancel Enrollment" action available on enrollment records (bypasses deadline — admin override)
  • Shows cancellation reason in transitions log

Edge cases:

  • Cancellation after deadline: rejected with 422 and message showing deadline
  • Cancellation of waitlisted: does NOT trigger promotion (no slot was freed)
  • Multiple cancellations in quick succession: each promotes the next in line

Acceptance criteria

  • Participant can cancel within deadline → status changes to cancelled
  • Cancellation after deadline is rejected with clear error message
  • Cancelling a confirmed enrollment promotes next waitlisted participant (FIFO)
  • Promoted participant gets confirmed status with proper transition record
  • EnrollmentConfirmed is dispatched for promoted enrollment
  • Cancelling a waitlisted enrollment does not trigger promotion
  • Admin can cancel any enrollment regardless of deadline
  • Transition audit trail records actor and reason for all cancellations
  • Feature tests: cancel within deadline, cancel after deadline, waitlist promotion, admin override
  • Pint passes

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions