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 verbose_name
="Temps de travail",
60 help_text
="% du temps complet")
61 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
64 verbose_name
="Nb. heures par semaine")
67 statut_residence
= models
.CharField(max_length
=10, default
='MAD',
68 verbose_name
="Statut",
69 choices
=STATUT_RESIDENCE_CHOICES
)
71 mise_a_disposition
= models
.BooleanField()
72 appel
= models
.CharField(max_length
=10, default
='interne',
73 verbose_name
="Appel à candidature",
74 choices
=POSTE_APPEL_CHOICES
)
77 classement_min
= models
.ForeignKey(rh
.Classement
, related_name
='+')
78 classement_max
= models
.ForeignKey(rh
.Classement
, related_name
='+')
79 valeur_point_min
= models
.ForeignKey(rh
.ValeurPoint
, related_name
='+')
80 valeur_point_max
= models
.ForeignKey(rh
.ValeurPoint
, related_name
='+')
81 salaire_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
83 salaire_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
85 indemn_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
87 indemn_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
89 autre_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
91 autre_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
94 # Comparatifs de rémunération
95 devise_comparaison
= models
.ForeignKey(rh
.Devise
, related_name
='+',
96 null
=True, blank
=True)
97 comp_locale_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
98 null
=True, blank
=True)
99 comp_locale_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
100 null
=True, blank
=True)
101 comp_universite_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
102 null
=True, blank
=True)
103 comp_universite_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
104 null
=True, blank
=True)
105 comp_fonctionpub_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
106 null
=True, blank
=True)
107 comp_fonctionpub_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
108 null
=True, blank
=True)
109 comp_ong_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
110 null
=True, blank
=True)
111 comp_ong_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
112 null
=True, blank
=True)
113 comp_autre_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
114 null
=True, blank
=True)
115 comp_autre_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
116 null
=True, blank
=True)
119 date_creation
= models
.DateTimeField(auto_now_add
=True)
120 date_modification
= models
.DateTimeField(auto_now
=True)
121 date_debut
= models
.DateField(verbose_name
="Date de début",
122 help_text
="format: aaaa-mm-jj")
123 date_fin
= models
.DateField(null
=True, blank
=True,
124 verbose_name
="Date de fin",
125 help_text
="format: aaaa-mm-jj")
126 actif
= models
.BooleanField(default
=True)
129 objects
= PosteManager()
131 def __unicode__(self
):
132 return u
'%s - %s (%s) [dae-%s]' % (self
.implantation
, self
.type_poste
.nom
,
135 def DISABLED_save(self
, *args
, **kwargs
):
136 # calculate nb_mois = nb of months between date_debut and date_fin
137 from datetime
import date
138 if not self
.salaire_min
:
139 self
.salaire_min
= self
.classement_min
* self
.valeur_point_min
140 if not self
.salaire_max
:
141 self
.salaire_max
= self
.classement_max
* self
.valeur_point_min
142 if not self
.valeur_point_min
:
143 self
.valeur_point_min
= \
144 rh
.ValeurPoint
.objects
.filter(implantation
=self
.implantation
)
145 if not self
.valeur_point_max
:
146 self
.valeur_point_max
= \
147 rh
.ValeurPoint
.objects
.filter(implantation
=self
.implantation
)
148 super(Subject
, self
).save(*args
, **kwargs
)
151 POSTE_FINANCEMENT_CHOICES
= (
152 ('A', 'A - Frais de personnel'),
153 ('B', 'B - Projet(s)-Titre(s)'),
158 class PosteFinancement(models
.Model
):
159 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2,
160 help_text
="ex.: 12000.00 € (décimale avec point, devise = EUR)")
161 poste
= models
.ForeignKey('Poste', related_name
='financements')
162 type = models
.CharField(max_length
=1, choices
=POSTE_FINANCEMENT_CHOICES
)
163 pourcentage
= models
.DecimalField(max_digits
=12, decimal_places
=2,
164 help_text
="ex.: 33.33 % (décimale avec point)")
165 commentaire
= models
.TextField(
166 help_text
="Spécifiez la source de financement.")
177 class Employe(models
.Model
):
180 id_rh
= models
.ForeignKey(rh
.Employe
, null
=True, related_name
='+')
181 nom
= models
.CharField(max_length
=255)
182 prenom
= models
.CharField(max_length
=255)
183 genre
= models
.CharField(max_length
=1, choices
=GENRE_CHOICES
,
184 null
=True, blank
=True)
186 def __unicode__(self
):
187 return u
'%s %s' % (self
.prenom
, self
.nom
)
190 COMPTE_COMPTA_CHOICES
= (
197 class Dossier(models
.Model
):
200 employe
= models
.ForeignKey('Employe', related_name
='+', editable
=False)
201 poste
= models
.ForeignKey('Poste', related_name
='+', editable
=False)
202 statut
= models
.ForeignKey(rh
.Statut
, related_name
='+')
203 organisme_bstg
= models
.ForeignKey(rh
.OrganismeBstg
, related_name
='+')
205 # Données antérieures de l'employé
206 statut_anterieur
= models
.ForeignKey(
207 rh
.Statut
, related_name
='+', null
=True, blank
=True,
208 verbose_name
='Statut précédent')
209 classement_anterieur
= models
.ForeignKey(
210 rh
.Classement
, related_name
='+', null
=True, blank
=True,
211 verbose_name
='Classement précédent')
212 salaire_anterieur
= models
.DecimalField(
213 max_digits
=12, decimal_places
=2, null
=True, default
=None,
214 blank
=True, verbose_name
='Salaire précédent')
216 # Données du titulaire précédent
217 employe_anterieur
= models
.ForeignKey(
218 rh
.Employe
, related_name
='+', null
=True, blank
=True,
219 verbose_name
='Employé précédent')
220 statut_titulaire_anterieur
= models
.ForeignKey(
221 rh
.Statut
, related_name
='+', null
=True, blank
=True,
222 verbose_name
='Statut titulaire précédent')
223 classement_titulaire_anterieur
= models
.ForeignKey(
224 rh
.Classement
, related_name
='+', null
=True, blank
=True,
225 verbose_name
='Classement titulaire précédent')
226 salaire_titulaire_anterieur
= models
.DecimalField(
227 max_digits
=12, decimal_places
=2, default
=None, null
=True,
228 blank
=True, verbose_name
='Salaire titulaire précédent')
231 remplacement
= models
.BooleanField()
232 statut_residence
= models
.CharField(max_length
=10,
233 choices
=STATUT_RESIDENCE_CHOICES
)
236 classement
= models
.ForeignKey(rh
.Classement
, related_name
='+',
237 verbose_name
='Classement proposé')
238 salaire
= models
.DecimalField(max_digits
=12, decimal_places
=2,
239 verbose_name
='Salaire de base',
240 null
=True, default
=None)
241 devise
= models
.ForeignKey(rh
.Devise
, related_name
='+')
242 regime_travail
= models
.DecimalField(max_digits
=12, decimal_places
=2,
243 verbose_name
="Régime de travail")
244 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
245 decimal_places
=2, verbose_name
="Nbr heures par semaine")
248 type_contrat
= models
.ForeignKey(rh
.TypeContrat
, related_name
='+')
249 contrat_date_debut
= models
.DateField()
250 contrat_date_fin
= models
.DateField()
253 compte_compta
= models
.CharField(max_length
=10,
254 choices
=COMPTE_COMPTA_CHOICES
)
255 compte_courriel
= models
.BooleanField()
258 class Remuneration(models
.Model
):
260 id = models
.IntegerField(primary_key
=True)
261 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
262 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
264 # type_revalorisation = models.ForeignKey('TypeRevalorisation',
265 # db_column='type_revalorisation')
266 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2) # Annuel
267 devise
= models
.ForeignKey(rh
.Devise
, to_field
='code',
268 db_column
='devise', related_name
='+')
269 date_effective
= models
.DateField(null
=True, blank
=True)
270 pourcentage
= models
.IntegerField(null
=True, blank
=True)
273 date_creation
= models
.DateField(auto_now_add
=True)
274 user_creation
= models
.IntegerField(null
=True, blank
=True)
275 desactivation
= models
.BooleanField(default
=False, blank
=True)
276 date_desactivation
= models
.DateField(null
=True, blank
=True)
277 user_desactivation
= models
.IntegerField(null
=True, blank
=True)
278 annulation
= models
.BooleanField(default
=False, blank
=True)
279 date_annulation
= models
.DateField(null
=True, blank
=True)
280 user_annulation
= models
.IntegerField(null
=True, blank
=True)
283 class JustificationPoste(models
.Model
):
287 class JustificationEmploye(models
.Model
):
291 class DocumentPoste(models
.Model
):
295 class DocumentEmploye(models
.Model
):
299 class Validation(models
.Model
):
301 date
= models
.DateField()
303 # avis = ? (CHOICES?)
306 class ValidationPoste(models
.Model
):
307 poste
= models
.ForeignKey('Poste')
310 class ValidationEmploye(models
.Model
):
311 employe
= models
.ForeignKey('Employe')
314 class TypeRemuneration(models
.Model
):
315 ordre
= models
.IntegerField()
316 groupe
= models
.ForeignKey('GroupeTypeRemuneration')
319 class GroupeTypeRemuneration(models
.Model
):
320 nom
= models
.CharField(max_length
=255)
321 ordre
= models
.IntegerField()