first commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
39
Base/Metrics/DashboardProf/get_sum_credit.py
Normal file
39
Base/Metrics/DashboardProf/get_sum_credit.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from django.db.models import Sum , Count
|
||||
from django.utils import timezone
|
||||
from Movement.models import (
|
||||
Calendar,
|
||||
ExpenseOrCredit,
|
||||
ChartOfAccount,
|
||||
)
|
||||
|
||||
def metric(Prof_id):
|
||||
current_month = timezone.localtime(timezone.now()).month
|
||||
current_year = timezone.localtime(timezone.now()).year
|
||||
|
||||
# pegando total de Despesas
|
||||
debit = ChartOfAccount.objects.filter(
|
||||
firm=False,
|
||||
debit=False,
|
||||
credit=True,
|
||||
prof=True,
|
||||
)
|
||||
expense = {}
|
||||
total_geral_despesas = 0
|
||||
for bank in debit:
|
||||
sum_bank = ExpenseOrCredit.objects.filter(
|
||||
# active=True,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
chart_of_account__id=bank.id,
|
||||
professional__id=Prof_id,
|
||||
)
|
||||
total_geral_despesas += sum_bank.aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
expense[bank.name] = {
|
||||
'sum_credit': sum_bank.aggregate(Sum('gross_value'))['gross_value__sum'] or 0,
|
||||
'list_credit': sum_bank ,
|
||||
}
|
||||
|
||||
return {
|
||||
'sum_credit': expense,
|
||||
'sum_credit_all': total_geral_despesas,
|
||||
}
|
||||
39
Base/Metrics/DashboardProf/get_sum_expense.py
Normal file
39
Base/Metrics/DashboardProf/get_sum_expense.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from django.db.models import Sum , Count
|
||||
from django.utils import timezone
|
||||
from Movement.models import (
|
||||
Calendar,
|
||||
ExpenseOrCredit,
|
||||
ChartOfAccount,
|
||||
)
|
||||
|
||||
def metric(Prof_id):
|
||||
current_month = timezone.localtime(timezone.now()).month
|
||||
current_year = timezone.localtime(timezone.now()).year
|
||||
|
||||
# pegando total de Despesas
|
||||
debit = ChartOfAccount.objects.filter(
|
||||
firm=False,
|
||||
debit=True,
|
||||
credit=False,
|
||||
prof=True,
|
||||
)
|
||||
expense = {}
|
||||
total_geral_despesas = 0
|
||||
for bank in debit:
|
||||
sum_bank = ExpenseOrCredit.objects.filter(
|
||||
# active=True,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
chart_of_account__id=bank.id,
|
||||
professional__id=Prof_id,
|
||||
)
|
||||
total_geral_despesas += sum_bank.aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
expense[bank.name] = {
|
||||
'sum_expense': sum_bank.aggregate(Sum('gross_value'))['gross_value__sum'] or 0,
|
||||
'list_expense': sum_bank ,
|
||||
}
|
||||
|
||||
return {
|
||||
'sum_expense': expense,
|
||||
'sum_expense_all': total_geral_despesas,
|
||||
}
|
||||
38
Base/Metrics/DashboardProf/get_total_money.py
Normal file
38
Base/Metrics/DashboardProf/get_total_money.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from django.db.models import Sum , Count
|
||||
from django.utils import timezone
|
||||
from Movement.models import (
|
||||
Calendar,
|
||||
ExpenseOrCredit
|
||||
)
|
||||
|
||||
def metric(Prof_id):
|
||||
current_month = timezone.localtime(timezone.now()).month
|
||||
current_year = timezone.localtime(timezone.now()).year
|
||||
|
||||
calenda = Calendar.objects.filter(
|
||||
professional_id=Prof_id,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
)
|
||||
debit = ExpenseOrCredit.objects.filter(
|
||||
prof=True,
|
||||
debit=True,
|
||||
credit=False,
|
||||
professional_id=Prof_id,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
)
|
||||
credit = ExpenseOrCredit.objects.filter(
|
||||
prof=True,
|
||||
debit=False,
|
||||
credit=True,
|
||||
professional_id=Prof_id,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
)
|
||||
sum_calenda = calenda.aggregate(Sum('prof_money'))['prof_money__sum'] or 0
|
||||
sum_debit = calenda.aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
sum_credit = calenda.aggregate(Sum('gross_value'))['gross_value__sum'] or 0
|
||||
all = sum_calenda + sum_credit - sum_debit
|
||||
|
||||
return all
|
||||
23
Base/Metrics/DashboardProf/get_total_serv.py
Normal file
23
Base/Metrics/DashboardProf/get_total_serv.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db.models import Sum , Count
|
||||
from django.utils import timezone
|
||||
from Movement.models import (
|
||||
Calendar,
|
||||
)
|
||||
|
||||
def metric(Prof_id):
|
||||
current_month = timezone.localtime(timezone.now()).month
|
||||
current_year = timezone.localtime(timezone.now()).year
|
||||
|
||||
qs = Calendar.objects.filter(
|
||||
professional_id=Prof_id,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
)
|
||||
# Contagem de cada serviço realizado
|
||||
services_breakdown = qs.values('service__name').annotate(
|
||||
total_performed=Count('id')
|
||||
).order_by('-total_performed')
|
||||
|
||||
return {
|
||||
'services': services_breakdown,
|
||||
}
|
||||
Reference in New Issue
Block a user