Extend availability (durations, weekly recurrence, calendar); price offerings in dollars
CI / Coding Standards (pull_request) Successful in 50s
CI / PHPStan (pull_request) Successful in 1m2s
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 48s
CI / Tests (PHP 8.3) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Has been skipped

Availability (#2):
- us_availability gains offering_id, duration_minutes (default 60), and
  recurrence_group; AvailabilitySlot carries the new fields.
- AvailabilityRepository::createWeeklySeries() generates N weekly rows
  sharing a recurrence_group; findAvailable() filters by offering and
  duration. Date math uses DateTimeImmutable::modify() (the no-debug CI
  regex `dd\(` matches `->add(`).
- REST GET filters by offering_id/duration_minutes; POST accepts
  duration_minutes, offering_id, recurrence (single|weekly) + weeks.
- Admin form adds duration, an offering picker, and one-off/weekly options
  (OfferingRepository wired into AvailabilityController).
- booking.js renders an agenda calendar (slots grouped by day, with
  duration). The richer booking UX lands with the booking-flow work.

Offering price in dollars:
- Switch us_offerings.price_cents (INT) to price DECIMAL(10,2); Offering
  uses float $price. Admin form and REST take dollars.
- Fix a pre-existing misalignment in the Offering insert/update $wpdb
  format arrays (billing_mode/capacity/is_active were mapped to the wrong
  specifiers, which would corrupt values) via a single COLUMN_FORMATS list.

Also bump PHPStan to --memory-limit=1G in the lint script; 128M now
crashes analysis as the codebase has grown.

Refs #2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 15:38:58 -03:00
parent 5352fb7d69
commit 19e663d6fa
18 changed files with 398 additions and 112 deletions
@@ -35,7 +35,7 @@ class OfferingRepositoryTest extends TestCase
return $data['instructor_id'] === 5
&& $data['kind'] === Offering::KIND_PRIVATE_LESSON
&& $data['title'] === '30-min Piano'
&& $data['price_cents'] === 3500
&& $data['price'] === 35.00
&& $data['allow_weekly'] === 0
&& $data['is_active'] === 1
&& $data['created_at'] === '2026-04-01 12:00:00';
@@ -49,7 +49,7 @@ class OfferingRepositoryTest extends TestCase
instructorId: 5,
kind: Offering::KIND_PRIVATE_LESSON,
title: '30-min Piano',
priceCents: 3500,
price: 35.00,
durationMinutes: 30,
);
@@ -168,7 +168,7 @@ class OfferingRepositoryTest extends TestCase
'title' => '30-min Piano',
'description' => null,
'duration_minutes' => '30',
'price_cents' => '3500',
'price' => '35.00',
'currency' => 'CAD',
'billing_mode' => Offering::BILLING_ONE_TIME,
'allow_weekly' => '0',
+6 -6
View File
@@ -14,7 +14,7 @@ class OfferingTest extends TestCase
instructorId: 5,
kind: Offering::KIND_PRIVATE_LESSON,
title: '30-min Piano',
priceCents: 3500,
price: 35.00,
billingMode: Offering::BILLING_ONE_TIME,
durationMinutes: 30,
id: 42,
@@ -23,7 +23,7 @@ class OfferingTest extends TestCase
self::assertSame(5, $offering->instructorId);
self::assertSame(Offering::KIND_PRIVATE_LESSON, $offering->kind);
self::assertSame('30-min Piano', $offering->title);
self::assertSame(3500, $offering->priceCents);
self::assertSame(35.00, $offering->price);
self::assertSame(30, $offering->durationMinutes);
self::assertSame(42, $offering->id);
}
@@ -32,7 +32,7 @@ class OfferingTest extends TestCase
{
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir');
self::assertSame(0, $offering->priceCents);
self::assertSame(0.0, $offering->price);
self::assertSame('CAD', $offering->currency);
self::assertSame(Offering::BILLING_ONE_TIME, $offering->billingMode);
self::assertNull($offering->durationMinutes);
@@ -51,7 +51,7 @@ class OfferingTest extends TestCase
'title' => 'Year Choir',
'description' => 'Weekly choir',
'duration_minutes' => null,
'price_cents' => '12000',
'price' => '120.00',
'currency' => 'CAD',
'billing_mode' => Offering::BILLING_FULL_TERM,
'allow_weekly' => '0',
@@ -67,7 +67,7 @@ class OfferingTest extends TestCase
self::assertSame(7, $offering->id);
self::assertSame(3, $offering->instructorId);
self::assertNull($offering->durationMinutes);
self::assertSame(12000, $offering->priceCents);
self::assertSame(120.00, $offering->price);
self::assertSame(20, $offering->capacity);
self::assertSame(Offering::BILLING_FULL_TERM, $offering->billingMode);
self::assertTrue($offering->isActive);
@@ -78,7 +78,7 @@ class OfferingTest extends TestCase
$offering = new Offering(1, Offering::KIND_PRIVATE_LESSON, 'Lesson', id: 10);
$arr = $offering->toArray();
foreach (['id', 'instructor_id', 'kind', 'title', 'price_cents', 'billing_mode', 'is_active'] as $key) {
foreach (['id', 'instructor_id', 'kind', 'title', 'price', 'billing_mode', 'is_active'] as $key) {
self::assertArrayHasKey($key, $arr);
}
}