From df37184c67728624f8edb49f954bf03fb5ff2d3b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Caissy Date: Fri, 16 Mar 2012 16:07:48 -0500 Subject: [PATCH] debut affichage masse salariale dans les rapports --- project/rh/masse_salariale.py | 11 ++++-- .../rh/templates/rh/rapports/masse_salariale.html | 27 +++++++++++++++ project/rh/templates/rh/rapports/remuneration.html | 35 -------------------- project/rh/templatetags/rapports.py | 12 ++++--- project/rh/views.py | 21 +++++++++++- 5 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 project/rh/templates/rh/rapports/masse_salariale.html delete mode 100644 project/rh/templates/rh/rapports/remuneration.html diff --git a/project/rh/masse_salariale.py b/project/rh/masse_salariale.py index 9db560b..68ad7d1 100644 --- a/project/rh/masse_salariale.py +++ b/project/rh/masse_salariale.py @@ -37,7 +37,11 @@ class MasseSalariale(): def __init__(self, date_debut, date_fin, custom_filter=None): """ date_debut: date de début pour les données temporelles date_fin: idem + custom_filter: dictionnaire des paramètres à passer au queryset. """ + if not date_debut and not date_fin: + return + date_debut = datetime.date( *time.strptime(date_debut, "%d-%m-%Y")[0:3] ) @@ -135,9 +139,10 @@ class MasseSalariale(): bstg_remun = r if bstg_remun: - bstg_remun_euro = bstg_remun + bstg_remun_euro = rh.Remuneration( + montant=bstg_remun.montant, devise=bstg_remun.devise + ) self.convertir(bstg_remun_euro) - print bstg_remun.devise, bstg_remun_euro.devise salaire_complement = 0.0 salaire_base = 0.0 @@ -221,7 +226,7 @@ class MasseSalariale(): masse_salariale = (salaire_base + total_indemnites + \ sum(primes.values()) + charges) - masse_salariale_euro = rh.Remuneration(montant=masse_salariale, + masse_salariale_euro = rh.Remuneration(montant=masse_salariale, devise=remuns[0].devise) self.convertir(masse_salariale_euro) diff --git a/project/rh/templates/rh/rapports/masse_salariale.html b/project/rh/templates/rh/rapports/masse_salariale.html new file mode 100644 index 0000000..90909cc --- /dev/null +++ b/project/rh/templates/rh/rapports/masse_salariale.html @@ -0,0 +1,27 @@ +{% extends 'rh/rapports/base.html' %} +{% load adminmedia rapports i18n %} + +{% block nomrapport %}Rapport Postes{% endblock %} +{% block count_elements %}

{{ count }} postes

{% endblock %} + +{% block contentrapport %} +
+

{% trans 'Filter' %}

+{% filter_region "dossier__poste__" %} +{% filter_implantation "dossier__poste__" %} +
+ + + + + {% table_header headers %} + + +{% spaceless %}{% for poste in rapport %} + + + +{% endfor %}{% endspaceless %} +
a
+ +{% endblock %} diff --git a/project/rh/templates/rh/rapports/remuneration.html b/project/rh/templates/rh/rapports/remuneration.html deleted file mode 100644 index 3ad5e08..0000000 --- a/project/rh/templates/rh/rapports/remuneration.html +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'rh/rapports/base.html' %} -{% load adminmedia rapports i18n %} - -{% block nomrapport %}Rapport de rémunération{% endblock %} - -{% block contentrapport %} - -
-

{% trans 'Filter' %}

-{% filter_region_remun %} -{% filter_implantation_remun %} -
- - - - - {% table_header headers %} - - -{% spaceless %}{% for employe in employes %} - - - - - - - - - - - -{% endfor %}{% endspaceless %} -
{{ employe.id }}{{ employe.nom|upper }}{{ employe.prenom }}{{ employe.Traitement|default:0|floatformat:2 }} €{{ employe.RAS|default:0|floatformat:2 }} €{{ employe.Indemnite|default:0|floatformat:2 }} €{{ employe.Accessoire|default:0|floatformat:2 }} €{{ employe.Charges|default:0|floatformat:2 }} €{{ employe.remun_sum_euro|default:0|floatformat:2 }} €
- -{% endblock %} diff --git a/project/rh/templatetags/rapports.py b/project/rh/templatetags/rapports.py index cc7f828..a2733b6 100644 --- a/project/rh/templatetags/rapports.py +++ b/project/rh/templatetags/rapports.py @@ -23,15 +23,19 @@ def filter_comble(context): @register.inclusion_tag('admin/filter.html', takes_context=True) -def filter_region(context): +def filter_region(context, prefix=None): + + label = "".join([prefix or "", "implantation__region"]) return {'title': u"région", - 'choices': prepare_choices(Region.objects.values_list('id', 'nom'), 'implantation__region', context, remove=['pays', 'nord_sud'])} + 'choices': prepare_choices(Region.objects.values_list('id', 'nom'), label, context, remove=['pays', 'nord_sud'])} @register.inclusion_tag('admin/filter.html', takes_context=True) -def filter_implantation(context): +def filter_implantation(context, prefix=None): + + label = "".join([prefix or "", "implantation"]) return {'title': u"implantation", - 'choices': prepare_choices(Implantation.objects.values_list('id', 'nom'), 'implantation', context)} + 'choices': prepare_choices(Implantation.objects.values_list('id', 'nom'), label, context)} @register.inclusion_tag('admin/filter.html', takes_context=True) diff --git a/project/rh/views.py b/project/rh/views.py index d4b8539..5f4a133 100644 --- a/project/rh/views.py +++ b/project/rh/views.py @@ -21,6 +21,7 @@ from rh.decorators import drh_or_admin_required from rh.templatetags.rapports import SortHeaders from rh.change_list import RechercheTemporelle from rh import graph as rh_graph +from rh.masse_salariale import MasseSalariale # pas de reference a DAE devrait etre refactorisé from dae.utils import get_employe_from_user @@ -196,7 +197,25 @@ def rapports_contrat(request): @login_required @drh_or_admin_required def rapports_masse_salariale(request): - pass + + date_debut = request.GET.get("date_debut", None) + date_fin = request.GET.get("date_fin", None) + + implantation = request.GET.get('dossier__poste__implantation') + region = request.GET.get('dossier__poste__implantation__region') + + custom_filter = {} + if implantation: + custom_filter['dossier__poste__implantation'] = implantation + if region: + custom_filter['dossier__poste__implantation__region'] = region + + masse = MasseSalariale(date_debut, date_fin, custom_filter) + c = { + 'headers': [], + 'rapport': masse.rapport, + } + return render_to_response('rh/rapports/masse_salariale.html', c, RequestContext(request)) @login_required -- 1.7.10.4