From: Nicolas Cadou Date: Wed, 9 Mar 2011 23:57:58 +0000 (-0500) Subject: Première passe aux modèles DAE X-Git-Tag: DAE~275 X-Git-Url: https://git.auf.org/?p=auf_rh_dae.git;a=commitdiff_plain;h=bd28238f1641cdd67dbf25cd4037529dcbd78e90 Première passe aux modèles DAE --- diff --git a/project/dae/models.py b/project/dae/models.py index 71a8362..cd10ea9 100644 --- a/project/dae/models.py +++ b/project/dae/models.py @@ -1,3 +1,255 @@ +# -=- encoding: utf-8 -=- from django.db import models -# Create your models here. +import datamaster_modeles.models as ref +import rh_v1.models as rh + + +STATUT_RESIDENCE_CHOICES = ( + ('local', 'local'), + ('expat', 'expatrié'), +) + +POSTE_APPEL_CHOICES = ( + ('interne', 'interne'), + ('externe', 'externe'), +) + +POSTE_STATUT_CHOICES = ( + ('MAD', 'Mise à disposition'), + ('DET', 'Détachement'), +) + + +class Poste(models.Model): + id = models.IntegerField(primary_key=True) + + # Modèle existant + id_rh = models.ForeignKey('rh.Poste', null=True) + nom = models.CharField(max_length=255) + implantation = models.ForeignKey('ref.Implantation') + type_poste = models.ForeignKey('rh.TypePoste', null=True) + service = models.ForeignKey('rh.Service') + responsable = models.ForeignKey('rh.Poste') + regime_travail = models.DecimalField(max_digit=12, decimal_places=2) + regime_complet_nb_heure_semaine = models.DecimalField(max_digit=12, + decimal_places=2) + regime_travail_nb_heure_semaine = models.DecimalField(max_digit=12, + decimal_places=2) + + # Recrutement + statut_residence = models.CharField(max_length=10, + choices=STATUT_RESIDENCE_CHOICES) + mise_a_disposition = models.BooleanField(null=True) + appel = models.CharField(max_length=10, choices=POSTE_APPEL_CHOICES) + + # Rémunération + classement_min = models.ForeignKey('rh.Classement') + classement_max = models.ForeignKey('rh.Classement') + valeur_point_min = models.ForeignKey('rh.ValeurPoint') + valeur_point_max = models.ForeignKey('rh.ValeurPoint') + salaire_min = models.DecimalField(max_digit=12, decimal_places=2) + salaire_max = models.DecimalField(max_digit=12, decimal_places=2) + indemn_min = models.DecimalField(max_digit=12, decimal_places=2) + indemn_max = models.DecimalField(max_digit=12, decimal_places=2) + autre_min = models.DecimalField(max_digit=12, decimal_places=2) + autre_max = models.DecimalField(max_digit=12, decimal_places=2) + postes_similaires = ManyToManyField('Poste') + + # Méta + date_creation = models.DateField() + date_modification = models.DateField(auto_now=True) + date_debut = models.DateField() + date_fin = models.DateField(null=True) + nb_mois = models.TimeField() + actif = models.BooleanField(default=True) + + def save(self, *args, **kwargs): + # calculate nb_mois = nb of months between date_debut and date_fin + from datetime import date + delta = self.date_fin - self.date_debut + nb_mois = delta.months + if not self.salaire_min: + self.salaire_min = self.classement_min * self.valeur_point_min + if not self.salaire_max: + self.salaire_max = self.classement_max * self.valeur_point_min + if not self.valeur_point_min: + self.valeur_point_min = \ + rh.ValeurPoint.objects.filter(implantation=self.implantation) + if not self.valeur_point_max: + self.valeur_point_max = \ + rh.ValeurPoint.objects.filter(implantation=self.implantation) + super(Subject, self).save(*args, **kwargs) + + +MIN_MAX_CHOICES = ( + ('min', 'minimum'), + ('max', 'maximum'), +) + + +TYPE_ORG_CHOICES = ( + ('locale_ent', 'minimum'), + ('university', 'université'), + ('government', 'fonction publique'), + ('ong', 'ONG'), + ('autre', 'autre'), +) + + +class PosteComparatifExterne(models.Model): + poste = models.ForeignKey('Poste') + montant = models.DecimalField(max_digit=12, decimal_places=2) + devise = models.ForeignKey('rh.Devise', default='EUR') + min_max = models.CharField(max_length=10, choices=MIN_MAX_CHOICES) + type_org = models.CharField(max_length=10, choices=TYPE_ORG_CHOICES) + + +class PosteFinancement(models.Model): + montant = models.DecimalField(max_digit=12, decimal_places=2) + poste = models.ForeignKey('Poste') + pourcentage = models.DecimalField(max_digit=12, decimal_places=2) + commentaire = models.TextField() + + +class PosteFinancementFraisPersonnel(models.Model): + source = models.ForeignKey('ref.LigneBudgetaire', null=True) + + +class PosteFinancementProjet(models.Model): + source = models.ForeignKey('ref.Project', null=True) + + +class PosteFinancementAutre(models.Model): + source = models.TextField() + + +GENRE_CHOICES = ( + ('m', 'masculin'), + ('f', 'féminin'), +) + + +class Employe(models.Model): + id = models.IntegerField(primary_key=True) + + # Modèle existant + id_rh = models.ForeignKey('rh.Employee', null=True) + nom = models.CharField(max_length=255) + prenom = models.CharField(max_length=255) + genre = models.CharField(max_length=1, + choices=GENRE_CHOICES, + null=True, + blank=True) + + +COMPTE_COMPTA_CHOICES = ( + ('coda', 'coda'), + ('scs', 'scs'), + ('aucun', 'aucun'), +) + + +class Dossier(models.Model): + statut_anterieur = models.ForeignKey('rh.Statut') + + # Modèle existant + poste = models.ForeignKey('Poste') + statut = models.ForeignKey('rh.Statut') + organisme_bstg = models.ForeignKey('rh.OrganismeBstg') + + # Recrutement + remplacement = models.BooleanField() + mobilite_interne = models.BooleanField() + statut_residence = models.CharField(max_length=10, + choices=STATUT_RESIDENCE_CHOICES) + + # Rémunération + classement = models.ForeignKey('rh.Classement', + verbose_name='Classement proposé') + salaire = models.DecimalField(max_digit=12, + decimal_places=2, + verbose_name='Salaire de base', + null=True, + default=None) + devise = models.ForeignKey('rh.Devise') + regime_travail = models.DecimalField(max_digit=12, decimal_places=2) + regime_travail_nb_heure_semaine = \ + models.DecimalField(max_digit=12, decimal_places=2) + + # Contrat + type_contrat = models.ForeignKey('rh.TypeContrat') + contrat_date_debut = models.DateField() + contrat_date_fin = models.DateField() + contrat_nb_mois = models.IntegerField() + + # Comptes + compte_compta = models.CharField(max_length=10, + choices=COMPTE_COMPTA_CHOICES) + compte_courriel = models.BooleanField() + + +class Remuneration(models.Model): + #Identification + id = models.IntegerField(primary_key=True) + dossier = models.ForeignKey('Dossier', db_column='dossier') + type = models.ForeignKey('TypeRemuneration', db_column='type') + type_revalorisation = models.ForeignKey('TypeRevalorisation', + db_column='type_revalorisation') + montant = models.DecimalField(max_digit=12, decimal_places=2) + devise = models.ForeignKey('rh.Devise', + to_field='code', + db_column='devise') + date_effective = models.DateField() + pourcentage = models.IntegerField() + + #Méta + date_creation = models.DateField(auto_now_add=True) + user_creation = models.IntegerField() + desactivation = models.BooleanField() + date_desactivation = models.DateField() + user_desactivation = models.IntegerField() + annule = models.BooleanField() + date_annule = models.DateField() + user_annule = models.IntegerField() + + +class JustificationPoste(models.Model): + pass + + +class JustificationEmploye(models.Model): + pass + + +class DocumentPoste(models.Model): + pass + + +class DocumentEmploye(models.Model): + pass + + +class Validation(models.Model): + # user + date = models.DateField() + + # avis = ? (CHOICES?) + + +class ValidationPoste(models.Model): + poste = models.ForeignKey('Poste') + + +class ValidationEmploye(models.Model): + employe = models.ForeignKey('Employe') + + +class TypeRemuneration(models.Model): + ordre = models.IntegerField() + groupe = models.ForeignKey('GroupeTypeRemuneration') + + +class GroupeTypeRemuneration(models.Model): + nom = models.CharField(max_length=255) + ordre = models.IntegerField()