Rapport Remunération
authorPA Parent <paparent@paparent.me>
Tue, 13 Dec 2011 20:11:44 +0000 (15:11 -0500)
committerPA Parent <paparent@paparent.me>
Tue, 13 Dec 2011 20:11:44 +0000 (15:11 -0500)
project/menu.py
project/rh/templates/rh/rapports/remuneration.html [new file with mode: 0644]
project/rh/urls.py
project/rh/views.py

index db73ace..e8f310c 100644 (file)
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 """
 This file was generated with the custommenu management command, it contains
 the classes for the admin menu, you can customize this class as you want.
 """
 This file was generated with the custommenu management command, it contains
 the classes for the admin menu, you can customize this class as you want.
@@ -29,6 +31,7 @@ class CustomMenu(Menu):
                            children=[
                                items.MenuItem('Rapport des postes', reverse('rhr_postes')),
                                items.MenuItem('Rapport des contrats', reverse('rhr_contrats')),
                            children=[
                                items.MenuItem('Rapport des postes', reverse('rhr_postes')),
                                items.MenuItem('Rapport des contrats', reverse('rhr_contrats')),
+                               items.MenuItem('Rapport de rémunération', reverse('rhr_remuneration')),
                            ]
                           ),
             items.AppList(
                            ]
                           ),
             items.AppList(
diff --git a/project/rh/templates/rh/rapports/remuneration.html b/project/rh/templates/rh/rapports/remuneration.html
new file mode 100644 (file)
index 0000000..7fa0395
--- /dev/null
@@ -0,0 +1,47 @@
+{% extends 'rh/rapports/base.html' %}
+{% load adminmedia rapports i18n %}
+
+{% block nomrapport %}Rapport de rémunération{% endblock %}
+
+{% block contentrapport %}
+
+<div id="changelist-filter">
+<h2>{% trans 'Filter' %}</h2>
+{% comment %}
+{% filter_region_contrat %}
+{% filter_implantation_contrat %}
+{% filter_type_contrat %}
+{% filter_echeance_contrat %}
+{% endcomment %}
+</div>
+
+<table id="result_list">
+<thead>
+<tr>
+       <th># de l'employé</th>
+       <th>Nom</th>
+       <th>Prénom</th>
+       <th>Traitement</th>
+       <th>Indemnité</th>
+       <th>Charges</th>
+       <th>Accessoire</th>
+       <th>RAS</th>
+       <th>Total</th>
+</tr>
+</thead>
+{% spaceless %}{% for employe in employes %}
+<tr class="{% cycle 'row1' 'row2' %}">
+       <td>{{ employe.id }}</td>
+       <td>{{ employe.nom }}</td>
+       <td>{{ employe.prenom }}</td>
+       <td align="right">{{ employe.Traitement|default:0|floatformat:2 }} &euro;</td>
+       <td align="right">{{ employe.Indemnite|default:0|floatformat:2 }} &euro;</td>
+       <td align="right">{{ employe.Charges|default:0|floatformat:2 }} &euro;</td>
+       <td align="right">{{ employe.Accessoire|default:0|floatformat:2 }} &euro;</td>
+       <td align="right">{{ employe.RAS|default:0|floatformat:2 }} &euro;</td>
+       <td align="right">{{ employe.remun_sum_euro|default:0|floatformat:2 }} &euro;</td>
+</tr>
+{% endfor %}{% endspaceless %}
+</table>
+
+{% endblock %}
index ea19452..ec96cf2 100644 (file)
@@ -17,4 +17,5 @@ urlpatterns += patterns(
     'project.rh.views',
     url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
     url(r'^admin/rh/rapports/contrats$', 'rapports_contrat', name='rhr_contrats'),
     'project.rh.views',
     url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
     url(r'^admin/rh/rapports/contrats$', 'rapports_contrat', name='rhr_contrats'),
+    url(r'^admin/rh/rapports/remuneration$', 'rapports_remuneration', name='rhr_remuneration'),
 )
 )
index 882ed6d..fde04ad 100644 (file)
@@ -10,6 +10,7 @@ from datamaster_modeles import models as ref
 from project.lib import get_employe_from_id
 
 from rh import models as rh
 from project.lib import get_employe_from_id
 
 from rh import models as rh
+from rh.lib import calc_remun
 
 # homes
 @login_required
 
 # homes
 @login_required
@@ -134,3 +135,62 @@ def rapports_contrat(request):
     }
 
     return render_to_response('rh/rapports/contrats.html', c, RequestContext(request))
     }
 
     return render_to_response('rh/rapports/contrats.html', c, RequestContext(request))
+
+
+def rapports_remuneration(request):
+
+    lookup_params = dict(request.GET.items())
+
+    for key, value in lookup_params.items():
+        if not isinstance(key, str):
+            # 'key' will be used as a keyword argument later, so Python
+            # requires it to be a string.
+            del lookup_params[key]
+            lookup_params[smart_str(key)] = value
+
+    employes = rh.Employe.objects.all()
+    employes = employes.filter(**lookup_params)
+
+    output = []
+
+    for employe in employes:
+        line = {}
+        output.append(line)
+
+        dossiers = employe.dossiers.all()
+
+        remun = {}
+        remun_sum_euro = 0
+
+        for dossier in dossiers:
+            this_remun, this_remun_sum, this_remun_sum_euro = calc_remun(dossier)
+
+            for item in this_remun:
+                if item not in remun:
+                    remun[item] = this_remun[item]
+                else:
+                    remun[item][0] += this_remun[item][0]
+                    remun[item][1] += this_remun[item][1]
+
+            remun_sum_euro += this_remun_sum_euro
+
+        line['remun_sum_euro'] = remun_sum_euro
+
+        for r in remun:
+            if r == u'Indemnité':
+                print r
+                line['Indemnite'] = remun[r][1]
+            else:
+                line[r] = remun[r][1]
+
+        line['id'] = employe.id
+        line['nom'] = employe.nom
+        line['prenom'] = employe.prenom
+
+
+    c = {
+        'title': 'Rapport de remuneration',
+        'employes': output,
+    }
+
+    return render_to_response('rh/rapports/remuneration.html', c, RequestContext(request))