first commit
This commit is contained in:
19
Base/Metrics/Dashboard/get_sum_of_service.py
Normal file
19
Base/Metrics/Dashboard/get_sum_of_service.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# from django.utils import timezone
|
||||
from django.db.models import Sum
|
||||
from Base.models import ServiceList
|
||||
from Movement.models import Calendar
|
||||
|
||||
def metric(Day):
|
||||
Service = ServiceList.objects.all()
|
||||
Serv_report = {}
|
||||
for Serv in Service:
|
||||
service = Calendar.objects.filter(
|
||||
service__name=Serv.name,
|
||||
date=Day
|
||||
).aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
Serv_report[Serv.name] = service
|
||||
sum_ = sum(Serv_report.values()) or 0
|
||||
return {
|
||||
'Service':Serv_report,
|
||||
'sum':sum_,
|
||||
}
|
||||
Reference in New Issue
Block a user