+# -=- encoding: utf-8 -=-
from django.db import models
-# Create your models here.
+import datamaster_modeles.models as ref
+import project.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):
+ # Modèle existant
+ id_rh = models.ForeignKey(rh.Poste, null=True, related_name='+',
+ editable=False)
+ nom = models.CharField(max_length=255)
+ implantation = models.ForeignKey(ref.Implantation)
+ type_poste = models.ForeignKey(rh.TypePoste, null=True, related_name='+')
+ service = models.ForeignKey(rh.Service, related_name='+')
+ responsable = models.ForeignKey(rh.Poste, related_name='+')
+ regime_travail = models.DecimalField(max_digits=12, decimal_places=2,
+ default=100)
+ regime_travail_nb_heure_semaine = models.DecimalField(max_digits=12,
+ decimal_places=2,
+ default=40)
+
+ # Recrutement
+ statut_residence = models.CharField(max_length=10, default='MAD',
+ choices=STATUT_RESIDENCE_CHOICES)
+ # TODO null?
+ mise_a_disposition = models.BooleanField()
+ appel = models.CharField(max_length=10, default='interne',
+ choices=POSTE_APPEL_CHOICES)
+
+ # Rémunération
+ classement_min = models.ForeignKey(rh.Classement, related_name='+')
+ classement_max = models.ForeignKey(rh.Classement, related_name='+')
+ valeur_point_min = models.ForeignKey(rh.ValeurPoint, related_name='+')
+ valeur_point_max = models.ForeignKey(rh.ValeurPoint, related_name='+')
+ salaire_min = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+ salaire_max = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+ indemn_min = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+ indemn_max = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+ autre_min = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+ autre_max = models.DecimalField(max_digits=12, decimal_places=2,
+ default=0)
+
+ # Comparatifs de rémunération
+ devise_comparaison = models.ForeignKey(rh.Devise, related_name='+',
+ null=True, blank=True)
+ comp_locale_min = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_locale_max = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_universite_min = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_universite_max = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_fonctionpub_min = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_fonctionpub_max = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_ong_min = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_ong_max = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_autre_min = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+ comp_autre_max = models.DecimalField(max_digits=12, decimal_places=2,
+ null=True, blank=True)
+
+ # Méta
+ date_creation = models.DateTimeField(auto_now_add=True)
+ date_modification = models.DateTimeField(auto_now=True)
+ date_debut = models.DateField()
+ date_fin = models.DateField(null=True)
+ actif = models.BooleanField(default=True)
+
+ def __unicode__(self):
+ return u'%s - %s (%s)' % (self.implantation, self.type_poste.nom,
+ self.nom)
+
+ def DISABLED_save(self, *args, **kwargs):
+ # calculate nb_mois = nb of months between date_debut and date_fin
+ from datetime import date
+ 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)
+
+
+POSTE_FINANCEMENT_CHOICES = (
+ ('A', 'A - Frais de personnel'),
+ ('B', 'B - Projet(s)-Titre(s)'),
+ ('C', 'C - Autre')
+)
+
+
+class PosteFinancement(models.Model):
+ montant = models.DecimalField(max_digits=12, decimal_places=2)
+ poste = models.ForeignKey('Poste', related_name='financements')
+ type = models.CharField(max_length=1, choices=POSTE_FINANCEMENT_CHOICES)
+ pourcentage = models.DecimalField(max_digits=12, decimal_places=2)
+ commentaire = models.TextField()
+
+
+GENRE_CHOICES = (
+ ('M', 'Homme'),
+ ('F', 'Femme'),
+)
+
+
+class Employe(models.Model):
+ id = models.IntegerField(primary_key=True)
+
+ # Modèle existant
+ id_rh = models.ForeignKey(rh.Employe, null=True, related_name='+')
+ 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):
+
+ # Modèle existant
+ employe = models.ForeignKey('Employe', related_name='+')
+ poste = models.ForeignKey('Poste', related_name='+')
+ statut = models.ForeignKey(rh.Statut, related_name='+')
+ organisme_bstg = models.ForeignKey(rh.OrganismeBstg, related_name='+')
+
+ # Données antérieures
+ employe_anterieur = models.ForeignKey('Employe', related_name='+')
+ statut_anterieur = models.ForeignKey(rh.Statut, related_name='+')
+ classement_anterieur = models.ForeignKey(rh.Classement, related_name='+',
+ verbose_name='Classement proposé')
+ salaire_anterieur = models.DecimalField(max_digits=12, decimal_places=2,
+ verbose_name='Salaire de base',
+ null=True, default=None)
+
+ # Recrutement
+ remplacement = models.BooleanField()
+ statut_residence = models.CharField(max_length=10,
+ choices=STATUT_RESIDENCE_CHOICES)
+
+ # Rémunération
+ classement = models.ForeignKey(rh.Classement, related_name='+',
+ verbose_name='Classement proposé')
+ salaire = models.DecimalField(max_digits=12, decimal_places=2,
+ verbose_name='Salaire de base',
+ null=True, default=None)
+ devise = models.ForeignKey(rh.Devise, related_name='+')
+ regime_travail = models.DecimalField(max_digits=12, decimal_places=2)
+ regime_travail_nb_heure_semaine = \
+ models.DecimalField(max_digits=12, decimal_places=2)
+
+ # Contrat
+ type_contrat = models.ForeignKey(rh.TypeContrat, related_name='+')
+ contrat_date_debut = models.DateField()
+ contrat_date_fin = models.DateField()
+
+ # 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')
+ # TODO: what's that?
+ # type_revalorisation = models.ForeignKey('TypeRevalorisation',
+ # db_column='type_revalorisation')
+ montant = models.DecimalField(max_digits=12, decimal_places=2) # Annuel
+ devise = models.ForeignKey(rh.Devise, to_field='code',
+ db_column='devise', related_name='+')
+ date_effective = models.DateField(null=True, blank=True)
+ pourcentage = models.IntegerField(null=True, blank=True)
+
+ # Méta
+ date_creation = models.DateField(auto_now_add=True)
+ user_creation = models.IntegerField(null=True, blank=True)
+ desactivation = models.BooleanField(null=True, blank=True)
+ date_desactivation = models.DateField(null=True, blank=True)
+ user_desactivation = models.IntegerField(null=True, blank=True)
+ annule = models.BooleanField(null=True, blank=True)
+ date_annule = models.DateField(null=True, blank=True)
+ user_annule = models.IntegerField(null=True, blank=True)
+
+
+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()