organization limit for quota - get org childs

This commit is contained in:
2025-07-16 12:21:29 +03:30
parent a70d451ca1
commit a6b29ad28d
47 changed files with 375 additions and 11 deletions

View File

@@ -1,7 +1,8 @@
from django.db.models import Sum
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from .models import QuotaDistribution, Quota
from .models import QuotaDistribution, Quota, Product
from apps.warehouse.models import InventoryQuotaSaleTransaction
def recalculate_remaining_amount(quota):
@@ -18,3 +19,18 @@ def recalculate_remaining_amount(quota):
@receiver(post_delete, sender=QuotaDistribution)
def update_quota_remaining(sender, instance, **kwargs):
recalculate_remaining_amount(instance.quota)
def update_product_stats(instance: Product):
pass
def update_quota_stats(instance: Quota):
pass
@receiver([post_save, post_delete], sender=QuotaDistribution)
@receiver([post_save, post_delete], sender=InventoryQuotaSaleTransaction)
def update_stats_on_change(sender, instance, **kwargs):
update_product_stats(instance)
update_quota_stats(instance)