def get_boss_days(self):
days = DayActivity.objects.filter(
delay_pending__gt = 0,
month_activity__is_changeable = False,
month_activity__automatic_compensation = True
)
#REMOVENDO SERVIDORES SEM SALDO
servidores_pk = days.exclude(chefe_imediato__isnull=True).values_list('employee', flat=True)
servidores = Servidor.objects.filter(id__in=servidores).distinct()
sem_saldo = []
sem_saldo_pk = []
for s in servidores:
ma = None
ma = MonthActivity.objects.filter(employee=s,month_activity__is_changeable = False).first()
if ma.get_balance_valid <= 0:
sem_saldo_pk.append(ma.employee.pk)
days = days.exclude(employee__in=sem_saldo_pk)
#PEGANDO OS CHEFES
pk_chefes = days.exclude(employee__chefe_imediato__isnull=True).values_list('employee__chefe_imediato', flat=True)
chefes = Servidor.objects.filter(pk__in=pk_chefes).distinct()
return {'chefes':chefes,'days':days}