fix - rancher quota weight statistic / link in herds livestock gropes

This commit is contained in:
2025-11-11 10:27:19 +03:30
parent 5da20dc16c
commit a36747f9f0

View File

@@ -14,9 +14,9 @@ from apps.warehouse.models import (
) )
LIVESTOCK_GROPES = { LIVESTOCK_GROPES = {
'I': 'industrial', # صنعتی 'industrial': 'I', # صنعتی
'V': 'rural', # روستایی 'rural': 'V', # روستایی
'N': 'nomadic' # عشایری 'nomadic': 'N' # عشایری
} }
@@ -85,6 +85,9 @@ def rancher_quota_weight(
allocations = list(quota.livestock_allocations.all().select_related('livestock_type')) allocations = list(quota.livestock_allocations.all().select_related('livestock_type'))
# list of quota incentive plans # list of quota incentive plans
incentive_plans = list(quota.incentive_assignments.all().select_related('livestock_type')) 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) 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 # calculate quota base weight by livestock type & base total weight
for item in allocations: # noqa for item in allocations: # noqa
if item.livestock_type: 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_fa = item.livestock_type.name
animal_type_en = item.livestock_type.en_name animal_type_en = item.livestock_type.en_name
per_head = item.quantity_kg per_head = item.quantity_kg