1 # -=- encoding: utf-8 -=-
2 from django
.db
import models
4 import datamaster_modeles
.models
as ref
5 import project
.rh_v1
.models
as rh
8 STATUT_RESIDENCE_CHOICES
= (
10 ('expat', 'Expatrié'),
13 POSTE_APPEL_CHOICES
= (
14 ('interne', 'Interne'),
15 ('externe', 'Externe'),
18 POSTE_STATUT_CHOICES
= (
19 ('MAD', 'Mise à disposition'),
20 ('DET', 'Détachement'),
24 class PosteManager(models
.Manager
):
26 Chargement de tous les objets FK existants sur chaque QuerySet.
28 def get_query_set(self
):
40 return super(PosteManager
, self
).get_query_set() \
41 .select_related(*fkeys
).all()
44 class Poste(models
.Model
):
46 id_rh
= models
.ForeignKey(rh
.Poste
, null
=True, related_name
='+',
48 verbose_name
="Mise à jour du poste")
49 nom
= models
.CharField(verbose_name
="Titre du poste", max_length
=255)
50 implantation
= models
.ForeignKey(ref
.Implantation
)
51 type_poste
= models
.ForeignKey(rh
.TypePoste
, null
=True, related_name
='+')
52 service
= models
.ForeignKey(rh
.Service
, related_name
='+',
53 verbose_name
=u
"Direction/Service/Pôle support")
54 responsable
= models
.ForeignKey(rh
.Poste
, related_name
='+',
55 verbose_name
="Poste du responsable")
57 regime_travail
= models
.DecimalField(max_digits
=12, decimal_places
=2,
59 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
64 statut_residence
= models
.CharField(max_length
=10, default
='MAD',
65 verbose_name
="Recrutement",
66 choices
=STATUT_RESIDENCE_CHOICES
)
68 mise_a_disposition
= models
.BooleanField()
69 appel
= models
.CharField(max_length
=10, default
='interne',
70 verbose_name
="Appel à candidature",
71 choices
=POSTE_APPEL_CHOICES
)
74 classement_min
= models
.ForeignKey(rh
.Classement
, related_name
='+')
75 classement_max
= models
.ForeignKey(rh
.Classement
, related_name
='+')
76 valeur_point_min
= models
.ForeignKey(rh
.ValeurPoint
, related_name
='+')
77 valeur_point_max
= models
.ForeignKey(rh
.ValeurPoint
, related_name
='+')
78 salaire_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
80 salaire_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
82 indemn_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
84 indemn_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
86 autre_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
88 autre_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
91 # Comparatifs de rémunération
92 devise_comparaison
= models
.ForeignKey(rh
.Devise
, related_name
='+',
93 null
=True, blank
=True)
94 comp_locale_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
95 null
=True, blank
=True)
96 comp_locale_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
97 null
=True, blank
=True)
98 comp_universite_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
99 null
=True, blank
=True)
100 comp_universite_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
101 null
=True, blank
=True)
102 comp_fonctionpub_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
103 null
=True, blank
=True)
104 comp_fonctionpub_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
105 null
=True, blank
=True)
106 comp_ong_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
107 null
=True, blank
=True)
108 comp_ong_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
109 null
=True, blank
=True)
110 comp_autre_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
111 null
=True, blank
=True)
112 comp_autre_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
113 null
=True, blank
=True)
116 date_creation
= models
.DateTimeField(auto_now_add
=True)
117 date_modification
= models
.DateTimeField(auto_now
=True)
118 date_debut
= models
.DateField(verbose_name
="Date de début",
119 help_text
="format: aaaa-mm-jj")
120 date_fin
= models
.DateField(null
=True, verbose_name
="Date de fin",
121 help_text
="format: aaaa-mm-jj")
122 actif
= models
.BooleanField(default
=True)
125 objects
= PosteManager()
127 def __unicode__(self
):
128 return u
'%s - %s (%s) [dae-%s]' % (self
.implantation
, self
.type_poste
.nom
,
131 def DISABLED_save(self
, *args
, **kwargs
):
132 # calculate nb_mois = nb of months between date_debut and date_fin
133 from datetime
import date
134 if not self
.salaire_min
:
135 self
.salaire_min
= self
.classement_min
* self
.valeur_point_min
136 if not self
.salaire_max
:
137 self
.salaire_max
= self
.classement_max
* self
.valeur_point_min
138 if not self
.valeur_point_min
:
139 self
.valeur_point_min
= \
140 rh
.ValeurPoint
.objects
.filter(implantation
=self
.implantation
)
141 if not self
.valeur_point_max
:
142 self
.valeur_point_max
= \
143 rh
.ValeurPoint
.objects
.filter(implantation
=self
.implantation
)
144 super(Subject
, self
).save(*args
, **kwargs
)
147 POSTE_FINANCEMENT_CHOICES
= (
148 ('A', 'A - Frais de personnel'),
149 ('B', 'B - Projet(s)-Titre(s)'),
154 class PosteFinancement(models
.Model
):
155 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2,
156 help_text
="ex.: 12000.00 € (décimale avec point, devise = EUR)")
157 poste
= models
.ForeignKey('Poste', related_name
='financements')
158 type = models
.CharField(max_length
=1, choices
=POSTE_FINANCEMENT_CHOICES
)
159 pourcentage
= models
.DecimalField(max_digits
=12, decimal_places
=2,
160 help_text
="ex.: 33.33 % (décimale avec point)")
161 commentaire
= models
.TextField(
162 help_text
="Spécifiez la source de financement.")
173 class Employe(models
.Model
):
176 id_rh
= models
.ForeignKey(rh
.Employe
, null
=True, related_name
='+')
177 nom
= models
.CharField(max_length
=255)
178 prenom
= models
.CharField(max_length
=255)
179 genre
= models
.CharField(max_length
=1, choices
=GENRE_CHOICES
,
180 null
=True, blank
=True)
182 def __unicode__(self
):
183 return u
'%s %s' % (self
.prenom
, self
.nom
)
186 COMPTE_COMPTA_CHOICES
= (
193 class Dossier(models
.Model
):
196 employe
= models
.ForeignKey('Employe', related_name
='+', editable
=False)
197 poste
= models
.ForeignKey('Poste', related_name
='+', editable
=False)
198 statut
= models
.ForeignKey(rh
.Statut
, related_name
='+')
199 organisme_bstg
= models
.ForeignKey(rh
.OrganismeBstg
, related_name
='+')
201 # Données antérieures de l'employé
202 statut_anterieur
= models
.ForeignKey(
203 rh
.Statut
, related_name
='+', null
=True, blank
=True,
204 verbose_name
='Statut précédent')
205 classement_anterieur
= models
.ForeignKey(
206 rh
.Classement
, related_name
='+', null
=True, blank
=True,
207 verbose_name
='Classement précédent')
208 salaire_anterieur
= models
.DecimalField(
209 max_digits
=12, decimal_places
=2, null
=True, default
=None,
210 blank
=True, verbose_name
='Salaire précédent')
212 # Données du titulaire précédent
213 employe_anterieur
= models
.ForeignKey(
214 rh
.Employe
, related_name
='+', null
=True, blank
=True,
215 verbose_name
='Employé précédent')
216 statut_titulaire_anterieur
= models
.ForeignKey(
217 rh
.Statut
, related_name
='+', null
=True, blank
=True,
218 verbose_name
='Statut titulaire précédent')
219 classement_titulaire_anterieur
= models
.ForeignKey(
220 rh
.Classement
, related_name
='+', null
=True, blank
=True,
221 verbose_name
='Classement titulaire précédent')
222 salaire_titulaire_anterieur
= models
.DecimalField(
223 max_digits
=12, decimal_places
=2, default
=None, null
=True,
224 blank
=True, verbose_name
='Salaire titulaire précédent')
227 remplacement
= models
.BooleanField()
228 statut_residence
= models
.CharField(max_length
=10,
229 choices
=STATUT_RESIDENCE_CHOICES
)
232 classement
= models
.ForeignKey(rh
.Classement
, related_name
='+',
233 verbose_name
='Classement proposé')
234 salaire
= models
.DecimalField(max_digits
=12, decimal_places
=2,
235 verbose_name
='Salaire de base',
236 null
=True, default
=None)
237 devise
= models
.ForeignKey(rh
.Devise
, related_name
='+')
238 regime_travail
= models
.DecimalField(max_digits
=12, decimal_places
=2,
239 verbose_name
="Régime de travail")
240 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
241 decimal_places
=2, verbose_name
="Nbr heures par semaine")
244 type_contrat
= models
.ForeignKey(rh
.TypeContrat
, related_name
='+')
245 contrat_date_debut
= models
.DateField()
246 contrat_date_fin
= models
.DateField()
249 compte_compta
= models
.CharField(max_length
=10,
250 choices
=COMPTE_COMPTA_CHOICES
)
251 compte_courriel
= models
.BooleanField()
254 class Remuneration(models
.Model
):
256 id = models
.IntegerField(primary_key
=True)
257 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
258 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
260 # type_revalorisation = models.ForeignKey('TypeRevalorisation',
261 # db_column='type_revalorisation')
262 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2) # Annuel
263 devise
= models
.ForeignKey(rh
.Devise
, to_field
='code',
264 db_column
='devise', related_name
='+')
265 date_effective
= models
.DateField(null
=True, blank
=True)
266 pourcentage
= models
.IntegerField(null
=True, blank
=True)
269 date_creation
= models
.DateField(auto_now_add
=True)
270 user_creation
= models
.IntegerField(null
=True, blank
=True)
271 desactivation
= models
.BooleanField(default
=False, blank
=True)
272 date_desactivation
= models
.DateField(null
=True, blank
=True)
273 user_desactivation
= models
.IntegerField(null
=True, blank
=True)
274 annulation
= models
.BooleanField(default
=False, blank
=True)
275 date_annulation
= models
.DateField(null
=True, blank
=True)
276 user_annulation
= models
.IntegerField(null
=True, blank
=True)
279 class JustificationPoste(models
.Model
):
283 class JustificationEmploye(models
.Model
):
287 class DocumentPoste(models
.Model
):
291 class DocumentEmploye(models
.Model
):
295 class Validation(models
.Model
):
297 date
= models
.DateField()
299 # avis = ? (CHOICES?)
302 class ValidationPoste(models
.Model
):
303 poste
= models
.ForeignKey('Poste')
306 class ValidationEmploye(models
.Model
):
307 employe
= models
.ForeignKey('Employe')
310 class TypeRemuneration(models
.Model
):
311 ordre
= models
.IntegerField()
312 groupe
= models
.ForeignKey('GroupeTypeRemuneration')
315 class GroupeTypeRemuneration(models
.Model
):
316 nom
= models
.CharField(max_length
=255)
317 ordre
= models
.IntegerField()