Nouvelle fonctionnalité : cotisation moyenne sur la page de statistiques. Statistiques globales pour Aurore.
This commit is contained in:
parent
de9909011a
commit
3d3249f7ab
@ -21,7 +21,13 @@ class StatsController(AuthenticatedBaseController):
|
||||
residences = []
|
||||
rooms_stats = dict()
|
||||
members_stats = dict()
|
||||
total_earned = dict()
|
||||
average_cotisation = dict()
|
||||
global_average_cotisation = 0
|
||||
global_total_earned = 0
|
||||
global_current_members = 0
|
||||
residences_ldap = Residences.get_residences(self.user)
|
||||
year = CotisationComputes.current_year()
|
||||
for residence_ldap in residences_ldap:
|
||||
residence_dn = residence_ldap.uniqueMember.first()
|
||||
residence_name = residence_ldap.cn.first()
|
||||
@ -38,6 +44,23 @@ class StatsController(AuthenticatedBaseController):
|
||||
for room in Room.get_rooms(self.user, residence_dn):
|
||||
if not room.has("x-memberIn"):
|
||||
rooms_stats[residence_name]['empty_rooms'].append(room)
|
||||
# FIXME : Vérifier si on compte les "extras" (vente de câbles). Il ne faudrait pas les compter.
|
||||
all_payments = Cotisation.get_all_payment_by_year(self.user, residence_dn, year)
|
||||
total_earned[residence_name] = 0
|
||||
for onepayment in all_payments:
|
||||
total_earned[residence_name] += float(onepayment.get('x-amountPaid').first())
|
||||
#end for
|
||||
if(members_stats[residence_name]['number_of_current_members'] != 0):
|
||||
average_cotisation[residence_name] = float(total_earned[residence_name])/float(members_stats[residence_name]['number_of_current_members'])
|
||||
else:
|
||||
average_cotisation[residence_name] = 0
|
||||
global_total_earned += total_earned[residence_name]
|
||||
global_current_members += members_stats[residence_name]['number_of_current_members']
|
||||
|
||||
if(global_current_members != 0):
|
||||
global_average_cotisation = global_total_earned/global_current_members
|
||||
else:
|
||||
global_average_cotisation = 0
|
||||
|
||||
residence = None
|
||||
if self.user is not None:
|
||||
@ -49,7 +72,12 @@ class StatsController(AuthenticatedBaseController):
|
||||
"residence" : residence,
|
||||
"residences" : residences,
|
||||
"rooms_stats" : rooms_stats,
|
||||
"members_stats" : members_stats
|
||||
"members_stats" : members_stats,
|
||||
"total_earned" : total_earned,
|
||||
"average_cotisation" : average_cotisation,
|
||||
"global_total_earned" : global_total_earned,
|
||||
"global_current_members" : global_current_members,
|
||||
"global_average_cotisation" : global_average_cotisation
|
||||
}
|
||||
#end def
|
||||
#end class
|
||||
|
@ -6,6 +6,23 @@
|
||||
</head>
|
||||
<body>
|
||||
<xi:include href="navbar.html" />
|
||||
<div py:if="residence == 'Aurore'" class="section" >
|
||||
<span class="section_name show_section_name">Globalement</span>
|
||||
<div>
|
||||
<div>
|
||||
<div class="room_number vide_color">${"%03d" % global_current_members}</div>
|
||||
<span>Adhérents actuels</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="room_number vide_color">${"%03d €" % global_total_earned}</div>
|
||||
<span>Cotisations année en cours</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="room_number vide_color">${"%03d €" % global_average_cotisation}</div>
|
||||
<span>Cotisation moyenne année en cours</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" >
|
||||
<div py:for="residence in residences">
|
||||
<span class="section_name show_section_name">${residence}</span>
|
||||
@ -14,6 +31,14 @@
|
||||
<div class="room_number ok_color">${"%03d" % members_stats[residence]['number_of_cotisation_paid_members']}</div>
|
||||
<span>Cotisations à jour</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="room_number vide_color">${"%03d €" % total_earned[residence]}</div>
|
||||
<span>Cotisations année en cours</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="room_number vide_color">${"%03d €" % average_cotisation[residence]}</div>
|
||||
<span>Cotisation moyenne année en cours</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="room_number non_certif_color">${"%03d" % members_stats[residence]['number_of_cotisation_late_members']}</div>
|
||||
<span>Cotisations en retard</span>
|
||||
|
Loading…
Reference in New Issue
Block a user