Bill a monthly group class its fee once per month
CI / Tests (PHP 8.1) (pull_request) Successful in 49s
CI / Tests (PHP 8.2) (pull_request) Successful in 52s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m50s
CI / Coding Standards (pull_request) Successful in 2m58s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / Build Plugin Zip (pull_request) Skipped

A monthly group class multiplied its price by the sessions falling in the month,
the same rule private lessons use — so a class priced at 40.00 CAD meeting
weekly was billed 160.00 CAD on the 1st, and no studio could quote the price on
a class card without lying about it.

A group class is now billed its fee once for the month however many times it
meets, which is what the card quotes and what the student ticks to agree to.
Private lessons keep the per-lesson rule: their price is a per-lesson fee, and
that is why the card quotes it per lesson.

The session count still labels the month on the student's payment notice; it no
longer prices it.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-07-28 15:22:46 -03:00
co-authored by Claude Opus 5
parent a276d53c1b
commit bfdc3b3380
6 changed files with 56 additions and 21 deletions
+9 -2
View File
@@ -251,11 +251,18 @@ class ScheduledBillingRunner {
/**
* Bill one payment per calendar month of a group class, once its 1st arrives.
*
* A monthly group class is priced **per month**, not per session: the fee is
* charged once for the month however many times the class meets in it. This is
* what the student is quoted and agrees to on the way in ("40.00 CAD monthly"),
* and it is the one place the monthly rule differs from private lessons, whose
* per-lesson fee is multiplied by the lessons that fall in the month.
*
* @param list<array{start: string, end: string}> $windows
* @param array<int, list<array{payment: Payment, label: string}>> $buckets
*/
private function billGroupMonthly( \DateTimeImmutable $now, string $today, Enrollment $enrollment, Offering $offering, array $windows, array &$buckets ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
// Count this enrolment's sessions per calendar month.
// Count this enrolment's sessions per calendar month. The count does not
// price the month — it names it on the student's notice ("3 sessions").
$months = [];
foreach ( $windows as $window ) {
$start = new \DateTimeImmutable( $window['start'] );
@@ -278,7 +285,7 @@ class ScheduledBillingRunner {
(int) $enrollment->id,
$enrollment->studentId,
$enrollment->instructorId,
$offering->price * $count,
$offering->price,
$offering->currency,
$offering->etransferEmail,
$monthStart,