From 193ce850b4297e15edbb323468e946b19cbb644d Mon Sep 17 00:00:00 2001 From: i701 Date: Sat, 5 Jul 2025 20:14:58 +0500 Subject: [PATCH] =?UTF-8?q?fix(filters):=20refine=20filter=20logic=20in=20?= =?UTF-8?q?TopupFilter=20to=20ensure=20only=20unpaid=20topups=20are=20cons?= =?UTF-8?q?idered=20for=20expiration=20check=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- billing/filters.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/billing/filters.py b/billing/filters.py index 2246518..9fe4487 100644 --- a/billing/filters.py +++ b/billing/filters.py @@ -43,9 +43,10 @@ class TopupFilter(django_filters.FilterSet): Filter topups based on whether they are expired or not """ now = timezone.now() - if value: # Filter for expired topups + queryset = queryset.filter(paid=False) + if value: return queryset.filter(expires_at__isnull=False, expires_at__lt=now) - else: # Filter for non-expired topups + else: return queryset.filter(Q(expires_at__isnull=True) | Q(expires_at__gte=now)) class Meta: