début du formulaire d'autorisation d'embauche
[auf_rh_dae.git] / project / rh_v1 / models.py
1 # -=- encoding: utf-8 -=-
2
3 from django.db import models
4 from datamaster_modeles.models import Pays, Implantation
5
6 GENRE_CHOICES = (
7 ('m', 'Homme'),
8 ('f', 'Femme'),
9 )
10 SITUATION_CHOICES = (
11 ('C', 'Célibataire'),
12 ('F', 'Fiancé'),
13 ('M', 'Marié'),
14 )
15
16 class Employe(models.Model):
17 #Identification
18 id = models.IntegerField(primary_key=True)
19 nom = models.CharField(max_length=255)
20 prenom = models.CharField(max_length=255)
21 nationalite = models.ForeignKey('datamaster_modeles.Pays', to_field='code', related_name='nationalite', db_column='nationalite')
22 date_naissance = models.DateField(null=True, blank=True)
23 #Infos personnelles
24 genre = models.CharField(max_length=1, choices=GENRE_CHOICES, null=True, blank=True)
25 situation_famille = models.CharField(max_length=1, choices=SITUATION_CHOICES, null=True, blank=True)
26 date_entree = models.DateField(null=True, blank=True) #devrait pas être là
27 #Coordonnées
28 tel_domicile = models.CharField(max_length=255, null=True, blank=True)
29 tel_cellulaire = models.CharField(max_length=255, null=True, blank=True)
30 adresse = models.CharField(max_length=255, null=True, blank=True)
31 no_rue = models.CharField(max_length=255, null=True, blank=True)
32 ville = models.CharField(max_length=255, null=True, blank=True)
33 province = models.CharField(max_length=255, null=True, blank=True)
34 code_postal = models.CharField(max_length=255, null=True, blank=True)
35 pays = models.ForeignKey('datamaster_modeles.Pays', to_field='code', null=True, blank=True, related_name='pays', db_column='pays')
36 #Métas
37 date_creation = models.DateField(auto_now_add=True)
38 date_maj = models.DateField(auto_now=True)
39 commentaire = models.TextField(null=True, blank=True)
40
41 def __unicode__(self):
42 return u'%s %s' % (self.prenom, self.nom)
43
44
45 TYPE_DOSSIER_CHOICES = (
46 ('2', 'Local'),
47 ('1', 'Expatrié'),
48 )
49
50 class Dossier(models.Model):
51 #Identification
52 id = models.IntegerField(primary_key=True)
53 code = models.CharField(max_length=10, unique=True)
54 employe = models.ForeignKey('Employe', db_column='employe')
55 #Postes
56 poste1 = models.ForeignKey('Poste', db_column='poste1', related_name='poste1')
57 implantation1 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation1', related_name='implantation1')
58 complement1 = models.TextField(null=True, blank=True)
59 responsable_implantation1 = models.IntegerField()
60 poste2 = models.ForeignKey('Poste', db_column='poste2', related_name='poste2', blank=True, null=True)
61 implantation2 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation2', related_name='implantation2')
62 complement2 = models.TextField(null=True, blank=True)
63 responsable_implantation2 = models.IntegerField()
64 #Relations
65 service = models.ForeignKey('Service', db_column='service')
66 responsable = models.ForeignKey('Employe', db_column='responsable', related_name='responsable')
67 remplacement_de = models.ForeignKey('Employe', db_column='remplacement_de', related_name='remplacement_de')
68 type = models.CharField(max_length=1, choices=TYPE_DOSSIER_CHOICES)
69 statut = models.ForeignKey('Statut', db_column='statut')
70 organisme_bstg = models.ForeignKey('OrganismeBstg', db_column='organisme_bstg')
71 #Rémunération
72 classement = models.ForeignKey('Classement', db_column='classement')
73 regime_travail = models.IntegerField()
74 #Mandat
75 mandat_date_debut = models.DateField()
76 mandat_date_fin = models.DateField()
77 #Contrat
78 contrat_date_debut = models.DateField()
79 contrat_date_fin = models.DateField()
80 type_contrat = models.ForeignKey('TypeContrat', db_column='type_contrat')
81 #Meta
82 date_creation = models.DateField(auto_now_add=True)
83 date_maj = models.DateField(auto_now=True)
84 commentaire = models.TextField(null=True, blank=True)
85
86 LIEN_PARENTE_CHOICES = (
87 ('Conjoint', 'Conjoint'),
88 ('Conjointe', 'Conjointe'),
89 ('Fille', 'Fille'),
90 ('Fils', 'Fils'),
91 )
92
93 class AyantDroit(models.Model):
94 #Identification
95 id = models.IntegerField(primary_key=True)
96 nom = models.CharField(max_length=255)
97 prenom = models.CharField(max_length=255)
98 #Relation
99 employe = models.ForeignKey('Employe', db_column='employe', related_name='employe')
100 lien_parente = models.CharField(max_length=10, choices=LIEN_PARENTE_CHOICES, null=True, blank=True)
101 #Méta
102 commentaire = models.TextField(null=True, blank=True)
103 actif = models.BooleanField()
104
105
106 class Remuneration(models.Model):
107 #Identification
108 id = models.IntegerField(primary_key=True)
109 dossier = models.ForeignKey('Dossier', db_column='dossier')
110 type = models.ForeignKey('TypeRemuneration', db_column='type')
111 type_revalorisation = models.ForeignKey('TypeRevalorisation', db_column='type_revalorisation', null=True, blank=True)
112 montant = models.FloatField(null=True, blank=True)
113 devise = models.ForeignKey('Devise', to_field='code', db_column='devise', null=True, blank=True)
114 date_effective = models.DateField(null=True, blank=True)
115 pourcentage = models.IntegerField(null=True, blank=True)
116 #Méta
117 date_creation = models.DateField(auto_now_add=True)
118 user_creation = models.IntegerField(null=True, blank=True) #User ou employé
119 desactivation = models.NullBooleanField(null=True, blank=True) #
120 date_desactivation = models.DateField(null=True, blank=True)
121 user_desactivation = models.IntegerField(null=True, blank=True) #User ou employé
122 annulation = models.NullBooleanField(null=True, blank=True)
123 date_annulation = models.DateField(null=True, blank=True)
124 user_annulation = models.IntegerField(null=True, blank=True) #User ou employé
125
126 class FamilleEmploi(models.Model):
127 #Identification
128 id = models.IntegerField(primary_key=True)
129 nom = models.CharField(max_length=255)
130 #Méta
131 actif = models.BooleanField()
132
133 class TypePoste(models.Model):
134 #Identification
135 id = models.IntegerField(primary_key=True)
136 nom = models.CharField(max_length=255)
137 nom_feminin = models.CharField(max_length=255)
138 description = models.CharField(max_length=255)
139 is_responsable = models.BooleanField()
140 famille_emploi = models.ForeignKey('FamilleEmploi', db_column='famille_emploi')
141 #Méta
142 date_modification = models.DateField(auto_now=True)
143 actif = models.BooleanField()
144
145 def __unicode__(self):
146 return u'%s' % self.nom
147
148
149 TYPE_PAIEMENT_CHOICES = (
150 ('Régulier', 'Régulier'),
151 ('Ponctuel', 'Ponctuel'),
152 )
153
154 NATURE_REMUNERATION_CHOICES = (
155 ('Accessoire', 'Accessoire'),
156 ('Charges', 'Charges'),
157 ('Indemnité', 'Indemnité'),
158 ('RAS', 'RAS'),
159 ('Traitement', 'Traitement'),
160 )
161
162 class TypeRemuneration(models.Model):
163 #Identification
164 id = models.IntegerField(primary_key=True)
165 nom = models.CharField(max_length=255)
166 type_paiement = models.CharField(max_length=30, choices=TYPE_PAIEMENT_CHOICES)
167 nature_remuneration = models.CharField(max_length=30, choices=NATURE_REMUNERATION_CHOICES)
168 #Méta
169 actif = models.BooleanField()
170
171 class TypeRevalorisation(models.Model):
172 #Identification
173 id = models.IntegerField(primary_key=True)
174 nom = models.CharField(max_length=255)
175 #Méta
176 actif = models.BooleanField()
177
178 PROPORTION_CHOICES = (
179 ('0.5', '0.5'),
180 ('1', '1'),
181 )
182
183 class Poste(models.Model):
184 #Identification
185 id = models.IntegerField(primary_key=True)
186 implantation = models.ForeignKey('datamaster_modeles.Implantation',
187 db_column='implantation', related_name='+')
188 type_poste = models.ForeignKey('TypePoste', db_column='type_poste')
189 proportion = models.CharField(max_length=10, choices=PROPORTION_CHOICES)
190 #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%)
191 #Méta
192 date_modification = models.DateField(auto_now=True)
193 actif = models.BooleanField()
194
195 def __unicode__(self):
196 return u'%s - %s' % (self.implantation, self.type_poste.nom)
197
198
199 class Service(models.Model):
200 #Identification
201 id = models.IntegerField(primary_key=True)
202 nom = models.CharField(max_length=255)
203 #Méta
204 actif = models.BooleanField()
205
206 def __unicode__(self):
207 return u'%s' % self.nom
208
209
210 TYPE_ORGANISME_CHOICES = (
211 ('MAD', 'Mise à disposition'),
212 ('DET', 'Détachement'),
213 )
214
215 class OrganismeBstg(models.Model):
216 #Identification
217 id = models.IntegerField(primary_key=True)
218 nom = models.CharField(max_length=255)
219 type = models.CharField(max_length=10, choices=TYPE_ORGANISME_CHOICES)
220 #Méta
221 actif = models.BooleanField()
222
223 def __unicode__(self):
224 return u'%s (%s)' % (self.nom, self.type)
225
226
227 CONTRAT_CATEGORIE_CHOICES= (
228 ('A', 'A'),
229 ('C', 'C'),
230 )
231 class Statut(models.Model):
232 #Identification
233 id = models.IntegerField(primary_key=True)
234 code = models.CharField(max_length=25, unique=True)
235 nom = models.CharField(max_length=255)
236 type_contrat_categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES)
237 #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie
238 #Méta
239 actif = models.BooleanField()
240
241 def __unicode__(self):
242 return u'%s' % self.nom
243
244 TYPE_CLASSEMENT_CHOICES = (
245 ('S', 'S'),
246 ('T', 'T'),
247 )
248 class Classement(models.Model):
249 #Identification
250 id = models.IntegerField(primary_key=True)
251 type = models.CharField(max_length=10, choices=TYPE_CLASSEMENT_CHOICES)
252 echelon = models.IntegerField()
253 degre = models.IntegerField()
254 coefficient = models.FloatField()
255 #Méta
256 commentaire = models.TextField(null=True, blank=True)
257 date_modification = models.DateField(auto_now=True)
258 actif = models.BooleanField()
259
260 def __unicode__(self):
261 return u'%s.%s.%s (%s)' % (self.type, self.echelon, self.degre,
262 self.coefficient)
263
264
265 class ValeurPoint(models.Model):
266 #Identification
267 id = models.IntegerField(primary_key=True)
268 valeur = models.FloatField()
269 implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation')
270 #Méta
271 annee = models.IntegerField()
272
273 def __unicode__(self):
274 return u'%s (%s-%s)' % (self.valeur, self.implantation_id, self.annee)
275
276
277 class TauxChange(models.Model):
278 #Identification
279 id = models.IntegerField(primary_key=True)
280 devise = models.ForeignKey('Devise', db_column='devise')
281 annee = models.IntegerField()
282 taux = models.FloatField()
283 #Relations
284 implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation')
285
286
287 class Devise(models.Model):
288 id = models.IntegerField(primary_key=True)
289 code = models.CharField(max_length=10, unique=True)
290 nom = models.CharField(max_length=255)
291
292 def __unicode__(self):
293 return u'%s - %s' % (self.code, self.nom)
294
295
296 class TypeContrat(models.Model):
297 #Identification
298 id = models.IntegerField(primary_key=True)
299 nom = models.CharField(max_length=255)
300 nom_long = models.CharField(max_length=255) #description
301 categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES)
302 #Méta
303 actif = models.BooleanField()
304
305 def __unicode__(self):
306 return u'%s - %s' % (self.categorie, self.nom)