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: