5834
[auf_rh_dae.git] / project / dae / templatetags / dae.py
index 08088b3..e2ea834 100644 (file)
@@ -16,6 +16,7 @@ from project.dae.forms import (
     ReadOnlyRemunFormSet,
     PosteCompReadOnlyRemunFormSet,
     DossierCompReadOnlyRemunFormSet,
+    RHReadOnlyRemunFormSet,
     )
 from project.dae import models as dae
 from project.rh import models as rh
@@ -132,7 +133,7 @@ def dossier_cmp_remun_form(context, dossier_cmp):
 
 
 @register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
-def rh_remun_form_for_year(context, dossier, year):
+def rh_remun_form_for_year(context, dossier, year=None):
 
     fs = remun_formset_factory_factory(
         read_only=True,
@@ -140,7 +141,14 @@ def rh_remun_form_for_year(context, dossier, year):
         model=rh.Remuneration,
         )
 
-    def _get_qs(inst):
+    def _get_qs(inst, year=year):
+
+        if year == None:
+            year = (
+                inst.instance.date_fin.year if
+                inst.instance.date_fin else
+                datetime.date.today().year)
+
         year_start = datetime.date(year, 1, 1)
         year_end = datetime.date(year, 12, 31)
         qs = inst.model.objects.filter(
@@ -151,7 +159,7 @@ def rh_remun_form_for_year(context, dossier, year):
                 Q(date_debut__isnull=True, date_fin__isnull=True)
                 ))
         return qs
-        
+
     fs.get_queryset = _get_qs
 
     return {