first commit
This commit is contained in:
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,
|
||||
}
|
||||
Reference in New Issue
Block a user