# -*- encoding: utf-8 -*-
+from collections import defaultdict
+import datetime
+
from django.db import models
from django.contrib import admin
from django.conf import settings
instance.owner = request.user
instance.save()
+ def render_change_form(self, request, context, *args, **kwargs):
+ obj = kwargs['obj']
+
+ thisyear = datetime.date.today().year
+ thisyearfilter = Q(date_debut__year=thisyear) | Q(date_fin__year=thisyear)
+
+ remunnow = obj.rh_remuneration_remunerations.filter(thisyearfilter)
+
+ remun_sum = 0
+ remun_sum_euro = 0
+ sums = defaultdict(int)
+ sums_euro = defaultdict(int)
+ for r in remunnow:
+ nature = r.type.nature_remuneration
+ sums[nature] += r.montant
+ sums_euro[nature] += r.montant_euro()
+ remun_sum += r.montant
+ remun_sum_euro += r.montant_euro()
+
+ remun = {}
+ sums = dict(sums)
+ for n, s in sums.iteritems():
+ remun[n] = [sums[n], sums_euro[n]]
+
+ extra = {
+ 'remun': remun,
+ 'remun_sum': remun_sum,
+ 'remun_sum_euro': remun_sum_euro,
+ }
+
+ context.update(extra)
+
+ return super(DossierAdmin, self).render_change_form(request, context, *args, **kwargs)
+
+
class DossierPieceAdmin(admin.ModelAdmin):
pass
pour chaque année budgétaire.
"""
# Identification
- devise = models.ForeignKey('Devise', db_column='devise',
- related_name='+')
+ devise = models.ForeignKey('Devise', db_column='devise')
annee = models.IntegerField(verbose_name = u"Année")
taux = models.FloatField(verbose_name = u"Taux vers l'euro")
--- /dev/null
+{% extends 'admin/change_form.html' %}
+
+{% block content %}
+{{ block.super }}
+
+<h2>Rémunération cette année</h2>
+<table>
+ <tr>
+ <th></th>
+ <th>Devise locale</th>
+ <th>Euro</th>
+ </tr>
+{% for t, m in remun.iteritems %}
+ <tr>
+ <td>{{ t }}</td>
+ <td>{{ m.0 }}</td>
+ <td>{{ m.1 }}</td>
+ </tr>
+{% endfor %}
+ <tr>
+ <td>Total</td>
+ <td>{{ remun_sum }}</td>
+ <td>{{ remun_sum_euro }}</td>
+</table>
+
+{% endblock %}