fix - change transaction base from distribution to quota stat

This commit is contained in:
2025-11-26 15:28:14 +03:30
parent 7c1fb57934
commit 817f26519d
13 changed files with 568 additions and 30 deletions

View File

@@ -1,15 +1,15 @@
from apps.product.models import QuotaUsage, IncentivePlan
from apps.livestock.models import LiveStockType
from apps.product.models import QuotaUsage, IncentivePlan
class QuotaUsageService:
@staticmethod
def allocate_usage(rancher, distribution, item_data):
def allocate_usage(rancher, distribution, item_data, quota_stat=None):
""" save & calculate quota usage of rancher """
# purchase quota usage of rancher
if 'livestock_statistic' in item_data.keys():
if 'livestock_statistic' in item_data.keys(): # noqa
# get list of livestock types object for transaction item
livestock_types = {
@@ -40,6 +40,7 @@ class QuotaUsageService:
rancher=rancher,
livestock_type=livestock_type,
distribution=distribution,
quota_stat=quota_stat,
incentive_plan=incentive_plans.get(item['id']) if is_incentive else None,
defaults={
"count": item['count'],