X-Git-Url: http://git.auf.org/?p=auf_rh_dae.git;a=blobdiff_plain;f=project%2Frh%2Fmodels.py;h=a5527b5b9f92ada9151bec0d3f1d3bdfb8d7829d;hp=ee41fc1442d48a8984b9de16663ca7f4648e8f2a;hb=838bc59d54d5f65ecc2a5cb4e789074e0f9ba764;hpb=71aec2c373b863afae294d831ccc549dec22c9ce diff --git a/project/rh/models.py b/project/rh/models.py index ee41fc1..a5527b5 100644 --- a/project/rh/models.py +++ b/project/rh/models.py @@ -6,6 +6,7 @@ from decimal import Decimal 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 @@ -659,10 +660,13 @@ class Dossier_(AUFMetadata, DevisableMixin): 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: @@ -670,6 +674,98 @@ class Dossier_(AUFMetadata, DevisableMixin): 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__