some changes
This commit is contained in:
@@ -823,9 +823,13 @@ class OrganizationQuotaStats(BaseModel):
|
|||||||
from apps.warehouse.models import InventoryQuotaSaleItem
|
from apps.warehouse.models import InventoryQuotaSaleItem
|
||||||
|
|
||||||
# calculate total amount of distribution
|
# calculate total amount of distribution
|
||||||
self.total_distributed = self.distributions.filter().aggregate(
|
# self.total_amount = self.distributions.filter().aggregate(
|
||||||
total=Sum('weight')
|
# total=Sum('weight')
|
||||||
)['total'] or 0
|
# )['total'] or 0
|
||||||
|
|
||||||
|
self.total_distributed = self.distributions.filter().exclude(
|
||||||
|
assigned_organization=self.organization
|
||||||
|
).aggregate(total=Sum('weight'))['total'] or 0
|
||||||
|
|
||||||
self.sold_amount = InventoryQuotaSaleItem.objects.filter(
|
self.sold_amount = InventoryQuotaSaleItem.objects.filter(
|
||||||
quota_distribution__in=self.distributions.all(),
|
quota_distribution__in=self.distributions.all(),
|
||||||
@@ -834,7 +838,7 @@ class OrganizationQuotaStats(BaseModel):
|
|||||||
total=Sum('weight')
|
total=Sum('weight')
|
||||||
)['total'] or 0
|
)['total'] or 0
|
||||||
|
|
||||||
self.remaining_amount = self.total_amount - self.sold_amount
|
self.remaining_amount = self.total_amount - self.total_distributed
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user