first commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24
Base/Metrics/Dashboard/get_sum_of_product.py
Normal file
24
Base/Metrics/Dashboard/get_sum_of_product.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.db.models import Sum
|
||||
from Base.models import ProductList
|
||||
from Movement.models import Product
|
||||
|
||||
def metric(Day):
|
||||
products = ProductList.objects.all()
|
||||
product_mov = Product.objects.filter(date=Day).values()
|
||||
product_report = {}
|
||||
for product in products:
|
||||
product_item = product_mov.filter(
|
||||
product__name=product.name,
|
||||
).aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
product_cont = product_mov.filter(
|
||||
product__name=product.name,
|
||||
).aggregate(Sum('quantity'))['quantity__sum'] or 0
|
||||
product_report[product.name] = {
|
||||
'product_item':product_item,
|
||||
'product_cont':product_cont,
|
||||
}
|
||||
sum_of_product = sum(item['product_item'] for item in product_report.values()) or 0
|
||||
return {
|
||||
'product_report':product_report,
|
||||
'sum_of_product':sum_of_product,
|
||||
}
|
||||
19
Base/Metrics/Dashboard/get_sum_of_professional.py
Normal file
19
Base/Metrics/Dashboard/get_sum_of_professional.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# from django.utils import timezone
|
||||
from django.db.models import Sum
|
||||
from Base.models import Professional
|
||||
from Movement.models import Calendar
|
||||
|
||||
def metric(Day):
|
||||
professionals = Professional.objects.all()
|
||||
professionals_report = {}
|
||||
for professional in professionals:
|
||||
service = Calendar.objects.filter(
|
||||
professional__name=professional.name,
|
||||
date=Day
|
||||
).aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
professionals_report[professional.name] = service
|
||||
sum_of_professionals = sum(professionals_report.values()) or 0
|
||||
return {
|
||||
'professional':professionals_report,
|
||||
'sum_all_prof':sum_of_professionals,
|
||||
}
|
||||
31
Base/Metrics/Dashboard/get_sum_of_professional_detail.py
Normal file
31
Base/Metrics/Dashboard/get_sum_of_professional_detail.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from Base.models import Professional , ServiceList
|
||||
from Movement.models import Calendar
|
||||
# from django.utils import timezone
|
||||
from django.db.models import Sum
|
||||
|
||||
def metric(Day):
|
||||
professionals = Professional.objects.all()
|
||||
services = ServiceList.objects.all()
|
||||
service_movement = Calendar.objects.filter(date=Day).values()
|
||||
professionals_report = {}
|
||||
for professional in professionals:
|
||||
professionals_report[professional.name] = {}
|
||||
for service in services:
|
||||
service_sum = service_movement.filter(
|
||||
professional__name=professional.name,
|
||||
service__name=service.name,
|
||||
)
|
||||
servSum =service_sum.aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
servCont = service_sum.count()
|
||||
professionals_report[professional.name][service.name] = {
|
||||
'servSum':servSum,
|
||||
'servCont':servCont,
|
||||
}
|
||||
sum_of_prof = sum(
|
||||
sum(service['servSum'] for service in services.values())
|
||||
for services in professionals_report.values()
|
||||
)
|
||||
return {
|
||||
'professionals_report':professionals_report,
|
||||
'sum_of_prof':sum_of_prof,
|
||||
}
|
||||
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_,
|
||||
}
|
||||
24
Base/Metrics/Dashboard/get_sum_of_stone.py
Normal file
24
Base/Metrics/Dashboard/get_sum_of_stone.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from Base.models import ProductList
|
||||
from Movement.models import Stock , Product
|
||||
from django.db.models import Sum
|
||||
|
||||
def metric(Day):
|
||||
List = ProductList.objects.all()
|
||||
Products = Product.objects.all()
|
||||
Stones = Stock.objects.all()
|
||||
Stones_report = {}
|
||||
|
||||
for Prod in List:
|
||||
sum_ = Stones.filter(
|
||||
product__name=Prod.name,
|
||||
).aggregate(Sum('quantity'))['quantity__sum'] or 0
|
||||
|
||||
sum_v = Products.filter(
|
||||
product__name=Prod.name,
|
||||
).aggregate(Sum('quantity'))['quantity__sum'] or 0
|
||||
|
||||
Stones_report[Prod.name] = sum_ - sum_v
|
||||
|
||||
return {
|
||||
'Stone':Stones_report,
|
||||
}
|
||||
24
Base/Metrics/Dashboard/get_sum_payment_method_service.py
Normal file
24
Base/Metrics/Dashboard/get_sum_payment_method_service.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.db.models import Sum
|
||||
from Base.models import PayMethod
|
||||
from Movement.models import Calendar , Product
|
||||
|
||||
|
||||
def metric(Day):
|
||||
# Total de despesas do dia
|
||||
payment_method = PayMethod.objects.all()
|
||||
serv_mov = Calendar.objects.filter(date=Day).values()
|
||||
prod_mov = Product.objects.filter(date=Day).values()
|
||||
bank_balance = {}
|
||||
for PayM in payment_method:
|
||||
sum_bank1 = serv_mov.filter(
|
||||
pay_method__name=PayM.name,
|
||||
).aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
sum_bank2 = prod_mov.filter(
|
||||
pay_method__name=PayM.name,
|
||||
).aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
bank_balance[PayM.name] = sum_bank1 + sum_bank2
|
||||
sum_of_bank = sum(bank_balance.values()) or 0
|
||||
return {
|
||||
'bank_balance':bank_balance,
|
||||
'sum_of_bank':sum_of_bank,
|
||||
}
|
||||
Reference in New Issue
Block a user