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