test_calc_imputations_3
This commit is contained in:
parent
32861d10af
commit
390f563ac0
2 changed files with 28 additions and 6 deletions
|
|
@ -149,11 +149,6 @@ class Teacher(models.Model):
|
|||
for key in imputations:
|
||||
imputations[key] = courses.filter(imputation__contains=key).aggregate(models.Sum('period'))['period__sum'] or 0
|
||||
|
||||
tot = sum(imputations.values())
|
||||
if tot > 0:
|
||||
for key in imputations:
|
||||
imputations[key] += round(imputations[key] / tot * activities['tot_formation'])
|
||||
|
||||
# Split EDE periods in EDEpe and EDEps columns, in proportion
|
||||
ede = courses.filter(imputation='EDE').aggregate(models.Sum('period'))['period__sum'] or 0
|
||||
if ede > 0:
|
||||
|
|
@ -164,7 +159,21 @@ class Teacher(models.Model):
|
|||
imputations['EDEpe'] += pe_plus
|
||||
imputations['EDEps'] += ede - pe_plus
|
||||
|
||||
return (self.calc_activity(), imputations)
|
||||
# Split formation periods in proportions
|
||||
tot = sum(imputations.values())
|
||||
if tot > 0:
|
||||
for key in imputations:
|
||||
imputations[key] += round(imputations[key] / tot * activities['tot_formation'])
|
||||
|
||||
# Correct for rounding errors changing the first imputations value
|
||||
tot = sum(imputations.values()) + self.previous_report - (self.next_report)
|
||||
dif = tot - activities['tot_paye']
|
||||
if dif in [-1, 1]:
|
||||
for k, v in imputations.items():
|
||||
if v > 0:
|
||||
imputations[k] += 1 if dif == -1 else -1
|
||||
break
|
||||
return (activities, imputations)
|
||||
|
||||
def total_logbook(self):
|
||||
return LogBook.objects.filter(teacher=self).aggregate(models.Sum('nb_period'))['nb_period__sum']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue