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 Poste(models
.Model
):
26 id_rh
= models
.ForeignKey(rh
.Poste
, null
=True, related_name
='+',
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,
35 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
40 statut_residence
= models
.CharField(max_length
=10, default
='MAD',
41 choices
=STATUT_RESIDENCE_CHOICES
)
43 mise_a_disposition
= models
.BooleanField()
44 appel
= models
.CharField(max_length
=10, default
='interne',
45 choices
=POSTE_APPEL_CHOICES
)
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,
54 salaire_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
56 indemn_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
58 indemn_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
60 autre_min
= models
.DecimalField(max_digits
=12, decimal_places
=2,
62 autre_max
= models
.DecimalField(max_digits
=12, decimal_places
=2,
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)
90 date_creation
= models
.DateTimeField(auto_now_add
=True)
91 date_modification
= models
.DateTimeField(auto_now
=True)
92 date_debut
= models
.DateField(help_text
="format: aaaa-mm-jj")
93 date_fin
= models
.DateField(null
=True, help_text
="format: aaaa-mm-jj")
94 actif
= models
.BooleanField(default
=True)
96 def __unicode__(self
):
97 return u
'%s - %s (%s)' % (self
.implantation
, self
.type_poste
.nom
,
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
)
116 POSTE_FINANCEMENT_CHOICES
= (
117 ('A', 'A - Frais de personnel'),
118 ('B', 'B - Projet(s)-Titre(s)'),
123 class PosteFinancement(models
.Model
):
124 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2)
125 poste
= models
.ForeignKey('Poste', related_name
='financements')
126 type = models
.CharField(max_length
=1, choices
=POSTE_FINANCEMENT_CHOICES
)
127 pourcentage
= models
.DecimalField(max_digits
=12, decimal_places
=2)
128 commentaire
= models
.TextField()
137 class Employe(models
.Model
):
140 id_rh
= models
.ForeignKey(rh
.Employe
, null
=True, related_name
='+')
141 nom
= models
.CharField(max_length
=255)
142 prenom
= models
.CharField(max_length
=255)
143 genre
= models
.CharField(max_length
=1, choices
=GENRE_CHOICES
,
144 null
=True, blank
=True)
146 def __unicode__(self
):
147 return u
'%s %s' % (self
.prenom
, self
.nom
)
150 COMPTE_COMPTA_CHOICES
= (
157 class Dossier(models
.Model
):
160 employe
= models
.ForeignKey('Employe', related_name
='+', editable
=False)
161 poste
= models
.ForeignKey('Poste', related_name
='+', editable
=False)
162 statut
= models
.ForeignKey(rh
.Statut
, related_name
='+')
163 organisme_bstg
= models
.ForeignKey(rh
.OrganismeBstg
, related_name
='+')
165 # Données antérieures de l'employé
166 statut_anterieur
= models
.ForeignKey(
167 rh
.Statut
, related_name
='+', null
=True, blank
=True,
168 verbose_name
='Statut précédent')
169 classement_anterieur
= models
.ForeignKey(
170 rh
.Classement
, related_name
='+', null
=True, blank
=True,
171 verbose_name
='Classement précédent')
172 salaire_anterieur
= models
.DecimalField(
173 max_digits
=12, decimal_places
=2, null
=True, default
=None,
174 blank
=True, verbose_name
='Salaire précédent')
176 # Données du titulaire précédent
177 employe_anterieur
= models
.ForeignKey(
178 rh
.Employe
, related_name
='+', null
=True, blank
=True,
179 verbose_name
='Employé précédent')
180 statut_titulaire_anterieur
= models
.ForeignKey(
181 rh
.Statut
, related_name
='+', null
=True, blank
=True,
182 verbose_name
='Statut titulaire précédent')
183 classement_titulaire_anterieur
= models
.ForeignKey(
184 rh
.Classement
, related_name
='+', null
=True, blank
=True,
185 verbose_name
='Classement titulaire précédent')
186 salaire_titulaire_anterieur
= models
.DecimalField(
187 max_digits
=12, decimal_places
=2, default
=None, null
=True,
188 blank
=True, verbose_name
='Salaire titulaire précédent')
191 remplacement
= models
.BooleanField()
192 statut_residence
= models
.CharField(max_length
=10,
193 choices
=STATUT_RESIDENCE_CHOICES
)
196 classement
= models
.ForeignKey(rh
.Classement
, related_name
='+',
197 verbose_name
='Classement proposé')
198 salaire
= models
.DecimalField(max_digits
=12, decimal_places
=2,
199 verbose_name
='Salaire de base',
200 null
=True, default
=None)
201 devise
= models
.ForeignKey(rh
.Devise
, related_name
='+')
202 regime_travail
= models
.DecimalField(max_digits
=12, decimal_places
=2)
203 regime_travail_nb_heure_semaine
= models
.DecimalField(max_digits
=12,
207 type_contrat
= models
.ForeignKey(rh
.TypeContrat
, related_name
='+')
208 contrat_date_debut
= models
.DateField()
209 contrat_date_fin
= models
.DateField()
212 compte_compta
= models
.CharField(max_length
=10,
213 choices
=COMPTE_COMPTA_CHOICES
)
214 compte_courriel
= models
.BooleanField()
217 class Remuneration(models
.Model
):
219 id = models
.IntegerField(primary_key
=True)
220 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
221 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
223 # type_revalorisation = models.ForeignKey('TypeRevalorisation',
224 # db_column='type_revalorisation')
225 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2) # Annuel
226 devise
= models
.ForeignKey(rh
.Devise
, to_field
='code',
227 db_column
='devise', related_name
='+')
228 date_effective
= models
.DateField(null
=True, blank
=True)
229 pourcentage
= models
.IntegerField(null
=True, blank
=True)
232 date_creation
= models
.DateField(auto_now_add
=True)
233 user_creation
= models
.IntegerField(null
=True, blank
=True)
234 desactivation
= models
.BooleanField(default
=False, blank
=True)
235 date_desactivation
= models
.DateField(null
=True, blank
=True)
236 user_desactivation
= models
.IntegerField(null
=True, blank
=True)
237 annulation
= models
.BooleanField(default
=False, blank
=True)
238 date_annulation
= models
.DateField(null
=True, blank
=True)
239 user_annulation
= models
.IntegerField(null
=True, blank
=True)
242 class JustificationPoste(models
.Model
):
246 class JustificationEmploye(models
.Model
):
250 class DocumentPoste(models
.Model
):
254 class DocumentEmploye(models
.Model
):
258 class Validation(models
.Model
):
260 date
= models
.DateField()
262 # avis = ? (CHOICES?)
265 class ValidationPoste(models
.Model
):
266 poste
= models
.ForeignKey('Poste')
269 class ValidationEmploye(models
.Model
):
270 employe
= models
.ForeignKey('Employe')
273 class TypeRemuneration(models
.Model
):
274 ordre
= models
.IntegerField()
275 groupe
= models
.ForeignKey('GroupeTypeRemuneration')
278 class GroupeTypeRemuneration(models
.Model
):
279 nom
= models
.CharField(max_length
=255)
280 ordre
= models
.IntegerField()