Add cancellation cutoff limiting how close to a lesson a student can cancel
CI / Tests (PHP 8.1) (pull_request) Successful in 41s
CI / Tests (PHP 8.2) (pull_request) Successful in 53s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 2m54s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 41s
CI / Tests (PHP 8.2) (pull_request) Successful in 53s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 2m54s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / Build Plugin Zip (pull_request) Skipped
Students can no longer cancel their own lesson online once it starts within a configured window; instructors and studio admins can always cancel. - Studio default `us_cancellation_cutoff_hours` (stored/computed in hours, entered and displayed in days under Studio Settings → Cancellations). - Optional per-offering override `cancellation_cutoff_hours` (entered in hours); blank inherits the studio default, 0 allows anytime cancellation. - `Booking\CancellationPolicy` resolves the effective window and decides; `BookingEndpoint::cancel()` returns a 403 `cancellation_closed` when too late. The instructor status endpoint and studio-admin student actions bypass it. Closes #93 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -84,6 +84,7 @@ class OfferingTest extends TestCase
|
||||
'term_end' => '2027-06-30',
|
||||
'schedule_note' => 'Tuesdays 4:00pm',
|
||||
'etransfer_email' => null,
|
||||
'cancellation_cutoff_hours' => '48',
|
||||
'is_active' => '1',
|
||||
];
|
||||
|
||||
@@ -95,9 +96,37 @@ class OfferingTest extends TestCase
|
||||
self::assertSame(120.00, $offering->price);
|
||||
self::assertSame(20, $offering->capacity);
|
||||
self::assertSame(Offering::BILLING_FULL_TERM, $offering->billingMode);
|
||||
self::assertSame(48, $offering->cancellationCutoffHours);
|
||||
self::assertTrue($offering->isActive);
|
||||
}
|
||||
|
||||
public function testFromRowMapsNullCancellationCutoff(): void
|
||||
{
|
||||
$row = (object) [
|
||||
'id' => '7',
|
||||
'instructor_id' => '3',
|
||||
'kind' => Offering::KIND_PRIVATE_LESSON,
|
||||
'title' => '30 min lesson',
|
||||
'description' => null,
|
||||
'duration_minutes' => '30',
|
||||
'price' => '40.00',
|
||||
'currency' => 'CAD',
|
||||
'billing_mode' => Offering::BILLING_ONE_TIME,
|
||||
'allow_weekly' => '0',
|
||||
'capacity' => null,
|
||||
'term_start' => null,
|
||||
'term_end' => null,
|
||||
'schedule_note' => null,
|
||||
'etransfer_email' => null,
|
||||
'cancellation_cutoff_hours' => null,
|
||||
'is_active' => '1',
|
||||
];
|
||||
|
||||
$offering = Offering::fromRow($row);
|
||||
|
||||
self::assertNull($offering->cancellationCutoffHours);
|
||||
}
|
||||
|
||||
public function testToArrayContainsExpectedKeys(): void
|
||||
{
|
||||
$offering = new Offering(1, Offering::KIND_PRIVATE_LESSON, 'Lesson', id: 10);
|
||||
|
||||
Reference in New Issue
Block a user