Add group-class withdrawal deadline and kind-aware offering form
CI / Tests (PHP 8.1) (pull_request) Successful in 44s
CI / Tests (PHP 8.2) (pull_request) Successful in 59s
CI / No Debug Code (pull_request) Successful in 3s
CI / Coding Standards (pull_request) Successful in 2m53s
CI / PHPStan (pull_request) Successful in 2m55s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m41s
CI / Build Plugin Zip (pull_request) Skipped

Group classes now carry an optional per-class withdrawal deadline. Up to
that day a student may withdraw themselves from the class; the withdrawal
frees the seat and voids any pending payment but never issues an account
credit. After the deadline self-withdrawal closes and a studio admin must
withdraw the student by hand (the admin path is never subject to the
deadline). A blank deadline keeps self-withdrawal open indefinitely.

Also make the Add/Edit Offering form show only the fields relevant to the
selected kind: group settings for group classes, weekly reservation for
private lessons. Progressive enhancement — without JS every field renders.

- New nullable us_offerings.withdrawal_deadline column; Offering model gains
  $withdrawalDeadline + isWithdrawalOpen().
- New student endpoint POST /enrollments/{id}/withdraw, gated by the deadline
  (403 withdrawal_closed), ownership-checked, idempotent.
- Front-end group-class page shows a Withdraw button while open.
- No USC_VERSION bump: 1.2.0 is unreleased and accumulates schema changes
  under its section, matching the scheduled-billing and credit features.

Tests: composer test (596), composer lint, composer cs all pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-24 15:56:40 -03:00
co-authored by Claude Opus 4.8
parent f552c3952a
commit 2c4b481077
14 changed files with 347 additions and 21 deletions
+25
View File
@@ -331,4 +331,29 @@ class OfferingTest extends TestCase
self::assertSame('2026-08-31', $offering->toArray()['enrollment_deadline']);
}
public function testIsWithdrawalOpenOnAndBeforeTheDeadlineDay(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', termStart: '2026-09-08', withdrawalDeadline: '2026-08-31');
self::assertTrue($offering->isWithdrawalOpen('2026-08-30'));
self::assertTrue($offering->isWithdrawalOpen('2026-08-31'));
self::assertFalse($offering->isWithdrawalOpen('2026-09-01'));
}
public function testIsWithdrawalOpenAlwaysTrueWithoutADeadline(): void
{
// Unlike the enrolment deadline, a withdrawal deadline has no default:
// an unset deadline leaves self-withdrawal open indefinitely.
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', termStart: '2026-09-08');
self::assertTrue($offering->isWithdrawalOpen('2099-01-01'));
}
public function testToArrayIncludesWithdrawalDeadline(): void
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir', withdrawalDeadline: '2026-08-31', id: 10);
self::assertSame('2026-08-31', $offering->toArray()['withdrawal_deadline']);
}
}