From 65f9fac88d76550d6bc7ec6c0efde727a1f3dbc6 Mon Sep 17 00:00:00 2001 From: davin baragiotta Date: Fri, 12 Aug 2011 17:03:39 -0400 Subject: [PATCH] profil : ajout champs remun --- project/rh/models.py | 36 +++++++++++-- project/rh/templates/rh/profil.html | 96 ++++++++++++++++++++++++++++------- project/rh/views.py | 15 +----- 3 files changed, 112 insertions(+), 35 deletions(-) diff --git a/project/rh/models.py b/project/rh/models.py index 59196a2..18d2b48 100644 --- a/project/rh/models.py +++ b/project/rh/models.py @@ -366,7 +366,10 @@ class Employe(AUFMetadata): def dossiers_passes(self): today = date.today() - return self.dossiers.filter(date_fin__lt=today).order_by('-date_fin') + dossiers_passes = self.dossiers.filter(date_fin__lt=today).order_by('-date_fin') + for d in dossiers_passes: + d.archive = True + return dossiers_passes def dossiers_futurs(self): today = date.today() @@ -375,7 +378,12 @@ class Employe(AUFMetadata): def dossiers_encours(self): dossiers_p_f = self.dossiers_passes() | self.dossiers_futurs() ids_dossiers_p_f = [d.id for d in dossiers_p_f] - return self.dossiers.exclude(id__in=ids_dossiers_p_f).order_by('-date_fin') + dossiers_encours = self.dossiers.exclude(id__in=ids_dossiers_p_f).order_by('-date_fin') + + # TODO : supprimer ce code quand related_name fonctionnera ou d.remuneration_set + for d in dossiers_encours: + d.remunerations = Remuneration.objects.filter(dossier=d.id).order_by('-id') + return dossiers_encours def postes_encours(self): postes_encours = set() @@ -384,7 +392,17 @@ class Employe(AUFMetadata): return postes_encours def poste_principal(self): - return self.dossiers_encours()[0].poste + """ + Retourne le Poste du premier Dossier créé parmi les Dossiers en cours. + Idée derrière : + si on ajout d'autre Dossiers, c'est pour des Postes secondaires. + """ + poste = Poste.objects.none() + try: + poste = self.dossiers_encours().order_by('date_debut')[0].poste + except: + pass + return poste class EmployePiece(models.Model): """Documents relatifs à un employé. @@ -539,6 +557,16 @@ class Dossier_(AUFMetadata): verbose_name = "Dossier" verbose_name_plural = "Dossiers" + def salaire_theorique(self): + annee = date.today().year + coeff = self.classement.coefficient + implantation = self.poste.implantation + point = ValeurPoint.objects.get(implantation=implantation, annee=annee) + + montant = coeff * point.valeur + devise = point.devise + return {'montant':montant, 'devise':devise} + def __unicode__(self): poste = self.poste.nom if self.employe.genre == 'F': @@ -681,7 +709,7 @@ class Contrat(AUFMetadata): objects = ContratManager() dossier = models.ForeignKey('Dossier', db_column='dossier', - related_name='+') + related_name='contrats') type_contrat = models.ForeignKey('TypeContrat', db_column='type_contrat', related_name='+', verbose_name="Type de contrat") diff --git a/project/rh/templates/rh/profil.html b/project/rh/templates/rh/profil.html index 2699c9c..102dc76 100644 --- a/project/rh/templates/rh/profil.html +++ b/project/rh/templates/rh/profil.html @@ -23,11 +23,11 @@ Nationalité : - {{ employe.nationalite }} + {{ employe.nationalite.nom }} Situation familiale : - {{ employe.situation_familiale }} + {{ employe.get_situation_famille_display }} @@ -165,13 +165,33 @@
-

Dépendants (ayant-droits)

+

+ Dépendant{{ employe.ayantdroits.all|pluralize }} + (ayant{{ employe.ayantdroits.all|pluralize }}-droit) + ({{ employe.ayantdroits.count }}) +

{% if employe.ayantdroits.all %} - + + + + + + + + + + + + {% for personne in employe.ayantdroits.all %} + + + + + + + {% endfor %} + +
NomNationalitéDate de naissanceGenreLien de parenté
{{ personne.get_nom }}{{ personne.nationalite.nom }}{{ personne.date_naissance }}{{ personne.get_genre_display }}{{ personne.lien_parente }}
{% else %}

Aucun dépendant.

{% endif %} @@ -179,15 +199,10 @@
-

Poste{{ employe.dossiers_encours|pluralize }} en cours

+

Poste{{ employe.dossiers_encours|pluralize }} en cours ({{ employe.dossiers_encours.count }})

{% for d in employe.dossiers_encours %}

{{ d.poste.nom }}

-

- {{ d.poste.service }}
- {{ d.poste.implantation.nom }}
- {{ d.poste.implantation.adresse_physique_ville }} -

@@ -240,10 +255,57 @@

Rémunération

- {{ d.classement }}
+ + + + + + + +
Classification :{{ d.classement.type }}.{{ d.classement.echelon }}.{{ d.classement.degre }}Salaire de base théorique : + {{ d.salaire_theorique.montant }} {{ d.salaire_theorique.devise.code }} +
+ + + + + + + + + + + + + + + {% for r in d.remunerations %} + + + + + + + + + + + {% endfor %} + +
MontantDeviseTypeType revalorisationValide duauCommentaire
{{ r.id }}{{ r.montant|default_if_none:"?" }}{{ r.devise.code }}{{ r.type }}{{ r.type_revalorisation|default_if_none:"" }}{{ r.date_debut|default_if_none:"(inconnu)" }}{{ r.date_fin|default_if_none:"(indéterminé)" }}{{ r.commentaire|default_if_none:"" }}
-

Contrats

- {{ d.contrats }} +

Contrat{{ d.contrats|pluralize }} ({{ d.contrats.count }})

+ + {% for c in d.contrats.all %} + + + + + + + + {% endfor %} +
{{ c.type_contrat }}du{{ c.date_debut }}au{{ c.date_fin|default_if_none:"(non déterminé)" }}
{% endfor %}
diff --git a/project/rh/views.py b/project/rh/views.py index ec2245b..d623ef6 100644 --- a/project/rh/views.py +++ b/project/rh/views.py @@ -18,22 +18,9 @@ def profil(request): c = {} employe = rc['this_employe'] - - # dossiers en cours et passés - today = date.today() - dossiers = employe.dossiers.all().order_by('-date_fin') - dossiers_passes = dossiers.filter(date_fin__lt=today) - dossiers_futurs = dossiers.filter(date_debut__gt=today) - dossiers_p_f = dossiers_passes | dossiers_futurs - ids_dossiers_p_f = [d.id for d in dossiers_p_f] - dossiers_encours = dossiers.exclude(id__in=ids_dossiers_p_f) - - for d in dossiers_passes: - d.archive = True - + c['user'] = request.user c['employe'] = employe - c['dossiers'] = dossiers.count() return render_to_response('rh/profil.html', c, rc) # employes -- 1.7.10.4