Commit | Line | Data |
---|---|---|
ed3cbb32 OL |
1 | import datetime |
2 | from django.db.models import Q | |
3 | from collections import defaultdict | |
49c98347 PP |
4 | |
5 | def calc_remun(dossier): | |
6 | thisyear = datetime.date.today().year | |
7 | thisyearfilter = Q(date_debut__year=thisyear) | Q(date_fin__year=thisyear) | |
8 | ||
da6c523f | 9 | remunnow = dossier.rh_remunerations.filter(thisyearfilter) |
49c98347 PP |
10 | |
11 | remun_sum = 0 | |
12 | remun_sum_euro = 0 | |
13 | sums = defaultdict(int) | |
14 | sums_euro = defaultdict(int) | |
15 | for r in remunnow: | |
16 | nature = r.type.nature_remuneration | |
17 | sums[nature] += r.montant | |
18 | sums_euro[nature] += r.montant_euro() | |
19 | remun_sum += r.montant | |
20 | remun_sum_euro += r.montant_euro() | |
21 | ||
22 | remun = {} | |
23 | sums = dict(sums) | |
24 | for n, s in sums.iteritems(): | |
25 | remun[n] = [sums[n], sums_euro[n]] | |
26 | ||
27 | return remun, remun_sum, remun_sum_euro | |
53ae644d OL |
28 | |
29 |