+# -=- encoding: utf-8 -=-
+
from django.db import models
+from datamaster_modeles.models import Pays, Implantation
+
+GENRE_CHOICES = (
+ ('M', 'Homme'),
+ ('F', 'Femme'),
+)
+SITUATION_CHOICES = (
+ ('C', 'Célibataire'),
+ ('F', 'Fiancé'),
+ ('M', 'Marié'),
+)
+
+class Employe(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ prenom = models.CharField(max_length=255)
+ nationalite = models.ForeignKey('datamaster_modeles.Pays', to_field='code', related_name='nationalite', db_column='nationalite')
+ date_naissance = models.DateField(null=True, blank=True)
+ #Infos personnelles
+ genre = models.CharField(max_length=1, choices=GENRE_CHOICES, null=True, blank=True)
+ situation_famille = models.CharField(max_length=1, choices=SITUATION_CHOICES, null=True, blank=True)
+ date_entree = models.DateField(null=True, blank=True) #devrait pas être là
+ #Coordonnées
+ tel_domicile = models.CharField(max_length=255, null=True, blank=True)
+ tel_cellulaire = models.CharField(max_length=255, null=True, blank=True)
+ adresse = models.CharField(max_length=255, null=True, blank=True)
+ no_rue = models.CharField(max_length=255, null=True, blank=True)
+ ville = models.CharField(max_length=255, null=True, blank=True)
+ province = models.CharField(max_length=255, null=True, blank=True)
+ code_postal = models.CharField(max_length=255, null=True, blank=True)
+ pays = models.ForeignKey('datamaster_modeles.Pays', to_field='code', null=True, blank=True, related_name='pays', db_column='pays')
+ #Métas
+ date_creation = models.DateField(auto_now_add=True)
+ date_maj = models.DateField(auto_now=True)
+ commentaire = models.TextField(null=True, blank=True)
+
+TYPE_DOSSIER_CHOICES = (
+ ('2', 'Local'),
+ ('1', 'Expatrié'),
+)
+
+class Dossier(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ code = models.CharField(max_length=10, unique=True)
+ employe = models.ForeignKey('Employe', db_column='employe')
+ #Postes
+ poste1 = models.ForeignKey('Poste', db_column='poste1', related_name='poste1')
+ implantation1 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation1', related_name='implantation1')
+ complement1 = models.TextField(null=True, blank=True)
+ responsable_implantation1 = models.IntegerField()
+ poste2 = models.ForeignKey('Poste', db_column='poste2', related_name='poste2', blank=True, null=True)
+ implantation2 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation2', related_name='implantation2')
+ complement2 = models.TextField(null=True, blank=True)
+ responsable_implantation2 = models.IntegerField()
+ #Relations
+ service = models.ForeignKey('Service', db_column='service')
+ responsable = models.ForeignKey('Employe', db_column='responsable', related_name='responsable')
+ remplacement_de = models.ForeignKey('Employe', db_column='remplacement_de', related_name='remplacement_de')
+ type = models.CharField(max_length=1, choices=TYPE_DOSSIER_CHOICES)
+ statut = models.ForeignKey('Statut', db_column='statut')
+ organisme_bstg = models.ForeignKey('OrganismeBstg', db_column='organisme_bstg')
+ #Rémunération
+ classement = models.ForeignKey('Classement', db_column='classement')
+ regime_travail = models.IntegerField()
+ #Mandat
+ mandat_date_debut = models.DateField()
+ mandat_date_fin = models.DateField()
+ #Contrat
+ contrat_date_debut = models.DateField()
+ contrat_date_fin = models.DateField()
+ type_contrat = models.ForeignKey('TypeContrat', db_column='type_contrat')
+ #Meta
+ date_creation = models.DateField(auto_now_add=True)
+ date_maj = models.DateField(auto_now=True)
+ commentaire = models.TextField(null=True, blank=True)
+
+LIEN_PARENTE_CHOICES = (
+ ('Conjoint', 'Conjoint'),
+ ('Conjointe', 'Conjointe'),
+ ('Fille', 'Fille'),
+ ('Fils', 'Fils'),
+)
+
+class AyantDroit(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ prenom = models.CharField(max_length=255)
+ #Relation
+ employe = models.ForeignKey('Employe', db_column='employe', related_name='employe')
+ lien_parente = models.CharField(max_length=10, choices=LIEN_PARENTE_CHOICES, null=True, blank=True)
+ #Méta
+ commentaire = models.TextField(null=True, blank=True)
+ actif = 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.FloatField()
+ devise = models.ForeignKey('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() #User ou employé
+ desactivation = models.BooleanField() #
+ date_desactivation = models.DateField()
+ user_desactivation = models.IntegerField() #User ou employé
+ annule = models.BooleanField()
+ date_annule = models.DateField()
+ user_annule = models.IntegerField() #User ou employé
+
+class FamilleEmploi(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ #Méta
+ actif = models.BooleanField()
+
+class TypePoste(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ nom_feminin = models.CharField(max_length=255)
+ description = models.CharField(max_length=255)
+ is_responsable = models.BooleanField()
+ famille_emploi = models.ForeignKey('FamilleEmploi', db_column='famille_emploi')
+ #Méta
+ date_modification = models.DateField(auto_now=True)
+ actif = models.BooleanField()
+
+ def __unicode__(self):
+ return u'%s' % self.nom
+
+
+TYPE_PAIEMENT_CHOICES = (
+ ('Régulier', 'Régulier'),
+ ('Ponctuel', 'Ponctuel'),
+)
+
+NATURE_REMUNERATION_CHOICES = (
+ ('Accessoire', 'Accessoire'),
+ ('Charges', 'Charges'),
+ ('Indemnité', 'Indemnité'),
+ ('RAS', 'RAS'),
+ ('Traitement', 'Traitement'),
+)
+
+class TypeRemuneration(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ type_paiement = models.CharField(max_length=30, choices=TYPE_PAIEMENT_CHOICES)
+ nature_remuneration = models.CharField(max_length=30, choices=NATURE_REMUNERATION_CHOICES)
+ #Méta
+ actif = models.BooleanField()
+
+class TypeRevalorisation(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ #Méta
+ actif = models.BooleanField()
+
+PROPORTION_CHOICES = (
+ ('0.5', '0.5'),
+ ('1', '1'),
+)
+
+class Poste(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ implantation = models.ForeignKey('datamaster_modeles.Implantation',
+ db_column='implantation', related_name='+')
+ type_poste = models.ForeignKey('TypePoste', db_column='type_poste')
+ proportion = models.CharField(max_length=10, choices=PROPORTION_CHOICES)
+ #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%)
+ #Méta
+ date_modification = models.DateField(auto_now=True)
+ actif = models.BooleanField()
+
+ def __unicode__(self):
+ return u'%s - %s' % (self.implantation, self.type_poste.nom)
+
+
+class Service(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ #Méta
+ actif = models.BooleanField()
+
+ def __unicode__(self):
+ return u'%s' % self.nom
+
+
+TYPE_ORGANISME_CHOICES = (
+ ('MAD', 'Mise à disposition'),
+ ('DET', 'Détachement'),
+)
+
+class OrganismeBstg(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ type = models.CharField(max_length=10, choices=TYPE_ORGANISME_CHOICES)
+ #Méta
+ actif = models.BooleanField()
+
+CONTRAT_CATEGORIE_CHOICES= (
+ ('A', 'A'),
+ ('C', 'C'),
+)
+class Statut(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ code = models.CharField(max_length=25, unique=True)
+ nom = models.CharField(max_length=255)
+ type_contrat_categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES)
+ #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie
+ #Méta
+ actif = models.BooleanField()
+
+TYPE_CLASSEMENT_CHOICES = (
+ ('S', 'S'),
+ ('T', 'T'),
+)
+class Classement(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ type = models.CharField(max_length=10, choices=TYPE_CLASSEMENT_CHOICES)
+ echelon = models.IntegerField()
+ degre = models.IntegerField()
+ coefficient = models.FloatField()
+ #Méta
+ commentaire = models.TextField(null=True, blank=True)
+ date_modification = models.DateField(auto_now=True)
+ actif = models.BooleanField()
+
+ def __unicode__(self):
+ return u'%s.%s.%s (%s)' % (self.type, self.echelon, self.degre,
+ self.coefficient)
+
+
+class ValeurPoint(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ valeur = models.FloatField()
+ implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation')
+ #Méta
+ annee = models.IntegerField()
+
+ def __unicode__(self):
+ return u'%s (%s-%s)' % (self.valeur, self.implantation_id, self.annee)
+
+
+class TauxChange(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ devise = models.ForeignKey('Devise', to_field='code', db_column='devise')
+ annee = models.IntegerField()
+ taux = models.FloatField()
+ #Relations
+ implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation')
+
+
+class Devise(models.Model):
+ id = models.IntegerField(primary_key=True)
+ code = models.CharField(max_length=10, unique=True)
+ nom = models.CharField(max_length=255)
+
+ def __unicode__(self):
+ return u'%s - %s' % (self.code, self.nom)
+
+
+class TypeContrat(models.Model):
+ #Identification
+ id = models.IntegerField(primary_key=True)
+ nom = models.CharField(max_length=255)
+ nom_long = models.CharField(max_length=255) #description
+ categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES)
+ #Méta
+ actif = models.BooleanField()
-# Create your models here.