add purchace limitations system for rancher - add incentive plans to rancher entries data

This commit is contained in:
2025-08-26 12:18:10 +03:30
parent b5dfcebafe
commit c0b6b8ddca
12 changed files with 142 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
from apps.warehouse.models import InventoryEntry, InventoryQuotaSaleTransaction
from apps.herd.services.services import rancher_quota_weight, get_rancher_statistics
from apps.core.models import SystemConfig
from django.db.models import Sum
@@ -17,6 +18,12 @@ def get_total_sold(inventory_entry, rancher):
def can_buy_from_inventory(rancher, inventory_entry: InventoryEntry):
"""
"""
if SystemConfig.get("IGNORE_ALL_RANCHER_PURCHASE_LIMITS") == "true":
return True
if rancher.ignore_purchase_limit:
return True
quota_weight = rancher_quota_weight(rancher, inventory_entry) # {total, by_type}
total_allowed = quota_weight['total']