|
@@ -4,6 +4,8 @@ from adhesions.models import Adhesion
|
|
|
from services.models import Service, ServiceType, IPResource, Route
|
|
|
from banking.models import RecurringPayment, PaymentUpdate
|
|
|
|
|
|
+from operator import add
|
|
|
+
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
help = 'Afficher les statistiques financières'
|
|
@@ -20,7 +22,7 @@ class Command(BaseCommand):
|
|
|
|
|
|
def handle_services(self):
|
|
|
ttnn = Adhesion.objects.get(id=100)
|
|
|
- total_income = 0
|
|
|
+ total = [0, 0, 0, 0, 0, 0]
|
|
|
lines = []
|
|
|
for service_type in ServiceType.objects.all():
|
|
|
services = service_type.services.filter(active=True)
|
|
@@ -36,9 +38,11 @@ class Command(BaseCommand):
|
|
|
pfree = ptotal - ppay
|
|
|
pmiss = nadh - ptotal
|
|
|
income = sum(map(lambda payment: float(payment.amount) / payment.period, payments))
|
|
|
- total_income += income
|
|
|
+ total = list(map(add, total, [nadh, ninf, ppay, pfree, pmiss, income]))
|
|
|
lines += [(str(service_type), nadh, ninf, ppay, pfree, pmiss, income)]
|
|
|
self.stdout.write("%-16s%12s%12s%12s%12s%12s%12s" % ('Service', 'infra', 'adhérents', 'gratuit', 'manquant', 'euros', 'pourcent'))
|
|
|
+ lines += [('TOTAL',) + tuple(total)]
|
|
|
+ total_income = total[5]
|
|
|
for service_type, nadh, ninf, ppay, pfree, pmiss, income in lines:
|
|
|
if total_income:
|
|
|
percent = income / total_income * 100
|