Masse salariale, fin de journée
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 14 Mar 2012 21:29:29 +0000 (16:29 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 14 Mar 2012 21:29:29 +0000 (16:29 -0500)
project/rh/masse_salariale.py

index 974c5cc..9e1ba89 100644 (file)
@@ -15,14 +15,18 @@ KEY_DATE_FIN = "fin"
 TYPE_REMUN_BSTG = (3,)
 TYPE_REMUN_MAD = (2,)
 TYPE_REMUN_BASE = (1,)
-TYPE_REMUN_FONC_RESP = (7,8)
+TYPE_REMUN_FONC_RESP = (7, 8)
 TYPE_REMUN_EXPAT = (4,)
 TYPE_REMUN_LOGEMENT = (6,)
 TYPE_REMUN_TRANSP = (9,)
 TYPE_REMUN_13E = (18,)
-TYPE_REMUN_AUTRE_RECURR_NOT = (1,2,3,4,6,7,8,9,18,13,14,15,19)
+TYPE_REMUN_AUTRE_RECURR_NOT = (1, 2, 3, 4, 6, 7, 8, 9, 18, 13, 14, 15, 19)
 TYPE_PAIEMENT_PONCTUEL = u"Ponctuel"
-
+TYPE_PRIME_INTERIM = (19,)
+TYPE_PRIME_INSTALLATION = (13,)
+TYPE_PRIME_DEMENAG = (15,)
+TYPE_PRIME_AVION = (14,)
+TYPE_NATURE_PAIEMENT = u"Accessoire" 
 
 class MasseSalariale():
     """ Rapport de la masse salariale. """
@@ -47,7 +51,7 @@ class MasseSalariale():
         remunerations = rh.Remuneration.objects.filter(q_range) \
                 .filter(q_range_d) \
                 .exclude(supprime=True) \
-                .select_related("dossier", "dossier_employe", "dossier_poste")
+                .select_related("dossier", "dossier_employe", "dossier_poste", "type")
 
         employes = {}
         for r in remunerations:
@@ -77,7 +81,7 @@ class MasseSalariale():
                 #TODO
                 pass
             dossier = list(dossiers)[0]
-            regime = dossier.poste.regime_travail
+            regime = float(dossier.poste.regime_travail) / 100
 
             if dossier.poste.expatrie:
                 statut = "E"
@@ -131,33 +135,58 @@ class MasseSalariale():
                     '13e': 0.0,
                     'autre_recurr': 0.0,
             }
+
+            primes = {
+                    'interim': 0.0,
+                    'installation': 0.0,
+                    'demenagement': 0.0,
+                    'avion': 0.0,
+                    'autre': 0.0,
+                }
             for r in remuns:
                 montant = float(r.montant)
-                if r.type in TYPE_REMUN_MAD:
+
+                if r.type_id in TYPE_REMUN_MAD:
                     salaire_complement += montant
 
-                if r.type in TYPE_REMUN_BASE:
+                if r.type_id in TYPE_REMUN_BASE:
                     salaire_base += montant
 
-                if r.type in TYPE_REMUN_FONC_RESP:
+                if r.type_id in TYPE_REMUN_FONC_RESP:
                     indemnites['fonc_resp'] += montant
 
-                if r.type in TYPE_REMUN_EXPAT:
+                if r.type_id in TYPE_REMUN_EXPAT:
                     indemnites['expat'] += montant
 
-                if r.type in TYPE_REMUN_LOGEMENT:
+                if r.type_id in TYPE_REMUN_LOGEMENT:
                     indemnites['logement'] += montant
 
-                if r.type in TYPE_REMUN_TRANSP:
+                if r.type_id in TYPE_REMUN_TRANSP:
                     indemnites['transp'] += montant
 
-                if r.type in TYPE_REMUN_13E:
+                if r.type_id in TYPE_REMUN_13E:
                     indemnites['13e'] += montant
 
-                if r.type not in TYPE_REMUN_AUTRE_RECURR_NOT \
+                if r.type_id not in TYPE_REMUN_AUTRE_RECURR_NOT \
                         and r.type.type_paiement != TYPE_PAIEMENT_PONCTUEL:
                     indemnites['autre_recurr'] += montant
 
+                if r.type_id in TYPE_PRIME_INTERIM:
+                    primes['interim'] += montant
+
+                if r.type_id in TYPE_PRIME_INSTALLATION:
+                    primes['installation'] += montant
+
+                if r.type_id in TYPE_PRIME_DEMENAG:
+                    primes['demenagement'] += montant
+
+                if r.type_id in TYPE_PRIME_AVION:
+                    primes['avion'] += montant
+
+                if r.type_id not in TYPE_REMUN_AUTRE_RECURR_NOT and \
+                        r.type.nature_remuneration == TYPE_NATURE_PAIEMENT:
+                    primes['autre'] += montant
+
             total_indemnites = sum(indemnites.values())
 
             #Calcul du nombre de jours pour ce dossier.
@@ -194,7 +223,7 @@ class MasseSalariale():
                                     if dossier.classement and
                                         dossier.classement.coefficient
                                     else "",
-                    'regime_de_travail': "%s %%" % regime,
+                    'regime_de_travail': "%s %%" % int(regime * 100),
                     'local_expatrie': statut,
                     'statut': dossier.statut.code,
                     'date_fin_contrat': dossier.date_fin,
@@ -210,9 +239,47 @@ class MasseSalariale():
                             if bstg_remun else None,
                     'organisme_bstg': dossier.organisme_bstg,
                     'salaire_base_brut': \
-                            salaire_base * regime * date_delta.days
-                    'salaire_
-                    }
+                            salaire_base * regime * (
+                                date_delta.days / rapport_date_delta.days
+                            ),
+                    'salaire_complementaire': \
+                            salaire_complement * regime * (
+                                date_delta.days / rapport_date_delta.days
+                            ),
+                    #'salaire_total': None
+                    'indemnite_fonctions': indemnites['fonc_resp'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnite_expat': indemnites['expat'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnite_logement': indemnites['logement'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnites_transp': indemnites['transp'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnites_13e': indemnites['13e'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnites_autre': indemnites['autre_recurr'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'indemnites_total': total_indemnites * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'total_brut': (
+                                total_indemnites + salaire_base +
+                                salaire_complement
+                            ) * regime * (
+                                date_delta.days / rapport_date_delta.days
+                            ),
+                    'prime_interim': primes['interim'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'prime_installation': primes['installation'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'prime_demenagement': primes['demenagement'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'prime_avion': primes['avion'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'prime_autre': primes['autre'] * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                    'prime_total': sum(primes.values()) * regime * \
+                            (date_delta.days / rapport_date_delta.days),
+                }
 
             self.rapport.append(item_rapport)