fix - rancher quota weight reamining weight / free sale

This commit is contained in:
2025-11-12 16:35:05 +03:30
parent f767bed356
commit afc9def177
2 changed files with 32 additions and 3 deletions

View File

@@ -150,13 +150,21 @@ def rancher_quota_weight(
# incentive plan quantity by this livestock type
rancher_plan_weight = rancher_plans.first().allowed_quantity * item.quantity_kg
total_weight += rancher_plan_weight
print(total_weight)
# get rancher remaining usage of quota for purchase
rancher_remaining_usage = RancherService.get_total_used_weight(rancher, InventoryQuotaSaleItem)
if total_weight - rancher_remaining_usage < 0:
remaining_weight = 0
free_sale = rancher_remaining_usage - total_weight
else:
remaining_weight = total_weight - rancher_remaining_usage
free_sale = 0
return {
"total_weight": total_weight,
"remaining_weight": total_weight - rancher_remaining_usage,
"remaining_weight": remaining_weight,
'free_sale': free_sale,
"rancher_temporary_livestock": rancher.without_herd,
"by_type": [{
"name": key,