Show a paid club's cover end date in the health table
For a club on a plan whose dues are settled, the Dues cell now reads "until <date> · paid" — the end of the current paid period, which is the day the grace period would start if nothing renews. It is exactly the "when does this lapse?" question the paid badge alone could not answer. Driven by a new paid_until annotation: the furthest-out PAID period end, null when the club owes or was never billed (so a fully-paid free tier shows just "paid", and an owing club shows the amount, unchanged). It rides the SAME single query — the assertNumQueries(1) test still holds — and the date is whitespace-nowrap so it does not wrap in the narrow cell. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,9 @@ def clubs_with_health(queryset=None, today=None, now=None):
|
||||
dues_owed=_subquery(Due.objects.filter(status__in=Due.OWING), Sum(F("amount") - F("amount_paid")), DecimalField(max_digits=10, decimal_places=2)),
|
||||
dues_grace_until=Subquery(Due.objects.filter(club=OuterRef("pk"), status__in=Due.OWING).order_by("grace_until").values("grace_until")[:1]),
|
||||
dues_period_end=Subquery(Due.objects.filter(club=OuterRef("pk"), status__in=Due.OWING).order_by("period_end").values("period_end")[:1]),
|
||||
# How far a fully-paid club is covered: the furthest-out PAID period end — the day
|
||||
# grace would start if nothing is renewed. Null when the club owes, or was never billed.
|
||||
paid_until=Subquery(Due.objects.filter(club=OuterRef("pk"), status=Due.Status.PAID).order_by("-period_end").values("period_end")[:1]),
|
||||
)
|
||||
.annotate(teams_without_coach=F("team_count") - F("teams_managed"))
|
||||
.order_by("name")
|
||||
|
||||
Reference in New Issue
Block a user