Affichage négatifs centralisés

- Accessibles depuis la page des comtpes et avec la perm `kfet.view_negs`
- Ajout du js moment avec timezone oublié précédemment
This commit is contained in:
Aurélien Delobelle 2016-08-23 20:31:31 +02:00
parent 79455193ca
commit 54ff265b0f
12 changed files with 1334 additions and 7 deletions

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('kfet', '0035_auto_20160823_1505'),
]
operations = [
migrations.AlterModelOptions(
name='globalpermissions',
options={'managed': False, 'permissions': (('is_team', 'Is part of the team'), ('perform_deposit', 'Effectuer une charge'), ('perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte"), ('cancel_old_operations', 'Annuler des commandes non récentes'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'), ('view_negs', 'Voir la liste des négatifs'))},
),
]

View file

@ -523,6 +523,7 @@ class GlobalPermissions(models.Model):
('manage_perms', 'Gérer les permissions K-Fêt'),
('manage_addcosts', 'Gérer les majorations'),
('perform_commented_operations', 'Enregistrer des commandes avec commentaires'),
('view_negs', 'Voir la liste des négatifs'),
)
class Settings(models.Model):

View file

@ -74,7 +74,7 @@ a:focus, a:hover {
}
.content-left .block {
padding-top:10px;
padding-top:25px;
}
.content-left .block .line {
@ -82,13 +82,19 @@ a:focus, a:hover {
line-height:30px;
}
.content-left .line.trigramme {
.content-left .line.line-big {
font-family:Oswald;
font-size:60px;
font-weight:bold;
text-align:center;
}
.content-left .line.line-bigsub {
font-size:25px;
font-weight:bold;
text-align:center;
}
.content-left .line.balance {
font-size:45px;
text-align:center;

View file

@ -9,11 +9,15 @@
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top text-center">
<div class="line">{{ accounts|length|add:-1 }} comptes</div>
<div class="line line-big">{{ accounts|length|add:-1 }}</div>
<div class="line line-bigsub">compte{{ accounts|length|add:-1|pluralize }}</div>
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.create' %}">Créer un compte</a>
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.group' %}">Permissions</a>
{% if perms.kfet.view_negs %}
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.negative' %}">Négatifs</a>
{% endif %}
</div>
</div>
</div>

View file

@ -0,0 +1,76 @@
{% extends 'kfet/base.html' %}
{% block title %}Comptes en négatifs{% endblock %}
{% block content-header-title %}Comptes - Négatifs{% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top">
<div class="line line-big">{{ negatives|length }}</div>
<div class="line line-bigsub">compte{{ negatives|length|pluralize }} en négatif</div>
<div class="block">
<div class="line"><b>Total:</b> {{ negatives_sum|floatformat:2 }}€</div>
</div>
<div class="block">
<div class="line"><b>Découvert autorisé par défaut</b></div>
<div class="line">Montant: {{ settings.overdraft_amount }}€</div>
<div class="line">Pendant: {{ settings.overdraft_duration }}</div>
</div>
</div>
{% if perms.kfet.change_settings %}
<div class="buttons">
<a class="btn btn-primary btn-lg" href="{% url 'kfet.settings' %}">Modifier les valeurs par défaut</a>
</div>
{% endif %}
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include 'kfet/base_messages.html' %}
<div class="content-right">
<div class="content-right-block">
<h2>Liste des comptes en négatifs</h2>
<div>
<table class="table table-condensed">
<tr style="font-weight:bold;">
<td></td>
<td>Tri</td>
<td>Nom</td>
<td>Balance</td>
<td>Réelle</td>
<td>Début</td>
<td>Découvert autorisé</td>
<td>Jusqu'au</td>
<td>Balance offset</td>
</tr>
{% for neg in negatives %}
<tr>
<td>
<a href="{% url 'kfet.account.update' neg.account.trigramme %}">
<span class="glyphicon glyphicon-cog"></span>
</a>
</td>
<td>{{ neg.account.trigramme }}</td>
<td>{{ neg.account.name }}</td>
<td class="text-right">{{ neg.account.balance|floatformat:2 }}€</td>
<td class="text-right">
{% if neg.account.balance_offset %}
{{ neg.account.real_balance|floatformat:2 }}€
{% endif %}
</td>
<td>{{ neg.start|date:'d/m/Y H:i:s'}}</td>
<td>{{ neg.authz_overdraft_amount|default_if_none:'' }}</td>
<td>{{ neg.authz_overdrafy_until|default_if_none:'' }}</td>
<td>{{ neg.balance_offset|default_if_none:'' }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -34,7 +34,7 @@
<div>
<ul>
{% for addcost in addcosts %}
<li>{{ addcost.date|date:'l j F' }}: {{ addcost.sum_addcosts }}</li>
<li>{{ addcost.date|date:'l j F' }}: +{{ addcost.sum_addcosts }}</li>
{% endfor %}
</ul>
</div>

View file

@ -23,7 +23,7 @@
{% endif %}
{% if user.profile.account_kfet %}
<li>
<a href="{% url 'kfet.account.read' request.user.profile.account_kfet.trigramme %}">Mes infos</a>
<a href="{% url 'kfet.account.read' user.profile.account_kfet.trigramme %}">Mes infos</a>
</li>
{% endif %}
{% if perms.kfet.is_team %}

View file

@ -1,7 +1,7 @@
{% load kfet_tags %}
<div class="content-left-top {% if account.is_frozen %}frozen-account{% endif %}">
<div class="line trigramme">{{ account.trigramme }}</div>
<div class="line line-big">{{ account.trigramme }}</div>
<div class="line balance">{{ account.balance|ukf:account.is_cof }} UKF</div>
<div class="block">
<div class="line">{{ account.name }}</div>

View file

@ -1,5 +1,5 @@
<div class="content-left-top">
<div class="line trigramme">{{ checkout.name }}</div>
<div class="line line-big">{{ checkout.name }}</div>
<div class="line balance">{{ checkout.balance|floatformat:2 }} €</div>
<div class="block">
<div class="line">Valide du {{ checkout.valid_from|date:'l j F Y, G:i' }}</div>

View file

@ -49,6 +49,10 @@ urlpatterns = [
permission_required('kfet.manage_perms')(views.AccountGroupUpdate.as_view()),
name = 'kfet.account.group.update'),
url(r'^accounts/negatives$',
permission_required('kfet.view_negs')(views.AccountNegativeList.as_view()),
name = 'kfet.account.negative'),
# -----
# Checkout urls
# -----

View file

@ -13,6 +13,7 @@ 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, Sum
from django.db.models.functions import Coalesce
from django.utils import timezone
from django.utils.crypto import get_random_string
from gestioncof.models import CofProfile, Clipper
@ -351,6 +352,27 @@ class AccountGroupUpdate(UpdateView):
success_message = 'Groupe modifié : %(name)s'
success_url = reverse_lazy('kfet.account.group')
class AccountNegativeList(ListView):
queryset = (AccountNegative.objects
.select_related('account', 'account__cofprofile__user'))
template_name = 'kfet/account_negative.html'
context_object_name = 'negatives'
def get_context_data(self, **kwargs):
context = super(AccountNegativeList, self).get_context_data(**kwargs)
context['settings'] = {
'overdraft_amount': Settings.OVERDRAFT_AMOUNT(),
'overdraft_duration': Settings.OVERDRAFT_DURATION(),
}
negs_sum = (AccountNegative.objects
.aggregate(
bal = Coalesce(Sum('account__balance'),0),
offset = Coalesce(Sum('balance_offset'),0),
)
)
context['negatives_sum'] = negs_sum['bal'] + negs_sum['offset']
return context
# -----
# Checkout views
# -----

File diff suppressed because it is too large Load diff