parent_model=dae.DossierComparaison,
model=dae.DossierComparaisonRemuneration,
)
-
+RHReadOnlyRemunFormSet = remun_formset_factory_factory(
+ read_only=True,
+ parent_model=rh.Dossier,
+ model=rh.Remuneration,
+ )
class PosteForm(filtered_archived_fields_form_factory(
'classement_min',
# -=- encoding: utf-8 -=-
import os
+from decimal import Decimal
from dateutil.relativedelta import relativedelta
from datetime import date, timedelta
# Managers
objects = PosteManager()
+ @property
+ def indemn_min_cad(self):
+ return ((self.indemn_expat_min or Decimal('0')) +
+ (self.indemn_fct_min or Decimal('0')))
+
+ @property
+ def indemn_max_cad(self):
+ return ((self.indemn_expat_max or Decimal('0')) +
+ (self.indemn_fct_max or Decimal('0')))
+
def _get_key(self):
"""
Les vues sont montées selon une clef spéciale
return dossier_rh
+ def get_dossier_precedent_titulaire(self):
+ try:
+ rh_poste = self.poste.id_rh
+ except rh.Poste.DoesNotExist:
+ return None
+
+ try:
+ precedent_employe = self.employe_anterieur
+ except rh.Employe.DoesNotExist:
+ return None
+
+ qs = rh.Dossier.objects.filter(
+ poste=rh_poste,
+ employe=precedent_employe,
+ ).order_by(
+ '-principal', 'date_fin')
+
+ if qs.count() == 0:
+ return None
+
+ # Retourne en le premier du queryset si la date de fin est None
+ # Sinon, retourne le plus récent selon la date de fin.
+ first = qs[0]
+ if first.date_fin == None:
+ return first
+ else:
+ return qs.order_by('-principal', '-date_fin')[0]
+
def get_salaire_anterieur_euros(self):
if self.devise_anterieur is None:
return None
+{% load dae %}
<fieldset>
<h2>Contrat</h2>
<table>
<h2>Classement et salaire de base</h2>
<h3>Ancien dossier <span class="info">(le cas échéant)</span></h3>
-{% if dossier.salaire_anterieur != None %}
+{% with dossier.employe.id_rh.get_latest_dossier_ordered_by_date_fin_and_principal as ancien_dossier %}
+{% if ancien_dossier %}
<table>
- <tbody>
- <tr>
- <td colspan="7">
- {{ dossier.employe }} <span class="info">{{ dossier.employe.id_rh.rh_dossiers.all.0.poste.type_poste.nom }} {{ dossier.employe.id_rh.dossier_set.all.0.complement1 }}</span>
- </td>
- </tr>
- <tr>
- <th>Classement antérieur</th>
- <th>Salaire antérieur</th>
- <th>Statut antérieur</th>
- <th>Type contrat</th>
- </tr>
- <tr>
- <td>{{ dossier.classement_anterieur|default:"" }}</td>
- <td class="montant">{{ dossier.salaire_anterieur|floatformat:0 }}
- {{ dossier.devise_anterieur.code }}
- {% if dossier.devise_anterieur %}
- ({{ dossier.get_salaire_anterieur_euros|floatformat:0 }}€)
- {% endif %}
- </td>
- <td>{{ dossier.statut_anterieur|default:"" }}</td>
- <td>{{ dossier.type_contrat_anterieur|default:"" }}</td>
- </tr>
- </tbody>
+ <tbody>
+ <tr>
+ <th>Classement</th>
+ <th>Statut</th>
+ <th>Implantation</th>
+ <th>Employé</th>
+ <th>Poste</th>
+ <th>Salaire</th>
+ <th>Salaire EUR</th>
+ </tr>
+ <tr class="gris-bkg">
+ <td>{{ ancien_dossier.classement|default:"" }}</td>
+ <td>{{ ancien_dossier.statut|default:"" }}</td>
+ <td>{{ ancien_dossier.poste.implantation }}</td>
+ <td>{{ dossier.employe }}</td>
+ <td>{{ ancien_dossier.poste.nom }}</td>
+ {% with ancien_dossier.get_salaire as salaire %}
+ <td>{{ salaire }}</td>
+ <td>{{ salaire.montant_euros_float|floatformat:2 }} EUR</td>
+ {% endwith %}
+ </tr>
+ {% if ancien_dossier and ancien_dossier.remunerations.all.count > 0 %}
+ <tr>
+ <td colspan="1">
+ Rémunérations
+ </td>
+ <td colspan="6">
+ {% rh_remun_form_for_year ancien_dossier %}
+ </td>
+ </tr>
+ {% endif %}
+ </tbody>
</table>
{% else %}
<p>Il n'y a pas d'ancien dossier pour cet employé</p>
{% endif %}
+{% endwith %}
<h3>Précédent titulaire <span class="info">(le cas échéant)</span></h3>
{% if dossier.classement_titulaire_anterieur %}
+{% with dossier.get_dossier_precedent_titulaire as precedent_titulaire %}
<table>
<tbody>
<tr>
- <td colspan="3">
+ <td colspan="7">
{{ dossier.employe_anterieur|default:"" }}
</td>
</tr>
<tr>
- <th>Classement du titulaire antérieur</th>
- <th>Salaire du titulaire antérieur</th>
- <th>Statut du titulaire antérieur</th>
+ <th>Classement</th>
+ <th>Statut</th>
+ <th>Implantation</th>
+ <th>Employé</th>
+ <th>Poste</th>
+ <th>Salaire</th>
+ <th>Salaire EUR</th>
+ </tr>
+ <tr>
+ <td>{{ precedent_titulaire.classement|default:"" }}</td>
+ <td>{{ precedent_titulaire.statut|default:"" }}</td>
+ <td>{{ precedent_titulaire.poste.implantation }}</td>
+ <td>{{ precedent_titulaire.employe }}</td>
+ <td>{{ precedent_titulaire.poste.nom }}</td>
+ {% with precedent_titulaire.get_salaire as salaire %}
+ <td>{{ salaire }}</td>
+ <td>{{ salaire.montant_euros_float|floatformat:2 }} EUR</td>
+ {% endwith %}
</tr>
+ {% if precedent_titulaire and precedent_titulaire.remunerations.all.count > 0 %}
<tr>
- <td>{{ dossier.classement_titulaire_anterieur|default:"" }}</td>
- <td class="montant">{{ dossier.salaire_titulaire_anterieur|floatformat:0 }}
- {% if dossier.devise_titulaire_anterieur %}
- {{ dossier.devise_titulaire_anterieur.code }}
- ({{ dossier.get_salaire_titulaire_anterieur_euros|floatformat:0 }}€)
- {% endif %}</td>
- <td>{{ dossier.statut_titulaire_anterieur|default:"" }}</td>
+ <td colspan="1">
+ Rémunérations
+ </td>
+ <td colspan="6">
+ {% rh_remun_form_for_year precedent_titulaire %}
+ </td>
</tr>
+ {% endif %}
</tbody>
<table>
+{% endwith %}
{% else %}
<p>Il n'y a pas de précédent titulaire</p>
{% endif %}
<tr>
<td>
<h4>{{ dossier.justif_nouveau_statut_label }}</h4>
- <p>{{ dossier.justif_nouveau_statut|default:"∅" }}
+ <p>{{ dossier.justif_nouveau_statut|default:"∅" }}
<h4>{{ dossier.justif_nouveau_tmp_remplacement_label }}</h4>
- <p>{{ dossier.justif_nouveau_tmp_remplacement|default:"∅" }}</p>
+ <p>{{ dossier.justif_nouveau_tmp_remplacement|default:"∅" }}</p>
<h4>{{ dossier.justif_nouveau_salaire_label }}</h4>
- <p>{{ dossier.justif_nouveau_salaire|default:"∅" }}</p>
+ <p>{{ dossier.justif_nouveau_salaire|default:"∅" }}</p>
<h4>{{ dossier.justif_nouveau_commentaire_label }}</h4>
- <p>{{ dossier.justif_nouveau_commentaire|default:"∅" }}</p>
+ <p>{{ dossier.justif_nouveau_commentaire|default:"∅" }}</p>
</td>
<td>
<h4>{{ dossier.justif_rempl_type_contrat_label }}</h4>
- <p>{{ dossier.justif_rempl_type_contrat|default:"∅"}}</p>
+ <p>{{ dossier.justif_rempl_type_contrat|default:"∅"}}</p>
<h4>{{ dossier.justif_rempl_statut_employe_label }}</h4>
- <p>{{ dossier.justif_rempl_statut_employe|default:"∅"}}</p>
+ <p>{{ dossier.justif_rempl_statut_employe|default:"∅"}}</p>
<h4>{{ dossier.justif_rempl_evaluation_label }}</h4>
- <p>{{ dossier.justif_rempl_evaluation|default:"∅"}}</p>
+ <p>{{ dossier.justif_rempl_evaluation|default:"∅"}}</p>
<h4>{{ dossier.justif_rempl_salaire_label }}</h4>
- <p>{{ dossier.justif_rempl_salaire|default:"∅" }}</p>
+ <p>{{ dossier.justif_rempl_salaire|default:"∅" }}</p>
<h4>{{ dossier.justif_rempl_commentaire_label }}</h4>
- <p>{{ dossier.justif_rempl_commentaire|default:"∅" }}</p>
+ <p>{{ dossier.justif_rempl_commentaire|default:"∅" }}</p>
</td>
</tr>
</table>
<th>Échelon AUF</th>
<td colspan="2">{{ poste.classement_min }}</td>
<td colspan="2">{{ poste.classement_max }}</td>
+ </tr>
+ <tr>
+ <th colspan="5">
+ Traitements
+ </th>
</tr>
<tr>
<td class="spaced" >Salaire de base</td>
</td>
</tr>
<tr>
+ <td class="spaced">Sous-total</td>
+ <td class="montant">
+ {{ poste.salaire_min|floatformat:0 }}
+ </td>
+ <td class="montant">
+ {{ poste.salaire_min|euros:poste.devise_min|floatformat:0 }}
+ </td>
+ <td class="montant">
+ {{ poste.salaire_max|floatformat:0 }}
+ </td>
+ <td class="montant">
+ {{ poste.salaire_max|euros:poste.devise_max|floatformat:0 }}
+ </td>
+ </tr>
+ <tr>
+ <th colspan="5">
+ Indemnités autres
+ </th>
+ </tr>
+ <tr>
<td class="spaced">Indem. d'expatriation</td>
<td class="montant">{{ poste.indemn_expat_min|floatformat:0 }}</td>
<td class="montant">{{ poste.indemn_expat_min|euros:poste.devise_min|floatformat:0 }}</td>
<td class="montant">{{ poste.indemn_fct_max|euros:poste.devise_max|floatformat:0 }}</td>
</tr>
<tr>
+ <td class="spaced">Sous-total</td>
+ <td class="montant">{{ poste.indemn_min_cad|floatformat:0 }}</td>
+ <td class="montant">{{ poste.indemn_min_cad|euros:poste.devise_min|floatformat:0 }}</td>
+ <td class="montant">{{ poste.indemn_max_cad|floatformat:0 }}</td>
+ <td class="montant">{{ poste.indemn_max_cad|euros:poste.devise_max|floatformat:0 }}</td>
+ </tr>
+ <tr>
+ <th colspan="5">
+ Charges patronales
+ </th>
+ </tr>
+ <tr>
<td class="spaced">Charges patronales</td>
<td class="montant">{{ poste.charges_patronales_min|floatformat:0 }}</td>
<td class="montant">{{ poste.charges_patronales_min|euros:poste.devise_min|floatformat:0 }}</td>
<td class="montant">{{ poste.charges_patronales_max|euros:poste.devise_max|floatformat:0 }}</td>
</tr>
<tr>
+ <td class="spaced">Sous-total</td>
+ <td class="montant">{{ poste.charges_patronales_min|floatformat:0 }}</td>
+ <td class="montant">{{ poste.charges_patronales_min|euros:poste.devise_min|floatformat:0 }}</td>
+ <td class="montant">{{ poste.charges_patronales_max|floatformat:0 }}</td>
+ <td class="montant">{{ poste.charges_patronales_max|euros:poste.devise_max|floatformat:0 }}</td>
+ </tr>
+ <tr>
+ <th colspan="5">
+ Autres
+ </th>
+ </tr>
+ <tr>
<td class="spaced">Autres</td>
<td class="montant">{{ poste.autre_min|floatformat:0 }}</td>
<td class="montant">{{ poste.autre_min|euros:poste.devise_min|floatformat:0 }}</td>
<td class="montant">{{ poste.autre_max|floatformat:0 }}</td>
<td class="montant">{{ poste.autre_max|euros:poste.devise_max|floatformat:0 }}</td>
</tr>
+ <tr>
+ <td class="spaced">Sous-total</td>
+ <td class="montant">{{ poste.autre_min|floatformat:0 }}</td>
+ <td class="montant">{{ poste.autre_min|euros:poste.devise_min|floatformat:0 }}</td>
+ <td class="montant">{{ poste.autre_max|floatformat:0 }}</td>
+ <td class="montant">{{ poste.autre_max|euros:poste.devise_max|floatformat:0 }}</td>
+ </tr>
<tr class="total-row" >
<th>TOTAL</th>
<td class="montant">{{ poste.get_couts_minimum|floatformat:0 }}</td>
ReadOnlyRemunFormSet,
PosteCompReadOnlyRemunFormSet,
DossierCompReadOnlyRemunFormSet,
+ RHReadOnlyRemunFormSet,
)
from project.dae import models as dae
from project.rh import models as rh
@register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
-def rh_remun_form_for_year(context, dossier, year):
+def rh_remun_form_for_year(context, dossier, year=None):
fs = remun_formset_factory_factory(
read_only=True,
model=rh.Remuneration,
)
- def _get_qs(inst):
+ def _get_qs(inst, year=year):
+
+ if year == None:
+ year = (
+ inst.instance.date_fin.year if
+ inst.instance.date_fin else
+ datetime.date.today().year)
+
year_start = datetime.date(year, 1, 1)
year_end = datetime.date(year, 12, 31)
qs = inst.model.objects.filter(
Q(date_debut__isnull=True, date_fin__isnull=True)
))
return qs
-
+
fs.get_queryset = _get_qs
return {
def __unicode__(self):
return u'%s %s [%s]' % (self.nom.upper(), self.prenom, self.id)
+ def get_latest_dossier_ordered_by_date_fin_and_principal(self):
+ res = self.rh_dossiers.order_by(
+ '-principal', 'date_fin')
+
+ # Retourne en le premier du queryset si la date de fin est None
+ # Sinon, retourne le plus récent selon la date de fin.
+ first = res[0]
+ if first.date_fin == None:
+ return first
+ else:
+ return res.order_by('-principal', '-date_fin')[0]
+
def civilite(self):
civilite = u''
if self.genre.upper() == u'M':