diff --git a/refunding/templates/refunding/elements_list.html b/refunding/templates/refunding/elements_list.html
index 500524d..81e637f 100644
--- a/refunding/templates/refunding/elements_list.html
+++ b/refunding/templates/refunding/elements_list.html
@@ -1,7 +1,7 @@
{% if elements %}
{% if sum %}
- Total : {{ sum|floatformat:-2 }}€
+ Total : {{ sum|floatformat:-2 }}€{% if refunded %} (soit {{ monthly|floatformat:-2 }}€ par mois){% endif %}
{% endif %}
diff --git a/refunding/views.py b/refunding/views.py
index cc44a6c..74b34c5 100644
--- a/refunding/views.py
+++ b/refunding/views.py
@@ -1,3 +1,5 @@
+import calendar
+
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.db.models import Sum
@@ -174,9 +176,23 @@ def already_refunded_payments(request):
else:
value_sum = 0
+ start_date = refunded.last().date
+ start_date = start_date.replace(day=1)
+
+ end_date = refunded.first().date
+ month = end_date.month
+ year = end_date.year + month // 12
+ month = month % 12 + 1
+ end_date = end_date.replace(year=year, month=month, day=1)
+
+ diff = (end_date.year - start_date.year) * 12 + end_date.month - start_date.month
+
+ monthly = value_sum / diff
+
context = {
'refunded': refunded,
'sum': value_sum,
+ 'monthly': monthly,
'default_nothing': 'Aucun paiement remboursé :)'
}
return render(request, "refunding/refunded_payments.html", context)