Browse Source

exclusion des services non actifs des statistiques

Élie Bouttier 8 years ago
parent
commit
09128169f5
1 changed files with 3 additions and 1 deletions
  1. 3 1
      services/management/commands/servicesstats.py

+ 3 - 1
services/management/commands/servicesstats.py

@@ -1,5 +1,6 @@
 from django.core.management.base import BaseCommand, CommandError
 from django.db.models import DecimalField, F, Sum, Func, Q
+from django.utils import timezone
 
 from decimal import Decimal
 
@@ -14,7 +15,8 @@ class Command(BaseCommand):
         total_income = Decimal(0.0)
         lines = []
         for service_type in ServiceType.objects.all():
-            services = service_type.services
+            now = timezone.now()
+            services = service_type.services.exclude(start__gt=now).exclude(end__lte=now)
             ntotal = services.count()
             services = services.exclude(adherent=None)
             nadh = services.count()