Premier jet pour le formulaire de poste (manque le financement)
[auf_rh_dae.git] / project / dae / models.py
1 # -=- encoding: utf-8 -=-
2 from django.db import models
3
4 import datamaster_modeles.models as ref
5 import project.rh_v1.models as rh
6
7
8 STATUT_RESIDENCE_CHOICES = (
9 ('local', 'Local'),
10 ('expat', 'Expatrié'),
11 )
12
13 POSTE_APPEL_CHOICES = (
14 ('interne', 'Interne'),
15 ('externe', 'Externe'),
16 )
17
18 POSTE_STATUT_CHOICES = (
19 ('MAD', 'Mise à disposition'),
20 ('DET', 'Détachement'),
21 )
22
23
24 class Poste(models.Model):
25 # Modèle existant
26 id_rh = models.ForeignKey(rh.Poste, null=True, related_name='+',
27 editable=False)
28 nom = models.CharField(max_length=255)
29 implantation = models.ForeignKey(ref.Implantation)
30 type_poste = models.ForeignKey(rh.TypePoste, null=True, related_name='+')
31 service = models.ForeignKey(rh.Service, related_name='+')
32 responsable = models.ForeignKey(rh.Poste, related_name='+')
33 regime_travail = models.DecimalField(max_digits=12, decimal_places=2,
34 default=100)
35 regime_travail_nb_heure_semaine = models.DecimalField(max_digits=12,
36 decimal_places=2,
37 default=40)
38
39 # Recrutement
40 statut_residence = models.CharField(max_length=10, default='MAD',
41 choices=STATUT_RESIDENCE_CHOICES)
42 # TODO null?
43 mise_a_disposition = models.BooleanField()
44 appel = models.CharField(max_length=10, default='interne',
45 choices=POSTE_APPEL_CHOICES)
46
47 # Rémunération
48 classement_min = models.ForeignKey(rh.Classement, related_name='+')
49 classement_max = models.ForeignKey(rh.Classement, related_name='+')
50 valeur_point_min = models.ForeignKey(rh.ValeurPoint, related_name='+')
51 valeur_point_max = models.ForeignKey(rh.ValeurPoint, related_name='+')
52 salaire_min = models.DecimalField(max_digits=12, decimal_places=2,
53 default=0)
54 salaire_max = models.DecimalField(max_digits=12, decimal_places=2,
55 default=0)
56 indemn_min = models.DecimalField(max_digits=12, decimal_places=2,
57 default=0)
58 indemn_max = models.DecimalField(max_digits=12, decimal_places=2,
59 default=0)
60 autre_min = models.DecimalField(max_digits=12, decimal_places=2,
61 default=0)
62 autre_max = models.DecimalField(max_digits=12, decimal_places=2,
63 default=0)
64
65 # Comparatifs de rémunération
66 devise_comparaison = models.ForeignKey(rh.Devise, related_name='+',
67 null=True, blank=True)
68 comp_locale_min = models.DecimalField(max_digits=12, decimal_places=2,
69 null=True, blank=True)
70 comp_locale_max = models.DecimalField(max_digits=12, decimal_places=2,
71 null=True, blank=True)
72 comp_universite_min = models.DecimalField(max_digits=12, decimal_places=2,
73 null=True, blank=True)
74 comp_universite_max = models.DecimalField(max_digits=12, decimal_places=2,
75 null=True, blank=True)
76 comp_fonctionpub_min = models.DecimalField(max_digits=12, decimal_places=2,
77 null=True, blank=True)
78 comp_fonctionpub_max = models.DecimalField(max_digits=12, decimal_places=2,
79 null=True, blank=True)
80 comp_ong_min = models.DecimalField(max_digits=12, decimal_places=2,
81 null=True, blank=True)
82 comp_ong_max = models.DecimalField(max_digits=12, decimal_places=2,
83 null=True, blank=True)
84 comp_autre_min = models.DecimalField(max_digits=12, decimal_places=2,
85 null=True, blank=True)
86 comp_autre_max = models.DecimalField(max_digits=12, decimal_places=2,
87 null=True, blank=True)
88
89 # Méta
90 date_creation = models.DateTimeField(auto_now_add=True)
91 date_modification = models.DateTimeField(auto_now=True)
92 date_debut = models.DateField()
93 date_fin = models.DateField(null=True)
94 actif = models.BooleanField(default=True)
95
96 def __unicode__(self):
97 return u'%s - %s (%s)' % (self.implantation, self.type_poste.nom,
98 self.nom)
99
100 def DISABLED_save(self, *args, **kwargs):
101 # calculate nb_mois = nb of months between date_debut and date_fin
102 from datetime import date
103 if not self.salaire_min:
104 self.salaire_min = self.classement_min * self.valeur_point_min
105 if not self.salaire_max:
106 self.salaire_max = self.classement_max * self.valeur_point_min
107 if not self.valeur_point_min:
108 self.valeur_point_min = \
109 rh.ValeurPoint.objects.filter(implantation=self.implantation)
110 if not self.valeur_point_max:
111 self.valeur_point_max = \
112 rh.ValeurPoint.objects.filter(implantation=self.implantation)
113 super(Subject, self).save(*args, **kwargs)
114
115
116 MIN_MAX_CHOICES = (
117 ('min', 'minimum'),
118 ('max', 'maximum'),
119 )
120
121
122 TYPE_ORG_CHOICES = (
123 ('locale_ent', 'minimum'),
124 ('university', 'université'),
125 ('government', 'fonction publique'),
126 ('ong', 'ONG'),
127 ('autre', 'autre'),
128 )
129
130
131 class PosteComparatifExterne(models.Model):
132 poste = models.ForeignKey('Poste')
133 montant = models.DecimalField(max_digits=12, decimal_places=2)
134 # TODO default='EUR'
135 devise = models.ForeignKey(rh.Devise, related_name='+')
136 min_max = models.CharField(max_length=10, choices=MIN_MAX_CHOICES)
137 type_org = models.CharField(max_length=10, choices=TYPE_ORG_CHOICES)
138
139
140 POSTE_FINANCEMENT_CHOICES = (
141 ('A', 'A - Frais de personnel'),
142 ('B', 'B - Projet(s)-Titre(s)'),
143 ('C', 'C - Autre')
144 )
145
146
147 class PosteFinancement(models.Model):
148 montant = models.DecimalField(max_digits=12, decimal_places=2)
149 poste = models.ForeignKey('Poste', related_name='financements')
150 type = models.CharField(max_length=1, choices=POSTE_FINANCEMENT_CHOICES)
151 pourcentage = models.DecimalField(max_digits=12, decimal_places=2)
152 commentaire = models.TextField()
153
154
155 GENRE_CHOICES = (
156 ('m', 'Masculin'),
157 ('f', 'Féminin'),
158 )
159
160
161 class Employe(models.Model):
162 id = models.IntegerField(primary_key=True)
163
164 # Modèle existant
165 id_rh = models.ForeignKey(rh.Employe, null=True, related_name='+')
166 nom = models.CharField(max_length=255)
167 prenom = models.CharField(max_length=255)
168 genre = models.CharField(max_length=1,
169 choices=GENRE_CHOICES,
170 null=True,
171 blank=True)
172
173
174 COMPTE_COMPTA_CHOICES = (
175 ('coda', 'coda'),
176 ('scs', 'scs'),
177 ('aucun', 'aucun'),
178 )
179
180
181 class Dossier(models.Model):
182 statut_anterieur = models.ForeignKey(rh.Statut, related_name='+')
183
184 # Modèle existant
185 poste = models.ForeignKey('Poste')
186 statut = models.ForeignKey(rh.Statut, related_name='+')
187 organisme_bstg = models.ForeignKey(rh.OrganismeBstg, related_name='+')
188
189 # Recrutement
190 remplacement = models.BooleanField()
191 mobilite_interne = models.BooleanField()
192 statut_residence = models.CharField(max_length=10,
193 choices=STATUT_RESIDENCE_CHOICES)
194
195 # Rémunération
196 classement = models.ForeignKey(rh.Classement,
197 verbose_name='Classement proposé',
198 related_name='+')
199 salaire = models.DecimalField(max_digits=12,
200 decimal_places=2,
201 verbose_name='Salaire de base',
202 null=True,
203 default=None)
204 devise = models.ForeignKey(rh.Devise, related_name='+')
205 regime_travail = models.DecimalField(max_digits=12, decimal_places=2)
206 regime_travail_nb_heure_semaine = \
207 models.DecimalField(max_digits=12, decimal_places=2)
208
209 # Contrat
210 type_contrat = models.ForeignKey(rh.TypeContrat, related_name='+')
211 contrat_date_debut = models.DateField()
212 contrat_date_fin = models.DateField()
213 contrat_nb_mois = models.IntegerField()
214
215 # Comptes
216 compte_compta = models.CharField(max_length=10,
217 choices=COMPTE_COMPTA_CHOICES)
218 compte_courriel = models.BooleanField()
219
220
221 class Remuneration(models.Model):
222 # Identification
223 id = models.IntegerField(primary_key=True)
224 dossier = models.ForeignKey('Dossier', db_column='dossier')
225 type = models.ForeignKey('TypeRemuneration', db_column='type')
226 # TODO: what's that?
227 # type_revalorisation = models.ForeignKey('TypeRevalorisation',
228 # db_column='type_revalorisation')
229 montant = models.DecimalField(max_digits=12, decimal_places=2)
230 devise = models.ForeignKey(rh.Devise,
231 to_field='code',
232 db_column='devise', related_name='+')
233 date_effective = models.DateField()
234 pourcentage = models.IntegerField()
235
236 # Méta
237 date_creation = models.DateField(auto_now_add=True)
238 user_creation = models.IntegerField()
239 desactivation = models.BooleanField()
240 date_desactivation = models.DateField()
241 user_desactivation = models.IntegerField()
242 annule = models.BooleanField()
243 date_annule = models.DateField()
244 user_annule = models.IntegerField()
245
246
247 class JustificationPoste(models.Model):
248 pass
249
250
251 class JustificationEmploye(models.Model):
252 pass
253
254
255 class DocumentPoste(models.Model):
256 pass
257
258
259 class DocumentEmploye(models.Model):
260 pass
261
262
263 class Validation(models.Model):
264 # user
265 date = models.DateField()
266
267 # avis = ? (CHOICES?)
268
269
270 class ValidationPoste(models.Model):
271 poste = models.ForeignKey('Poste')
272
273
274 class ValidationEmploye(models.Model):
275 employe = models.ForeignKey('Employe')
276
277
278 class TypeRemuneration(models.Model):
279 ordre = models.IntegerField()
280 groupe = models.ForeignKey('GroupeTypeRemuneration')
281
282
283 class GroupeTypeRemuneration(models.Model):
284 nom = models.CharField(max_length=255)
285 ordre = models.IntegerField()