from django.core.files.storage import FileSystemStorage
from django.db import models
+from django.db.models import Q
from django.conf import settings
from auf.django.emploi.models import GENRE_CHOICES, SITUATION_CHOICES # devrait plutot être dans references
def remunerations(self):
- return self.rh_remunerations.all().order_by('date_debut')
+ key = "%s_remunerations" % self._meta.app_label
+ remunerations = getattr(self, key)
+ return remunerations.all().order_by('-date_debut')
def remunerations_en_cours(self):
- return self.rh_remunerations.all().filter(date_fin__exact=None).order_by('date_debut')
+ q = Q(date_fin__exact=None) | Q(date_fin__gt=datetime.date.today())
+ return self.remunerations().all().filter(q).order_by('date_debut')
def get_salaire(self):
try:
except:
return None
+ def get_salaire_euros(self):
+ tx = self.taux_devise()
+ return (float)(tx) * (float)(self.salaire)
+
+ def get_remunerations_brutes(self):
+ """
+ 1 Salaire de base
+ 3 Indemnité de base
+ 4 Indemnité d'expatriation
+ 5 Indemnité pour frais
+ 6 Indemnité de logement
+ 7 Indemnité de fonction
+ 8 Indemnité de responsabilité
+ 9 Indemnité de transport
+ 10 Indemnité compensatrice
+ 11 Indemnité de subsistance
+ 12 Indemnité différentielle
+ 13 Prime d'installation
+ 14 Billet d'avion
+ 15 Déménagement
+ 16 Indemnité de départ
+ 18 Prime de 13ième mois
+ 19 Prime d'intérim
+ """
+ ids = [1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19]
+ return [r for r in self.remunerations_en_cours().all() if r.type_id in ids]
+
+ def get_charges_salariales(self):
+ """
+ 20 Charges salariales ?
+ """
+ ids = [20, ]
+ return [r for r in self.remunerations_en_cours().all() if r.type_id in ids]
+
+ def get_total_charges_salariales(self):
+ total = 0.0
+ for r in self.get_charges_salariales():
+ total += r.montant_euros()
+ return total
+
+ def get_charges_patronales(self):
+ """
+ 17 Charges patronales
+ """
+ ids = [17, ]
+ return [r for r in self.remunerations_en_cours().all() if r.type_id in ids]
+
+ def get_total_charges_patronales(self):
+ total = 0.0
+ for r in self.get_charges_patronales():
+ total += r.montant_euros()
+ return total
+
+ def get_salaire_brut(self):
+ """
+ somme des rémuérations brutes
+ """
+ total = 0.0
+ for r in self.get_remunerations_brutes():
+ total += r.montant_euros()
+ return total
+
+ def get_salaire_net(self):
+ """
+ salaire brut - charges salariales
+ """
+ total_charges = 0.0
+ for r in self.get_charges_salariales():
+ total_charges += r.montant_euros()
+ return self.get_salaire_brut() - total_charges
+
+ def get_couts_auf(self):
+ """
+ salaire net + charges patronales
+ """
+ total_charges = 0.0
+ for r in self.get_charges_patronales():
+ total_charges += r.montant_euros()
+ return self.get_salaire_net() + total_charges
+
+ def get_remunerations_tierces(self):
+ """
+ 2 Salaire MAD
+ """
+ return [r for r in self.remunerations_en_cours().all() if r.type_id in (2, )]
+
+ def get_total_remunerations_tierces(self):
+ total = 0.0
+ for r in self.get_remunerations_tierces():
+ total += r.montant_euros()
+ return total
+
class Dossier(Dossier_):
__doc__ = Dossier_.__doc__