From a36747f9f04dd2cfdd215a064cb8d2ccefd10204 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 11 Nov 2025 10:27:19 +0330 Subject: [PATCH] fix - rancher quota weight statistic / link in herds livestock gropes --- apps/herd/services/services.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/herd/services/services.py b/apps/herd/services/services.py index 8cdce45..b1630fa 100644 --- a/apps/herd/services/services.py +++ b/apps/herd/services/services.py @@ -14,9 +14,9 @@ from apps.warehouse.models import ( ) LIVESTOCK_GROPES = { - 'I': 'industrial', # صنعتی - 'V': 'rural', # روستایی - 'N': 'nomadic' # عشایری + 'industrial': 'I', # صنعتی + 'rural': 'V', # روستایی + 'nomadic': 'N' # عشایری } @@ -85,6 +85,9 @@ def rancher_quota_weight( allocations = list(quota.livestock_allocations.all().select_related('livestock_type')) # list of quota incentive plans incentive_plans = list(quota.incentive_assignments.all().select_related('livestock_type')) + # list of rancher herds + herds = rancher.herd.all() + herd_livestock_gropes = [herd.activity for herd in herds] livestock_counts_list, livestock_counts_dict = get_rancher_statistics(rancher) @@ -94,7 +97,7 @@ def rancher_quota_weight( # calculate quota base weight by livestock type & base total weight for item in allocations: # noqa if item.livestock_type: - if rancher.activity and LIVESTOCK_GROPES[rancher.activity] == item.livestock_group: + if LIVESTOCK_GROPES[item.livestock_group] in herd_livestock_gropes: animal_type_fa = item.livestock_type.name animal_type_en = item.livestock_type.en_name per_head = item.quantity_kg