Affichage détail compte

- Ajout de l'affichage des totaux venant des majorations/jour
- Fix affichage valid_by historique
This commit is contained in:
Aurélien Delobelle 2016-08-23 18:15:41 +02:00
parent 4048c007ea
commit 79455193ca
2 changed files with 24 additions and 4 deletions

View file

@ -28,6 +28,18 @@
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
<div class="content-right">
{% if addcosts %}
<div class="content-right-block">
<h2>Gagné des majorations</h2>
<div>
<ul>
{% for addcost in addcosts %}
<li>{{ addcost.date|date:'l j F' }}: {{ addcost.sum_addcosts }}</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="content-right-block">
<h2>Historique</h2>
<div id="history">
@ -48,7 +60,7 @@
{{ ope.group.amount|ukf:ope.group.is_cof }}
{% endif %}
</span>
{% if perms.kfet.is_team %}
{% if perms.kfet.is_team and ope.group.valid_by %}
<span class="valid_by">Par {{ ope.group.valid_by.trigramme }}</span>
{% endif %}
{% if ope.group.comment %}

View file

@ -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'] = []