fix - device pre register & exception handling with json response

This commit is contained in:
2025-11-09 14:35:14 +03:30
parent 0c5142aff3
commit c0f289284f
7 changed files with 118 additions and 9 deletions

View File

@@ -0,0 +1,28 @@
from django.db.models import Sum
from apps.product import models as product_models
class QuotaDistributionService:
"""
Service layer to manage multiple quota distributions as one unified entity.
Used for organization-based views and POS operations.
"""
def __init__(self, quota, organization):
self.quota = quota
self.organization = organization
self.distribution = product_models.QuotaDistribution.objects.filter(
quota=quota,
assigned_organization=organization,
quota__is_closed=False,
warehouse_entry__gt=0
).first()
@property
def total_weight(self):
return self.distribution.aggregate(
total=Sum('weight')
)['total'] or 0
pass