fix(groups): read the subscription column off what the invoice actually says
The roster column called itself الدفع and answered two questions wrongly.
WHAT COUNTS. "Subscription" was every invoice line with no itemable — which
is every line a receptionist typed by hand. On the live tenant that swept in
42,800 EGP of federation registration fees ("قسط القيد", "قيد اشتراك",
"أقساط متبقية من قيد اتحاد الكرة") and kit ("الزي", "شنطة لبس") and reported
it as training money players had paid. SubscriptionLine now reads the text:
the academy's own product names first, then its programme names, then the
words for registration and kit — matched on whole normalised WORDS, never
substrings, because "تجهيزي" contains the letters of "زي" and a substring
match turns a subscription into merchandise. Anything still unrecognised
keeps counting as subscription, so no line disappears unannounced.
WHICH MONTH. The month was the invoice's issue_date, which is only the
covered month when the invoice was raised inside it. August's subscription
typed up in September belonged to no cycle at all, and one invoice covering
July and August counted twice over. Months now come from the invoice's own
metadata, then any month named in the line or the notes ("اشتراك يوليو 2026",
"اشتراك شهر 8", ranges), then the issue date — and a line covering several
months is split evenly across them, remainder on the last, so the parts can
never exceed what was billed. A line that names no month is still judged by
its date, which is the only evidence there is.
A year is only read as a date when it sits near the invoice, so the age group
in "فريق 2011/2012" cannot date a 2026 subscription to 2011.
Verified against a restored copy of the live tenant: subscription billed for
July 123,173 -> 101,073 EGP and August 200,538 -> 187,038 EGP, and every
excluded line was checked one by one — all 14 are registration or kit, none
is a programme. No line currently moves month; that half is future-proofing
plus the combined-invoice case the old data is full of.
Column renamed الدفع -> الاشتراك and the header now carries the year as well
as the month, because "سبتمبر" alone does not say which September.
Co-Authored-By:
Claude Opus 5 (1M context) <noreply@anthropic.com>
Showing
This diff is collapsed.
Please register or sign in to comment