feat(billing): let the desk date a subscription invoice to the month it settles
A branch going onto the system mid-season has players who have been training —
and paying — since before anyone typed them in. Registration could only ever
raise an invoice dated today, so the first invoice for those players said
September when the money it settled was August, and nothing reconciled.
Both reception wizards now ask, on the payment step, whether the invoice is for
today or for an earlier month, and offer the last twelve. The month is bounded
at both ends: a future month is refused outright, in validation and again in the
service, because an invoice dated ahead of today is one the renewal run raises a
second time when that month arrives and one no "what did we bill this month"
report shows. Inside the current month the invoice still reads as raised today —
backdating it to the 1st only makes it look overdue the day it is created.
The dating is the smaller half. GenerateRenewalInvoices skips a month only when
it finds BOTH metadata->month and metadata->renewal_enrollment_id on a
non-cancelled invoice, and neither wizard wrote either — so every invoice they
raised was invisible to that check and the nightly run billed the same month
again. Two invoices, one player, one month, nothing on either saying so. Both
now stamp both keys, and both advance next_billing_date past the month just
billed — forward only, so a backdated invoice can never drag the anchor back
behind where it already sits and have the run bill the months in between.
The guard resolving the month runs before the auto-invoice branch, so a bad
month is refused identically whether or not an academy has
auto_invoice_on_enrollment switched on.
Co-Authored-By:
Claude Opus 5 (1M context) <noreply@anthropic.com>
Showing
Please register or sign in to comment