e9bbd6ba |
1 | # -=- encoding: utf-8 -=- |
2 | |
49f9f116 |
3 | from django.db import models |
e9bbd6ba |
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) |
ae936f8d |
21 | nationalite = models.ForeignKey('datamaster_modeles.Pays', to_field='code', related_name='employes_nationalite', db_column='nationalite') |
e9bbd6ba |
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) |
ae936f8d |
35 | pays = models.ForeignKey('datamaster_modeles.Pays', to_field='code', null=True, blank=True, related_name='employes', db_column='pays') |
e9bbd6ba |
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 | TYPE_DOSSIER_CHOICES = ( |
42 | ('2', 'Local'), |
43 | ('1', 'Expatrié'), |
44 | ) |
45 | |
46 | class Dossier(models.Model): |
47 | #Identification |
48 | id = models.IntegerField(primary_key=True) |
49 | code = models.CharField(max_length=10, unique=True) |
50 | employe = models.ForeignKey('Employe', db_column='employe') |
51 | #Postes |
ae936f8d |
52 | poste1 = models.ForeignKey('Poste', db_column='poste1', related_name='dossiers_poste1') |
53 | implantation1 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation1', related_name='dossiers_implantation1') |
e9bbd6ba |
54 | complement1 = models.TextField(null=True, blank=True) |
55 | responsable_implantation1 = models.IntegerField() |
ae936f8d |
56 | poste2 = models.ForeignKey('Poste', db_column='poste2', related_name='dossiers_poste2', blank=True, null=True) |
57 | implantation2 = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation2', related_name='dossiers_implantation2') |
e9bbd6ba |
58 | complement2 = models.TextField(null=True, blank=True) |
59 | responsable_implantation2 = models.IntegerField() |
60 | #Relations |
61 | service = models.ForeignKey('Service', db_column='service') |
ae936f8d |
62 | responsable = models.ForeignKey('Employe', db_column='responsable', related_name='responsable_de') |
63 | remplacement_de = models.ForeignKey('Employe', db_column='remplacement_de', related_name='replaced_by') |
e9bbd6ba |
64 | type = models.CharField(max_length=1, choices=TYPE_DOSSIER_CHOICES) |
65 | statut = models.ForeignKey('Statut', db_column='statut') |
66 | organisme_bstg = models.ForeignKey('OrganismeBstg', db_column='organisme_bstg') |
67 | #Rémunération |
68 | classement = models.ForeignKey('Classement', db_column='classement') |
69 | regime_travail = models.IntegerField() |
70 | #Mandat |
71 | mandat_date_debut = models.DateField() |
72 | mandat_date_fin = models.DateField() |
73 | #Contrat |
74 | contrat_date_debut = models.DateField() |
75 | contrat_date_fin = models.DateField() |
76 | type_contrat = models.ForeignKey('TypeContrat', db_column='type_contrat') |
77 | #Meta |
78 | date_creation = models.DateField(auto_now_add=True) |
79 | date_maj = models.DateField(auto_now=True) |
80 | commentaire = models.TextField(null=True, blank=True) |
81 | |
82 | LIEN_PARENTE_CHOICES = ( |
83 | ('Conjoint', 'Conjoint'), |
84 | ('Conjointe', 'Conjointe'), |
85 | ('Fille', 'Fille'), |
86 | ('Fils', 'Fils'), |
87 | ) |
88 | |
89 | class AyantDroit(models.Model): |
90 | #Identification |
91 | id = models.IntegerField(primary_key=True) |
92 | nom = models.CharField(max_length=255) |
93 | prenom = models.CharField(max_length=255) |
94 | #Relation |
ae936f8d |
95 | employe = models.ForeignKey('Employe', db_column='employe', related_name='ayants_droit') |
e9bbd6ba |
96 | lien_parente = models.CharField(max_length=10, choices=LIEN_PARENTE_CHOICES, null=True, blank=True) |
97 | #Méta |
98 | commentaire = models.TextField(null=True, blank=True) |
99 | actif = models.BooleanField() |
100 | |
101 | |
102 | class Remuneration(models.Model): |
103 | #Identification |
104 | id = models.IntegerField(primary_key=True) |
105 | dossier = models.ForeignKey('Dossier', db_column='dossier') |
106 | type = models.ForeignKey('TypeRemuneration', db_column='type') |
107 | type_revalorisation = models.ForeignKey('TypeRevalorisation', db_column='type_revalorisation') |
108 | montant = models.FloatField() |
109 | devise = models.ForeignKey('Devise', to_field='code', db_column='devise') |
110 | date_effective = models.DateField() |
111 | pourcentage = models.IntegerField() |
112 | #Méta |
113 | date_creation = models.DateField(auto_now_add=True) |
114 | user_creation = models.IntegerField() #User ou employé |
115 | desactivation = models.BooleanField() # |
116 | date_desactivation = models.DateField() |
117 | user_desactivation = models.IntegerField() #User ou employé |
118 | annule = models.BooleanField() |
119 | date_annule = models.DateField() |
120 | user_annule = models.IntegerField() #User ou employé |
121 | |
122 | class FamilleEmploi(models.Model): |
123 | #Identification |
124 | id = models.IntegerField(primary_key=True) |
125 | nom = models.CharField(max_length=255) |
126 | #Méta |
127 | actif = models.BooleanField() |
128 | |
129 | class TypePoste(models.Model): |
130 | #Identification |
131 | id = models.IntegerField(primary_key=True) |
132 | nom = models.CharField(max_length=255) |
133 | nom_feminin = models.CharField(max_length=255) |
134 | description = models.CharField(max_length=255) |
135 | is_responsable = models.BooleanField() |
136 | famille_emploi = models.ForeignKey('FamilleEmploi', db_column='famille_emploi') |
137 | #Méta |
138 | date_modification = models.DateField(auto_now=True) |
139 | actif = models.BooleanField() |
140 | |
141 | def __unicode__(self): |
142 | return u'%s' % self.nom |
143 | |
144 | |
145 | TYPE_PAIEMENT_CHOICES = ( |
146 | ('Régulier', 'Régulier'), |
147 | ('Ponctuel', 'Ponctuel'), |
148 | ) |
149 | |
150 | NATURE_REMUNERATION_CHOICES = ( |
151 | ('Accessoire', 'Accessoire'), |
152 | ('Charges', 'Charges'), |
153 | ('Indemnité', 'Indemnité'), |
154 | ('RAS', 'RAS'), |
155 | ('Traitement', 'Traitement'), |
156 | ) |
157 | |
158 | class TypeRemuneration(models.Model): |
159 | #Identification |
160 | id = models.IntegerField(primary_key=True) |
161 | nom = models.CharField(max_length=255) |
162 | type_paiement = models.CharField(max_length=30, choices=TYPE_PAIEMENT_CHOICES) |
163 | nature_remuneration = models.CharField(max_length=30, choices=NATURE_REMUNERATION_CHOICES) |
164 | #Méta |
165 | actif = models.BooleanField() |
166 | |
167 | class TypeRevalorisation(models.Model): |
168 | #Identification |
169 | id = models.IntegerField(primary_key=True) |
170 | nom = models.CharField(max_length=255) |
171 | #Méta |
172 | actif = models.BooleanField() |
173 | |
174 | PROPORTION_CHOICES = ( |
175 | ('0.5', '0.5'), |
176 | ('1', '1'), |
177 | ) |
178 | |
179 | class Poste(models.Model): |
180 | #Identification |
181 | id = models.IntegerField(primary_key=True) |
182 | implantation = models.ForeignKey('datamaster_modeles.Implantation', |
ae936f8d |
183 | db_column='implantation', related_name='postes') |
e9bbd6ba |
184 | type_poste = models.ForeignKey('TypePoste', db_column='type_poste') |
185 | proportion = models.CharField(max_length=10, choices=PROPORTION_CHOICES) |
186 | #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%) |
187 | #Méta |
188 | date_modification = models.DateField(auto_now=True) |
189 | actif = models.BooleanField() |
190 | |
191 | def __unicode__(self): |
192 | return u'%s - %s' % (self.implantation, self.type_poste.nom) |
193 | |
194 | |
195 | class Service(models.Model): |
196 | #Identification |
197 | id = models.IntegerField(primary_key=True) |
198 | nom = models.CharField(max_length=255) |
199 | #Méta |
200 | actif = models.BooleanField() |
201 | |
202 | def __unicode__(self): |
203 | return u'%s' % self.nom |
204 | |
205 | |
206 | TYPE_ORGANISME_CHOICES = ( |
207 | ('MAD', 'Mise à disposition'), |
208 | ('DET', 'Détachement'), |
209 | ) |
210 | |
211 | class OrganismeBstg(models.Model): |
212 | #Identification |
213 | id = models.IntegerField(primary_key=True) |
214 | nom = models.CharField(max_length=255) |
215 | type = models.CharField(max_length=10, choices=TYPE_ORGANISME_CHOICES) |
216 | #Méta |
217 | actif = models.BooleanField() |
218 | |
219 | CONTRAT_CATEGORIE_CHOICES= ( |
220 | ('A', 'A'), |
221 | ('C', 'C'), |
222 | ) |
223 | class Statut(models.Model): |
224 | #Identification |
225 | id = models.IntegerField(primary_key=True) |
226 | code = models.CharField(max_length=25, unique=True) |
227 | nom = models.CharField(max_length=255) |
228 | type_contrat_categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES) |
229 | #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie |
230 | #Méta |
231 | actif = models.BooleanField() |
232 | |
233 | TYPE_CLASSEMENT_CHOICES = ( |
234 | ('S', 'S'), |
235 | ('T', 'T'), |
236 | ) |
237 | class Classement(models.Model): |
238 | #Identification |
239 | id = models.IntegerField(primary_key=True) |
240 | type = models.CharField(max_length=10, choices=TYPE_CLASSEMENT_CHOICES) |
241 | echelon = models.IntegerField() |
242 | degre = models.IntegerField() |
243 | coefficient = models.FloatField() |
244 | #Méta |
245 | commentaire = models.TextField(null=True, blank=True) |
246 | date_modification = models.DateField(auto_now=True) |
247 | actif = models.BooleanField() |
248 | |
249 | def __unicode__(self): |
250 | return u'%s.%s.%s (%s)' % (self.type, self.echelon, self.degre, |
251 | self.coefficient) |
252 | |
253 | |
254 | class ValeurPoint(models.Model): |
255 | #Identification |
256 | id = models.IntegerField(primary_key=True) |
257 | valeur = models.FloatField() |
ae936f8d |
258 | implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation', related_name='valeurs_point') |
e9bbd6ba |
259 | #Méta |
260 | annee = models.IntegerField() |
261 | |
262 | def __unicode__(self): |
263 | return u'%s (%s-%s)' % (self.valeur, self.implantation_id, self.annee) |
264 | |
265 | |
266 | class TauxChange(models.Model): |
267 | #Identification |
268 | id = models.IntegerField(primary_key=True) |
269 | devise = models.ForeignKey('Devise', to_field='code', db_column='devise') |
270 | annee = models.IntegerField() |
271 | taux = models.FloatField() |
272 | #Relations |
ae936f8d |
273 | implantation = models.ForeignKey('datamaster_modeles.Implantation', db_column='implantation', related_name='taux_change') |
e9bbd6ba |
274 | |
275 | |
276 | class Devise(models.Model): |
277 | id = models.IntegerField(primary_key=True) |
278 | code = models.CharField(max_length=10, unique=True) |
279 | nom = models.CharField(max_length=255) |
280 | |
281 | def __unicode__(self): |
282 | return u'%s - %s' % (self.code, self.nom) |
283 | |
284 | |
285 | class TypeContrat(models.Model): |
286 | #Identification |
287 | id = models.IntegerField(primary_key=True) |
288 | nom = models.CharField(max_length=255) |
289 | nom_long = models.CharField(max_length=255) #description |
290 | categorie = models.CharField(max_length=10, choices=CONTRAT_CATEGORIE_CHOICES) |
291 | #Méta |
292 | actif = models.BooleanField() |
49f9f116 |
293 | |