1 # -=- encoding: utf-8 -=-
4 from django
.db
import models
5 from datamaster_modeles
.models
import Pays
, Implantation
17 class Employe(models
.Model
):
19 id = models
.IntegerField(primary_key
=True)
20 nom
= models
.CharField(max_length
=255)
21 prenom
= models
.CharField(max_length
=255)
22 nationalite
= models
.ForeignKey('datamaster_modeles.Pays', to_field
='code',
23 related_name
='employes_nationalite',
24 db_column
='nationalite')
25 date_naissance
= models
.DateField(null
=True, blank
=True)
27 genre
= models
.CharField(max_length
=1, null
=True, blank
=True,
28 choices
=GENRE_CHOICES
)
29 situation_famille
= models
.CharField(max_length
=1, null
=True, blank
=True,
30 choices
=SITUATION_CHOICES
)
31 date_entree
= models
.DateField(null
=True, blank
=True) #devrait pas être là
33 tel_domicile
= models
.CharField(max_length
=255, null
=True, blank
=True)
34 tel_cellulaire
= models
.CharField(max_length
=255, null
=True, blank
=True)
35 adresse
= models
.CharField(max_length
=255, null
=True, blank
=True)
36 no_rue
= models
.CharField(max_length
=255, null
=True, blank
=True)
37 ville
= models
.CharField(max_length
=255, null
=True, blank
=True)
38 province
= models
.CharField(max_length
=255, null
=True, blank
=True)
39 code_postal
= models
.CharField(max_length
=255, null
=True, blank
=True)
40 pays
= models
.ForeignKey('datamaster_modeles.Pays', to_field
='code',
41 null
=True, blank
=True,
42 related_name
='employes', db_column
='pays')
44 date_creation
= models
.DateField(auto_now_add
=True)
45 date_maj
= models
.DateField(auto_now
=True)
46 commentaire
= models
.TextField(null
=True, blank
=True)
48 def __unicode__(self
):
49 return u
'%s %s' % (self
.prenom
, self
.nom
)
52 TYPE_DOSSIER_CHOICES
= (
57 class Dossier(models
.Model
):
59 id = models
.IntegerField(primary_key
=True)
60 code
= models
.CharField(max_length
=10, unique
=True)
61 employe
= models
.ForeignKey('Employe', db_column
='employe')
63 poste1
= models
.ForeignKey('Poste', db_column
='poste1',
64 related_name
='dossiers_poste1')
65 implantation1
= models
.ForeignKey('datamaster_modeles.Implantation',
66 db_column
='implantation1',
67 related_name
='dossiers_implantation1',
68 blank
=True, null
=True)
69 complement1
= models
.TextField(null
=True, blank
=True)
70 responsable_implantation1
= models
.IntegerField()
71 poste2
= models
.ForeignKey('Poste', db_column
='poste2',
72 related_name
='dossiers_poste2',
73 blank
=True, null
=True)
74 implantation2
= models
.ForeignKey('datamaster_modeles.Implantation',
75 db_column
='implantation2',
76 related_name
='dossiers_implantation2',
77 null
=True, blank
=True)
78 complement2
= models
.TextField(null
=True, blank
=True)
79 responsable_implantation2
= models
.IntegerField()
81 service
= models
.ForeignKey('Service', db_column
='service',
82 blank
=True, null
=True)
83 responsable
= models
.ForeignKey('Employe', db_column
='responsable',
84 related_name
='responsable_de',
85 blank
=True, null
=True)
86 remplacement_de
= models
.ForeignKey('Employe', db_column
='remplacement_de',
87 related_name
='replaced_by',
88 blank
=True, null
=True)
89 type = models
.CharField(max_length
=1, choices
=TYPE_DOSSIER_CHOICES
)
90 statut
= models
.ForeignKey('Statut', db_column
='statut',
91 blank
=True, null
=True)
92 organisme_bstg
= models
.ForeignKey('OrganismeBstg',
93 db_column
='organisme_bstg',
94 blank
=True, null
=True)
96 classement
= models
.ForeignKey('Classement', db_column
='classement',
97 blank
=True, null
=True)
98 regime_travail
= models
.IntegerField()
100 mandat_date_debut
= models
.DateField()
101 mandat_date_fin
= models
.DateField(null
=True, blank
=True)
103 contrat_date_debut
= models
.DateField()
104 contrat_date_fin
= models
.DateField()
105 type_contrat
= models
.ForeignKey('TypeContrat', db_column
='type_contrat',
106 blank
=True, null
=True)
108 date_creation
= models
.DateField(auto_now_add
=True)
109 date_maj
= models
.DateField(auto_now
=True)
110 commentaire
= models
.TextField(null
=True, blank
=True)
112 def __unicode__(self
):
113 return u
'%s : %s %s' % (self
.employe
, self
.poste1
, self
.complement1
)
115 LIEN_PARENTE_CHOICES
= (
116 ('Conjoint', 'Conjoint'),
117 ('Conjointe', 'Conjointe'),
122 class AyantDroit(models
.Model
):
124 id = models
.IntegerField(primary_key
=True)
125 nom
= models
.CharField(max_length
=255)
126 prenom
= models
.CharField(max_length
=255)
128 employe
= models
.ForeignKey('Employe', db_column
='employe',
129 related_name
='ayants_droit')
130 lien_parente
= models
.CharField(max_length
=10, null
=True, blank
=True,
131 choices
=LIEN_PARENTE_CHOICES
)
133 commentaire
= models
.TextField(null
=True, blank
=True)
134 actif
= models
.BooleanField()
137 class Remuneration(models
.Model
):
139 id = models
.IntegerField(primary_key
=True)
140 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
141 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
142 type_revalorisation
= models
.ForeignKey('TypeRevalorisation',
143 db_column
='type_revalorisation',
144 null
=True, blank
=True)
145 montant
= models
.FloatField(null
=True, blank
=True)
146 devise
= models
.ForeignKey('Devise', to_field
='code', db_column
='devise',
147 null
=True, blank
=True)
148 date_effective
= models
.DateField(null
=True, blank
=True)
149 pourcentage
= models
.IntegerField(null
=True, blank
=True)
151 date_creation
= models
.DateField(auto_now_add
=True)
152 user_creation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
153 desactivation
= models
.BooleanField(null
=True, blank
=True) #
154 date_desactivation
= models
.DateField(null
=True, blank
=True)
155 user_desactivation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
156 annulation
= models
.BooleanField(null
=True, blank
=True)
157 date_annulation
= models
.DateField(null
=True, blank
=True)
158 user_annulation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
160 def __unicode__(self
):
162 devise
= self
.devise
.code
165 return "%s %s" % (self
.montant
, devise
)
167 class FamilleEmploi(models
.Model
):
169 id = models
.IntegerField(primary_key
=True)
170 nom
= models
.CharField(max_length
=255)
172 actif
= models
.BooleanField()
174 class TypePoste(models
.Model
):
176 id = models
.IntegerField(primary_key
=True)
177 nom
= models
.CharField(max_length
=255)
178 nom_feminin
= models
.CharField(max_length
=255)
179 description
= models
.CharField(max_length
=255)
180 is_responsable
= models
.BooleanField()
181 famille_emploi
= models
.ForeignKey('FamilleEmploi',
182 db_column
='famille_emploi')
184 date_modification
= models
.DateField(auto_now
=True)
185 actif
= models
.BooleanField()
187 def __unicode__(self
):
188 return u
'%s' % self
.nom
191 TYPE_PAIEMENT_CHOICES
= (
192 ('Régulier', 'Régulier'),
193 ('Ponctuel', 'Ponctuel'),
196 NATURE_REMUNERATION_CHOICES
= (
197 ('Accessoire', 'Accessoire'),
198 ('Charges', 'Charges'),
199 ('Indemnité', 'Indemnité'),
201 ('Traitement', 'Traitement'),
204 class TypeRemuneration(models
.Model
):
206 id = models
.IntegerField(primary_key
=True)
207 nom
= models
.CharField(max_length
=255)
208 type_paiement
= models
.CharField(max_length
=30,
209 choices
=TYPE_PAIEMENT_CHOICES
)
210 nature_remuneration
= models
.CharField(max_length
=30,
211 choices
=NATURE_REMUNERATION_CHOICES
)
213 actif
= models
.BooleanField()
215 def __unicode__(self
):
216 return u
'%s' % self
.nom
218 class TypeRevalorisation(models
.Model
):
220 id = models
.IntegerField(primary_key
=True)
221 nom
= models
.CharField(max_length
=255)
223 actif
= models
.BooleanField()
225 PROPORTION_CHOICES
= (
230 class Poste(models
.Model
):
232 id = models
.IntegerField(primary_key
=True)
233 implantation
= models
.ForeignKey('datamaster_modeles.Implantation',
234 db_column
='implantation', related_name
='postes')
235 type_poste
= models
.ForeignKey('TypePoste', db_column
='type_poste')
236 proportion
= models
.CharField(max_length
=10, choices
=PROPORTION_CHOICES
)
237 #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%)
239 date_modification
= models
.DateField(auto_now
=True)
240 actif
= models
.BooleanField()
243 def __unicode__(self
):
244 return u
'%s - %s [%s]' % (self
.implantation
, self
.type_poste
.nom
,
248 class Service(models
.Model
):
250 id = models
.IntegerField(primary_key
=True)
251 nom
= models
.CharField(max_length
=255)
253 actif
= models
.BooleanField()
255 def __unicode__(self
):
256 return u
'%s' % self
.nom
262 TYPE_ORGANISME_CHOICES
= (
263 ('MAD', 'Mise à disposition'),
264 ('DET', 'Détachement'),
267 class OrganismeBstg(models
.Model
):
269 id = models
.IntegerField(primary_key
=True)
270 nom
= models
.CharField(max_length
=255)
271 type = models
.CharField(max_length
=10, choices
=TYPE_ORGANISME_CHOICES
)
273 actif
= models
.BooleanField()
275 def __unicode__(self
):
276 return u
'%s (%s)' % (self
.nom
, self
.type)
279 ordering
= ['type', 'nom']
281 CONTRAT_CATEGORIE_CHOICES
= (
285 class Statut(models
.Model
):
287 id = models
.IntegerField(primary_key
=True)
288 code
= models
.CharField(max_length
=25, unique
=True)
289 nom
= models
.CharField(max_length
=255)
290 type_contrat_categorie
= models
.CharField(max_length
=10,
291 choices
=CONTRAT_CATEGORIE_CHOICES
)
292 #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie
294 actif
= models
.BooleanField()
296 def __unicode__(self
):
297 return u
'%s : %s' % (self
.code
, self
.nom
)
299 TYPE_CLASSEMENT_CHOICES
= (
303 class Classement(models
.Model
):
305 id = models
.IntegerField(primary_key
=True)
306 type = models
.CharField(max_length
=10, choices
=TYPE_CLASSEMENT_CHOICES
)
307 echelon
= models
.IntegerField()
308 degre
= models
.IntegerField()
309 coefficient
= models
.FloatField()
311 commentaire
= models
.TextField(null
=True, blank
=True)
312 date_modification
= models
.DateField(auto_now
=True)
313 actif
= models
.BooleanField()
315 def __unicode__(self
):
316 return u
'%s.%s.%s (%s)' % (self
.type, self
.echelon
, self
.degre
,
319 ordering
= ['type','echelon','degre','coefficient']
322 class TauxChange(models
.Model
):
324 id = models
.IntegerField(primary_key
=True)
325 devise
= models
.ForeignKey('Devise', to_field
='code', db_column
='devise')
326 annee
= models
.IntegerField()
327 taux
= models
.FloatField()
329 implantation
= models
.ForeignKey('datamaster_modeles.Implantation',
330 db_column
='implantation',
331 related_name
='taux_change')
334 class ValeurPoint(models
.Model
):
336 id = models
.IntegerField(primary_key
=True)
337 valeur
= models
.FloatField()
338 implantation
= models
.ForeignKey('datamaster_modeles.Implantation',
339 db_column
='implantation',
340 related_name
='valeurs_point')
342 annee
= models
.IntegerField()
344 # Stockage de tous les taux de change pour optimiser la recherche de la devise associée
345 annee_courante
= datetime
.datetime
.now().year
346 tauxchange
= TauxChange
.objects
.select_related('devise').filter(annee
=annee_courante
)
348 def __unicode__(self
):
349 tx
= self
.get_tauxchange_courant()
351 devise_code
= tx
.devise
.code
354 return u
'%s %s (%s-%s)' % (self
.valeur
, devise_code
, self
.implantation_id
, self
.annee
)
357 ordering
= ['valeur']
360 class Devise(models
.Model
):
361 id = models
.IntegerField(primary_key
=True)
362 code
= models
.CharField(max_length
=10, unique
=True)
363 nom
= models
.CharField(max_length
=255)
365 def __unicode__(self
):
366 return u
'%s - %s' % (self
.code
, self
.nom
)
369 class TypeContrat(models
.Model
):
371 id = models
.IntegerField(primary_key
=True)
372 nom
= models
.CharField(max_length
=255)
373 nom_long
= models
.CharField(max_length
=255) #description
374 categorie
= models
.CharField(max_length
=10,
375 choices
=CONTRAT_CATEGORIE_CHOICES
)
377 actif
= models
.BooleanField()
379 def __unicode__(self
):
380 return u
'%s' % (self
.nom
)