diff --git a/kfet/templates/kfet/account_read.html b/kfet/templates/kfet/account_read.html index 977b7c22..ffe77a3c 100644 --- a/kfet/templates/kfet/account_read.html +++ b/kfet/templates/kfet/account_read.html @@ -28,6 +28,18 @@
{% include "kfet/base_messages.html" %}
+ {% if addcosts %} +
+

Gagné des majorations

+
+
    + {% for addcost in addcosts %} +
  • {{ addcost.date|date:'l j F' }}: {{ addcost.sum_addcosts }}
  • + {% endfor %} +
+
+
+ {% endif %}

Historique

@@ -48,7 +60,7 @@ {{ ope.group.amount|ukf:ope.group.is_cof }} {% endif %} - {% if perms.kfet.is_team %} + {% if perms.kfet.is_team and ope.group.valid_by %} Par {{ ope.group.valid_by.trigramme }} {% endif %} {% if ope.group.comment %} diff --git a/kfet/views.py b/kfet/views.py index ff477a3c..013031dd 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -12,7 +12,7 @@ from django.contrib.auth.models import User, Permission, Group from django.http import HttpResponse, JsonResponse, Http404 from django.forms import modelformset_factory from django.db import IntegrityError, transaction -from django.db.models import F +from django.db.models import F, Sum from django.utils import timezone from django.utils.crypto import get_random_string from gestioncof.models import CofProfile, Clipper @@ -21,7 +21,7 @@ from kfet.models import (Account, Checkout, Article, Settings, AccountNegative, from kfet.forms import * from collections import defaultdict from kfet import consumers -from datetime import timedelta +import datetime import django_cas_ng @login_required @@ -209,9 +209,17 @@ def account_read(request, trigramme): .filter(group__on_acc=account) .order_by('-group__at')) + addcosts = (OperationGroup.objects + .filter(opes__addcost_for=account,opes__canceled_at=None) + .extra({'date':"date(at)"}) + .values('date') + .annotate(sum_addcosts=Sum('opes__addcost_amount')) + .order_by('-date')) + return render(request, "kfet/account_read.html", { 'account' : account, 'history' : history, + 'addcosts': addcosts, }) # Account - Update @@ -991,7 +999,7 @@ def kpsul_history(request): 'id', 'amount', 'at', 'checkout_id', 'is_cof', 'comment', 'valid_by__trigramme', 'on_acc__trigramme') .select_related('valid_by', 'on_acc') - .filter(at__gt=timezone.now()-timedelta(hours=24))) + .filter(at__gt=timezone.now()-datetime.timedelta(hours=24))) opegroups = { opegroup['id']:opegroup for opegroup in opegroups_list } for opegroup in opegroups: opegroups[opegroup]['opes'] = []