Let parents register once and book for their children

A parent registers once and manages lessons for one or more children, who
need no login of their own. A child is a real wp_users row with the student
role but no usable login — so student_id keeps meaning "a WordPress user"
on every table, and booking, credits, policies and enrolments work unchanged.
A us_guardians link table maps guardian to child.

The signup form gains a parent/guardian tick that reveals a block per child,
with the account-signup questions asked per child rather than per guardian
— they describe the student, not the account holder. Signup policies are
recorded once per child with the guardian as the acceptor, which is the
record that actually means something. A family that half-creates is rolled
back entirely rather than leaving a guardian who cannot re-register.

The booking and enrolment forms gain a "Who is this for?" picker listing
children first, so the default selection is never the parent — booking for
the wrong child is correctable, quietly billing a parent for their kid's
lesson is not. POST /bookings and POST /enrollments take an optional
student_id honoured only for that child's guardian; anything else is a 403.
That check is the authorisation boundary of the feature.

Payments and credits gain a payer: the charge names the child it was for and
the guardian who owes it, so per-child reporting is unchanged while notices,
receipts and the payment step reach the parent. Credit is held by the payer,
so one child's cancellation can settle a sibling's charge, and the daily
billing scan sends a guardian one notice covering every child.

Closes #132

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-07-29 16:07:52 -03:00
co-authored by Claude Opus 5
parent c25260a367
commit b772e1811e
71 changed files with 4192 additions and 191 deletions
+7 -1
View File
@@ -11,6 +11,7 @@ use Unsupervised\Schedular\Auth\RegistrationPage;
use Unsupervised\Schedular\BlockRegistrar;
use Unsupervised\Schedular\Booking\BookingPage;
use Unsupervised\Schedular\GroupClass\GroupClassPage;
use Unsupervised\Schedular\Guardian\FamilyPage;
/**
* Test double exposing editor-preview mode as a switch (the real detection
@@ -41,6 +42,7 @@ class BlockRegistrarTest extends TestCase
private LoginPage&Mockery\MockInterface $loginPage;
private RegistrationPage&Mockery\MockInterface $registrationPage;
private GroupClassPage&Mockery\MockInterface $groupClassPage;
private FamilyPage&Mockery\MockInterface $familyPage;
private TestableBlockRegistrar $registrar;
protected function setUp(): void
@@ -51,6 +53,7 @@ class BlockRegistrarTest extends TestCase
$this->loginPage = Mockery::mock(LoginPage::class);
$this->registrationPage = Mockery::mock(RegistrationPage::class);
$this->groupClassPage = Mockery::mock(GroupClassPage::class);
$this->familyPage = Mockery::mock(FamilyPage::class);
// Most requests are not a just-finished registration; the tests that
// exercise that path override this.
@@ -63,6 +66,7 @@ class BlockRegistrarTest extends TestCase
$this->loginPage,
$this->registrationPage,
$this->groupClassPage,
$this->familyPage,
);
}
@@ -74,7 +78,7 @@ class BlockRegistrarTest extends TestCase
$this->registrar->register();
}
public function testRegisterBlocksRegistersAllFourBlocksWithAssets(): void
public function testRegisterBlocksRegistersAllBlocksWithAssets(): void
{
Functions\expect('wp_register_script')
->once()
@@ -111,6 +115,7 @@ class BlockRegistrarTest extends TestCase
'us-scheduler/student-login',
'us-scheduler/student-register',
'us-scheduler/group-classes',
'us-scheduler/family',
],
array_keys($registered)
);
@@ -207,6 +212,7 @@ class BlockRegistrarTest extends TestCase
$this->loginPage,
$this->registrationPage,
$this->groupClassPage,
$this->familyPage,
);
$this->bookingPage->shouldReceive('render')->once()->with([])->andReturn('live');