X-Git-Url: http://git.auf.org/?p=auf_rh_dae.git;a=blobdiff_plain;f=project%2Frh%2Fmodels.py;h=d9db8219504d033cca1dcf708c378f70f9673b34;hp=e991319f295e5d154b56b3be8dfe2d36daae472c;hb=1d0f4eef756d50da91fff69ee31a15217423240e;hpb=dc4b78a73c70f69ea4c6054eb32e0d3abe48cccc diff --git a/project/rh/models.py b/project/rh/models.py index e991319..d9db821 100644 --- a/project/rh/models.py +++ b/project/rh/models.py @@ -264,7 +264,16 @@ class PosteComparaison(models.Model): nom = models.CharField(verbose_name="Poste", max_length=255, null=True, blank=True) montant = models.IntegerField(null=True) devise = models.ForeignKey("Devise", default=5, related_name='+', null=True, blank=True) - montant_euros = models.IntegerField(null=True) + + def taux_devise(self): + liste_taux = self.devise.tauxchange_set.order_by('-annee').filter(implantation=self.implantation) + if len(liste_taux) == 0: + raise Exception(u"La devise %s n'a pas de taux pour l'implantation %s" % (self.devise, self.implantation)) + else: + return liste_taux[0].taux + + def montant_euros(self): + return round(float(self.montant) * float(self.taux_devise()), 2) class PosteCommentaire(Commentaire): @@ -528,6 +537,27 @@ class DossierCommentaire(Commentaire): dossier = models.ForeignKey('Dossier', db_column='dossier', related_name='+') +class DossierComparaison(models.Model): + """ + Photo d'une comparaison salariale au moment de l'embauche. + """ + dossier = models.ForeignKey('Dossier', related_name='comparaisons') + implantation = models.ForeignKey(ref.Implantation, null=True, blank=True) + poste = models.CharField(max_length=255, null=True, blank=True) + personne = models.CharField(max_length=255, null=True, blank=True) + montant = models.IntegerField(null=True) + devise = models.ForeignKey(rh.Devise, default=5, related_name='+', null=True, blank=True) + + def taux_devise(self): + liste_taux = self.devise.tauxchange_set.order_by('-annee').filter(implantation=self.dossier.poste.implantation) + if len(liste_taux) == 0: + raise Exception(u"La devise %s n'a pas de taux pour l'implantation %s" % (self.devise, self.dossier.poste.implantation)) + else: + return liste_taux[0].taux + + def montant_euros(self): + return round(float(self.montant) * float(self.taux_devise()), 2) + ### RÉMUNÉRATION