fix - change base of pre sale / extra sale on quota stat & total purchase of rancher in Quota usage calculation

This commit is contained in:
2025-11-26 15:50:35 +03:30
parent 817f26519d
commit 65bdb539bc
7 changed files with 51 additions and 26 deletions

View File

@@ -4,11 +4,11 @@ from django.db.models import Sum, functions, Value
class RancherService:
@staticmethod
def get_total_used_weight(rancher, sale_item, distribution):
def get_total_used_weight(rancher, sale_item, quota_stat):
return sale_item.objects.filter(
transaction__rancher=rancher,
transaction__transaction_status='success',
quota_distribution=distribution,
quota_stat=quota_stat,
).aggregate(
total_weight=functions.Coalesce(Sum('weight'), Value(0))
)['total_weight']