31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from django.db.models import Count, Sum
|
|
from django.db.models import Q
|
|
|
|
from .models import *
|
|
|
|
def dashBoxData(request):
|
|
|
|
debit = Article.objects.filter().aggregate(Sum('debit'))['debit__sum']
|
|
credit = Article.objects.filter().aggregate(Sum('credit'))['credit__sum']
|
|
try:
|
|
mandehesab = debit - credit
|
|
except:
|
|
mandehesab = 0
|
|
countCustomers = Customer.objects.all().count()
|
|
allUsers = User.objects.filter().exclude(username='admin').exclude(username='fesahat')
|
|
ActionCount = Action.objects.filter(forUser=request.user.id, status='waite').count()
|
|
rezayatCount = Action.objects.exclude(actionType='vosol').filter(Q(nazar='') | Q(nazar=None) & Q(status='finish')).count()
|
|
try:
|
|
entezarbazdid = CacheTable.objects.get(key='9mahbazdid').value
|
|
except Exception as exp:
|
|
entezarbazdid = 0
|
|
|
|
data = {
|
|
'mandehesab': mandehesab,
|
|
'countCustomers': countCustomers,
|
|
'ActionCount': ActionCount,
|
|
'allUsers': allUsers,
|
|
'rezayatCount': rezayatCount,
|
|
'entezarbazdid': entezarbazdid
|
|
}
|
|
return data |