transaction system deploying

This commit is contained in:
2025-09-09 15:15:04 +03:30
parent 5307a27d20
commit 9678bf2c21
11 changed files with 241 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ from apps.product.models import QuotaDistribution
from apps.warehouse.models import InventoryQuotaSaleTransaction
from apps.authentication.models import Organization, OrganizationStats
from django.db.models.signals import post_save, post_delete
from rest_framework.exceptions import APIException
from django.dispatch import receiver
@@ -38,6 +39,12 @@ def update_organization_stats(instance: Organization):
@receiver([post_save, post_delete], sender=InventoryQuotaSaleTransaction)
def organization_stats(sender, instance, **kwargs):
if sender == QuotaDistribution:
update_organization_stats(instance.assigned_organization)
if instance.assigned_organization:
update_organization_stats(instance.assigned_organization)
else:
print("assigned_organization is null")
elif sender == InventoryQuotaSaleTransaction:
update_organization_stats(instance.inventory_entry.organization)
if instance.inventory_entry:
update_organization_stats(instance.inventory_entry.organization)
else:
print("inventory_entry is null - authentication app signals")