fixes
[auf_rh_dae.git] / project / rh / lib.py
1 # -*- encoding: utf-8 -*-
2
3 from collections import defaultdict
4 import datetime
5
6 from django.db import models
7 from django import forms
8 from django.core.urlresolvers import reverse
9 from django.contrib import admin
10 from django.conf import settings
11 from django.db.models import Q
12 from ajax_select import make_ajax_form
13 from auf.django.metadata.admin import AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, AUF_METADATA_READONLY_FIELDS
14 from project.rh import models as rh
15 from forms import ContratForm, AyantDroitForm, EmployeAdminForm, AjaxSelect
16 from dae.utils import get_employe_from_user
17
18
19 # Desactivation des bactch action a cause des managers qui delete
20 AUFMetadataAdminMixin.actions = None
21
22 # Override of the InlineModelAdmin to support the link in the tabular inline
23 class LinkedInline(admin.options.InlineModelAdmin):
24 template = "admin/linked.html"
25 admin_model_path = None
26
27 def __init__(self, *args):
28 super(LinkedInline, self).__init__(*args)
29 if self.admin_model_path is None:
30 self.admin_model_path = self.model.__name__.lower()
31
32
33 class ProtectRegionMixin(object):
34
35 def queryset(self, request):
36 from dae.workflow import grp_drh, grp_correspondants_rh
37 qs = super(ProtectRegionMixin, self).queryset(request)
38
39 if request.user.is_superuser:
40 return qs
41
42 user_groups = request.user.groups.all()
43
44 if grp_drh in user_groups:
45 return qs
46
47 if grp_correspondants_rh in user_groups:
48 employe = get_employe_from_user(request.user)
49 q = Q(**{self.model.prefix_implantation: employe.implantation.region})
50 qs = qs.filter(q).distinct()
51 return qs
52 return qs.none()
53
54 def has_change_permission(self, request, obj=None):
55 if obj is None:
56 return True
57 ids = [o.id for o in self.queryset(request)]
58 return obj.id in ids
59
60
61 # Inlines
62
63 class ReadOnlyInlineMixin(object):
64 def get_readonly_fields(self, request, obj=None):
65 return [f.name for f in self.model._meta.fields if f.name not in AUF_METADATA_READONLY_FIELDS]
66
67
68 class AyantDroitInline(AUFMetadataInlineAdminMixin, admin.StackedInline):
69 model = models.Model # à remplacer dans admin.py
70 form = AyantDroitForm
71 extra = 0
72
73 fieldsets = (
74 (None, {
75 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', 'lien_parente', )
76 }),
77 )
78
79
80 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
81 readonly_fields = ('owner', )
82 model = models.Model # à remplacer dans admin.py
83 extra = 1
84
85
86 class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
87 form = ContratForm
88 model = models.Model # à remplacer dans admin.py
89 extra = 1
90
91
92 class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
93 template = "admin/rh/dossier/linked.html"
94 exclude = AUF_METADATA_READONLY_FIELDS
95 model = models.Model # à remplacer dans admin.py
96 extra = 0
97 can_delete = False
98
99 def has_add_permission(self, request=None):
100 return False
101
102 def has_change_permission(self, request, obj=None):
103 return False
104
105 def has_delete_permission(self, request, obj=None):
106 return False
107
108
109 class DossierCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
110 readonly_fields = ('owner', )
111 model = models.Model # à remplacer dans admin.py
112 extra = 1
113
114
115 class DossierPieceInline(admin.TabularInline):
116 model = models.Model # à remplacer dans admin.py
117 extra = 4
118
119
120 class EmployeInline(admin.TabularInline):
121 model = models.Model # à remplacer dans admin.py
122
123 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
124 readonly_fields = ('owner', )
125 model = models.Model # à remplacer dans admin.py
126 extra = 1
127
128
129 class EmployePieceInline(admin.TabularInline):
130 model = models.Model # à remplacer dans admin.py
131 extra = 4
132
133
134 class EvenementInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
135 model = models.Model # à remplacer dans admin.py
136 extra = 1
137
138
139 class EvenementRemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
140 model = models.Model # à remplacer dans admin.py
141 extra = 1
142
143
144 class PosteCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
145 readonly_fields = ('owner', )
146 model = models.Model # à remplacer dans admin.py
147 extra = 1
148
149
150 class PosteFinancementInline(admin.TabularInline):
151 model = models.Model # à remplacer dans admin.py
152
153
154 class PostePieceInline(admin.TabularInline):
155 model = models.Model # à remplacer dans admin.py
156
157
158 class RemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
159 model = models.Model # à remplacer dans admin.py
160 extra = 1
161
162
163 class RemunerationROInline(ReadOnlyInlineMixin, RemunerationInline):
164 pass
165
166
167 class TypePosteInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
168 model = models.Model # à remplacer dans admin.py
169
170
171 # Admins
172
173 class AyantDroitAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
174 """
175 L'ajout d'un nouvel ayantdroit se fait dans l'admin de l'employé.
176 """
177 alphabet_filter = 'nom'
178 search_fields = ('nom', 'prenom', 'employe__nom', 'employe__prenom', )
179 list_display = ('_employe', 'lien_parente', '_ayantdroit', )
180 inlines = (AyantDroitCommentaireInline,)
181 readonly_fields = AUFMetadataAdminMixin.readonly_fields + ('employe',)
182 fieldsets = AUFMetadataAdminMixin.fieldsets + (
183 ("Lien avec l'employé", {
184 'fields': (('employe', 'lien_parente'), )
185 }),
186
187 ('Identification', {
188 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
189 }),
190 )
191
192 def save_formset(self, request, form, formset, change):
193 instances = formset.save(commit=False)
194 for instance in instances:
195 if instance.__class__ == rh.AyantDroitCommentaire:
196 instance.owner = request.user
197 instance.save()
198
199 def _ayantdroit(self, obj):
200 return unicode(obj)
201 _ayantdroit.short_description = u'Ayant droit'
202
203 def _employe(self, obj):
204 return unicode(obj.employe)
205 _employe.short_description = u'Employé'
206
207 def has_add_permission(self, request):
208 return False
209
210 class AyantDroitCommentaireAdmin(admin.ModelAdmin):
211 pass
212
213
214 class ClassementAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
215 fieldsets = AUFMetadataAdminMixin.fieldsets + (
216 (None, {
217 'fields': ('type', 'echelon', 'degre', 'coefficient', )
218 }),
219 )
220
221
222 class CommentaireAdmin(admin.ModelAdmin):
223 pass
224
225
226 #class ContratAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
227 # form = ContratForm
228 # alphabet_filter = 'dossier__employe__nom'
229 # search_fields = ('dossier__employe__nom', 'dossier__employe__prenom', 'dossier__poste__nom', 'dossier__poste__nom_feminin', )
230 # list_display = ('id', '_employe', '_poste', 'date_debut', 'date_fin', '_implantation', )
231 # fieldsets = AUFMetadataAdminMixin.fieldsets + (
232 # (None, {
233 # 'fields': ('dossier', 'type_contrat', 'date_debut', 'date_fin', )
234 # }),
235 # )
236 #
237 # def lookup_allowed(self, key, value):
238 # if key in ('dossier__employe__nom__istartswith', ):
239 # return True
240 #
241 # def _employe(self, obj):
242 # return unicode(obj.dossier.employe)
243 # _employe.short_description = "Employé"
244 #
245 # def _poste(self, obj):
246 # return obj.dossier.poste.nom
247 # _poste.short_description = "Poste"
248 #
249 # def _implantation(self, obj):
250 # return obj.dossier.poste.implantation
251 # _poste.short_description = "Implantation"
252
253 class DeviseAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
254 fieldsets = AUFMetadataAdminMixin.fieldsets + (
255 (None, {
256 'fields': ('code', 'nom', ),
257 }),
258 )
259
260
261 class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
262 alphabet_filter = 'employe__nom'
263 search_fields = ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin')
264 list_display = ('_id', '_employe', '_actif', '_poste', 'date_debut', 'date_fin', 'date_modification')
265 list_filter = ('poste__implantation__region', 'poste__implantation', )
266 inlines = (DossierPieceInline, ContratInline,
267 RemunerationInline,
268 #EvenementInline,
269 DossierCommentaireInline,
270 )
271 fieldsets = AUFMetadataAdminMixin.fieldsets + (
272 (None, {
273 'fields': ('employe', 'poste', 'statut', 'organisme_bstg',)
274 }),
275 ('Recrutement', {
276 'fields': ('statut_residence', 'remplacement', 'remplacement_de', )
277 }),
278 ('Rémunération', {
279 'fields': ('classement', ('regime_travail', 'regime_travail_nb_heure_semaine'),)
280 }),
281 ('Occupation du Poste par cet Employe', {
282 'fields': (('date_debut', 'date_fin'), )
283 }),
284 )
285 form = make_ajax_form(rh.Dossier, {
286 'employe' : 'employes',
287 'poste' : 'postes',
288 'remplacement_de' : 'dossiers',
289 })
290
291 def lookup_allowed(self, key, value):
292 if key in (
293 'employe__nom__istartswith',
294 'actif__exact',
295 'poste__implantation__region__id__exact',
296 'poste__implantation__id__exact',
297 ):
298 return True
299
300 def _id(self, d):
301 link = u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>%s</a> <a href="%s" title="Modifier le dossier"><img src="%simg/page_edit.png" /></a>""" % \
302 (reverse('dossier_apercu', args=(d.id,)),
303 d.id,
304 reverse('admin:rh_dossier_change', args=(d.id,)),
305 settings.MEDIA_URL,
306 )
307 return link
308 _id.allow_tags = True
309 _id.short_description = u'Numéro de dossier'
310 _id.admin_order_field = 'id'
311
312
313 def _actif(self, dossier):
314 if dossier.employe.actif:
315 html = """<img alt="True" src="%simg/admin/icon-yes.gif">"""
316 else:
317 html = """<img alt="False" src="%simg/admin/icon-no.gif">"""
318 return html % settings.ADMIN_MEDIA_PREFIX
319 _actif.allow_tags = True
320 _actif.short_description = u'Employé actif'
321 _actif.admin_order_field = 'employe__actif'
322
323 def _poste(self, dossier):
324 link = u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>%s</a> <a href="%s" title="Modifier le poste"><img src="%simg/page_edit.png" /></a>""" % \
325 (reverse('poste_apercu', args=(dossier.poste.id,)),
326 dossier.poste,
327 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
328 settings.MEDIA_URL,
329 )
330 return link
331 _poste.allow_tags = True
332 _poste.short_description = u'Poste'
333 _poste.admin_order_field = 'poste__nom'
334
335 def _employe(self, obj):
336 employe = obj.employe
337 view_link = reverse('employe_apercu', args=(employe.id,))
338 edit_link = reverse('admin:rh_employe_change', args=(employe.id,))
339 return u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>[%s] %s %s</a>
340 <a href="%s" title="Modifier l'employé"><img src="%simg/user_edit.png" /></a>""" % \
341 (view_link, employe.id, employe.nom.upper(), employe.prenom.title(), edit_link, settings.MEDIA_URL,)
342 _employe.allow_tags = True
343 _employe.short_description = u"Employé ([code] NOM Prénom)"
344 _employe.admin_order_field = "employe__nom"
345
346 def save_formset(self, request, form, formset, change):
347 instances = formset.save(commit=False)
348 for instance in instances:
349 if instance.__class__ == rh.DossierCommentaire:
350 instance.owner = request.user
351 instance.save()
352
353
354 class DossierPieceAdmin(admin.ModelAdmin):
355 pass
356
357
358 class DossierCommentaireAdmin(admin.ModelAdmin):
359 pass
360
361
362 class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
363 alphabet_filter = 'nom'
364 DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
365 search_fields = ('id', 'nom', 'prenom', 'nom_affichage', )
366 ordering = ('nom', )
367 form = EmployeAdminForm
368 list_display = ('_nom', '_dossiers', 'date_modification', 'user_modification',)
369 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'actif', )
370 inlines = (AyantDroitInline,
371 DossierROInline,
372 EmployePieceInline,
373 EmployeCommentaireInline)
374 fieldsets = AUFMetadataAdminMixin.fieldsets + (
375 ('Identification', {
376 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
377 }),
378 ('Informations personnelles', {
379 'fields': ('situation_famille', 'date_entree', )
380 }),
381 ('Coordonnées', {
382 'fields': (('tel_domicile', 'tel_cellulaire'), ('adresse', 'ville'), ('code_postal', 'province'), 'pays', )
383 }),
384 )
385
386 def _nom(self, obj):
387 view_link = reverse('employe_apercu', args=(obj.id,))
388 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
389 return u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>[%s] %s %s</a>
390 <a href="%s" title="Modifier l'employé"><img src="%simg/user_edit.png" /></a>""" % \
391 (view_link, obj.id, obj.nom.upper(), obj.prenom.title(), edit_link, settings.MEDIA_URL,)
392 _nom.allow_tags = True
393 _nom.short_description = u"Employé ([code] NOM Prénom)"
394 _nom.admin_order_field = "nom"
395
396 def _dossiers(self, obj):
397 l = []
398 for d in obj.dossiers.all().order_by('-date_debut'):
399 style = ""
400 if d.date_fin is not None:
401 style = "color: grey";
402 link = u"""<li><a style="%s;" onclick="return showAddAnotherPopup(this);" href='%s'>%s : %s</a> <a href="%s" title="Modifier le dossier"><img src="%simg/page_edit.png" /></a> </li>""" % \
403 (style,
404 reverse('dossier_apercu', args=(d.id,)),
405 d.date_debut.year,
406 d.poste,
407 reverse('admin:rh_dossier_change', args=(d.id,)),
408 settings.MEDIA_URL,
409 )
410 l.append(link)
411 return "<ul>%s</ul>" % "\n".join(l)
412 _dossiers.allow_tags = True
413
414 def queryset(self, request):
415 qs = super(EmployeAdmin, self).queryset(request)
416 return qs.filter(actif=True).select_related(depth=1).order_by('nom')
417
418 def save_formset(self, request, form, formset, change):
419 instances = formset.save(commit=False)
420 for instance in instances:
421 if instance.__class__ == rh.EmployeCommentaire:
422 instance.owner = request.user
423 instance.save()
424
425
426
427 class EmployeCommentaireAdmin(admin.ModelAdmin):
428 pass
429
430
431 class EmployePieceAdmin(admin.ModelAdmin):
432 pass
433
434
435 class EvenementAdmin(admin.ModelAdmin):
436 inlines = (EvenementRemunerationInline,)
437
438
439 class EvenementRemunerationAdmin(admin.ModelAdmin):
440 pass
441
442
443 class FamilleEmploiAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
444 inlines = (TypePosteInline,)
445 fieldsets = AUFMetadataAdminMixin.fieldsets + (
446 (None, {
447 'fields': ('nom', )
448 }),
449 )
450
451
452 class OrganismeBstgAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
453 search_fields = ('nom', )
454 list_display = ('nom', 'type', 'pays', )
455 inlines = (DossierROInline,)
456 fieldsets = AUFMetadataAdminMixin.fieldsets + (
457 (None, {
458 'fields': ('nom', 'type', 'pays', )
459 }),
460 )
461
462
463 class PosteAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
464 form = make_ajax_form(rh.Poste, {
465 'implantation' : 'implantations',
466 'type_poste' : 'typepostes',
467 'responsable' : 'postes',
468 'valeur_point_min' : 'valeurpoints',
469 'valeur_point_max' : 'valeurpoints',
470 })
471 alphabet_filter = 'nom'
472 search_fields = ('nom',
473 'implantation__code',
474 'implantation__nom',
475 'implantation__region__code',
476 'implantation__region__nom',
477 )
478 list_display = (
479 '_nom',
480 '_occupe_par',
481 'implantation',
482 'service',
483 'date_debut',
484 'date_fin',
485 'date_modification',
486 'user_modification',
487 )
488 list_filter = ('service',
489 'implantation__region',
490 'implantation',
491 )
492 fieldsets = AUFMetadataAdminMixin.fieldsets + (
493 (None, {
494 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste',
495 'service', 'responsable')
496 }),
497 ('Contrat', {
498 'fields': (('regime_travail', 'regime_travail_nb_heure_semaine'), )
499 }),
500 ('Recrutement', {
501 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)
502 }),
503 ('Rémunération', {
504 'fields': (('classement_min', 'classement_max'),
505 ('valeur_point_min', 'valeur_point_max'),
506 ('devise_min', 'devise_max'),
507 ('salaire_min', 'salaire_max'),
508 ('indemn_min', 'indemn_max'),
509 ('autre_min', 'autre_max'))
510 }),
511 ('Comparatifs de rémunération', {
512 'fields': ('devise_comparaison',
513 ('comp_locale_min', 'comp_locale_max'),
514 ('comp_universite_min', 'comp_universite_max'),
515 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
516 ('comp_ong_min', 'comp_ong_max'),
517 ('comp_autre_min', 'comp_autre_max'))
518 }),
519 ('Justification', {
520 'fields': ('justification',)
521 }),
522 ('Autres Metadata', {
523 'fields': ('date_debut', 'date_fin')
524 }),
525 )
526
527 inlines = (PosteFinancementInline,
528 PostePieceInline,
529 DossierROInline,
530 PosteCommentaireInline, )
531
532
533 def _nom(self, poste):
534 link = u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>%s</a> <a href="%s" title="Modifier le poste"><img src="%simg/page_edit.png" /></a>""" % \
535 (reverse('poste_apercu', args=(poste.id,)),
536 poste.nom,
537 reverse('admin:rh_poste_change', args=(poste.id,)),
538 settings.MEDIA_URL,
539 )
540 return link
541 _nom.allow_tags = True
542 _nom.short_description = u'Nom'
543 _nom.admin_order_field = 'nom'
544
545 def _occupe_par(self, obj):
546 """Formatte la méthode Poste.occupe_par() pour l'admin"""
547 output = "VACANT"
548 employes = obj.occupe_par()
549 if employes:
550 l = []
551 for e in employes:
552 link = "<a href='%s'>%s</a>" % \
553 (reverse('admin:rh_employe_change', args=(e.id,)),
554 e)
555 l.append(link)
556 output = "\n<br />".join(l)
557 return output
558 _occupe_par.allow_tags = True
559 _occupe_par.short_description = "Occupé par"
560
561 def save_formset(self, request, form, formset, change):
562 instances = formset.save(commit=False)
563 for instance in instances:
564 if instance.__class__ == rh.PosteCommentaire:
565 instance.owner = request.user
566 instance.save()
567 formset.save_m2m()
568
569
570 class PosteCommentaireAdmin(admin.ModelAdmin):
571 pass
572
573
574 class PosteFinancementAdmin(admin.ModelAdmin):
575 pass
576
577
578 class PostePieceAdmin(admin.ModelAdmin):
579 fk_name = 'poste'
580
581
582 class RemunerationAdmin(admin.ModelAdmin):
583 pass
584
585
586 class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
587 fieldsets = AUFMetadataAdminMixin.fieldsets + (
588 (None, {
589 'fields': ('employe', 'implantation', ),
590 }),
591 )
592
593
594 class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
595 list_display = ('nom', 'actif', )
596 fieldsets = AUFMetadataAdminMixin.fieldsets + (
597 (None, {
598 'fields': ('nom', ),
599 }),
600 )
601
602 class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
603 fieldsets = AUFMetadataAdminMixin.fieldsets + (
604 (None, {
605 'fields': ('code', 'nom', ),
606 }),
607 )
608
609 class TauxChangeAdmin(admin.ModelAdmin):
610 list_display = ('taux', 'devise', 'annee', )
611 list_filter = ('devise', )
612 fieldsets = AUFMetadataAdminMixin.fieldsets + (
613 (None, {
614 'fields': ('taux', 'devise', 'annee', ),
615 }),
616 )
617
618 class TypeContratAdmin(admin.ModelAdmin):
619 inlines = (ContratInline,)
620 fieldsets = AUFMetadataAdminMixin.fieldsets + (
621 (None, {
622 'fields': ('nom', 'nom_long', ),
623 }),
624 )
625
626
627 class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
628 search_fields = ('nom', 'nom_feminin', )
629 list_display = ('nom', 'famille_emploi', )
630 list_filter = ('famille_emploi', )
631 fieldsets = AUFMetadataAdminMixin.fieldsets + (
632 (None, {
633 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
634 }),
635 )
636
637
638 class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
639 list_display = ('nom', 'type_paiement', 'nature_remuneration', )
640 #inlines = (RemunerationROInline,) utilité?
641 fieldsets = AUFMetadataAdminMixin.fieldsets + (
642 (None, {
643 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
644 }),
645 )
646
647
648 class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
649 #inlines = (RemunerationROInline,) utilité?
650 fieldsets = AUFMetadataAdminMixin.fieldsets + (
651 (None, {
652 'fields': ('nom', )
653 }),
654 )
655
656
657 class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
658 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', )
659 fieldsets = AUFMetadataAdminMixin.fieldsets + (
660 (None, {
661 'fields': ('valeur', 'devise', 'implantation', 'annee', )
662 }),
663 )
664
665 def _devise_code(self, obj):
666 return obj.devise.code
667 _devise_code.short_description = "Code de la devise"
668
669 def _devise_nom(self, obj):
670 return obj.devise.nom
671 _devise_nom.short_description = "Nom de la devise"
672
673
674 def calc_remun(dossier):
675 thisyear = datetime.date.today().year
676 thisyearfilter = Q(date_debut__year=thisyear) | Q(date_fin__year=thisyear)
677
678 remunnow = dossier.rh_remunerations.filter(thisyearfilter)
679
680 remun_sum = 0
681 remun_sum_euro = 0
682 sums = defaultdict(int)
683 sums_euro = defaultdict(int)
684 for r in remunnow:
685 nature = r.type.nature_remuneration
686 sums[nature] += r.montant
687 sums_euro[nature] += r.montant_euro()
688 remun_sum += r.montant
689 remun_sum_euro += r.montant_euro()
690
691 remun = {}
692 sums = dict(sums)
693 for n, s in sums.iteritems():
694 remun[n] = [sums[n], sums_euro[n]]
695
696 return remun, remun_sum, remun_sum_euro