1 from collections
import defaultdict
4 from django
.db
.models
import Q
5 from django
.utils
.encoding
import smart_str
8 def calc_remun(dossier
):
9 thisyear
= datetime
.date
.today().year
10 thisyearfilter
= Q(date_debut__year
=thisyear
) |
Q(date_fin__year
=thisyear
)
12 remunnow
= dossier
.rh_remunerations
.filter(thisyearfilter
)
16 sums
= defaultdict(int)
17 sums_euro
= defaultdict(int)
19 nature
= r
.type.nature_remuneration
20 sums
[nature
] += r
.montant
21 sums_euro
[nature
] += r
.montant_euros()
22 remun_sum
+= r
.montant
23 remun_sum_euro
+= r
.montant_euros()
27 for n
, s
in sums
.iteritems():
28 remun
[n
] = [sums
[n
], sums_euro
[n
]]
30 return remun
, remun_sum
, remun_sum_euro
32 def get_lookup_params(request
):
33 lookup_params
= dict(request
.GET
.items())
35 # order by, order type
36 if 'ot' in lookup_params
:
37 del lookup_params
['ot']
38 if 'o' in lookup_params
:
39 del lookup_params
['o']
42 for key
, value
in lookup_params
.items():
43 if not isinstance(key
, str):
44 # 'key' will be used as a keyword argument later, so Python
45 # requires it to be a string.
46 del lookup_params
[key
]
47 lookup_params
[smart_str(key
)] = value