fix - change transaction base from distribution to quota stat
This commit is contained in:
19
apps/product/migrations/0098_quotausage_quota_stat.py
Normal file
19
apps/product/migrations/0098_quotausage_quota_stat.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0 on 2025-11-26 11:00
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0097_organizationquotastats_inventory_entry_balance'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='quotausage',
|
||||
name='quota_stat',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='usages', to='product.organizationquotastats'),
|
||||
),
|
||||
]
|
||||
@@ -580,6 +580,12 @@ class QuotaStats(BaseModel):
|
||||
|
||||
|
||||
class QuotaUsage(BaseModel):
|
||||
quota_stat = models.ForeignKey(
|
||||
'OrganizationQuotaStats',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='usages',
|
||||
null=True
|
||||
)
|
||||
distribution = models.ForeignKey(
|
||||
"QuotaDistribution",
|
||||
on_delete=models.CASCADE,
|
||||
|
||||
@@ -274,7 +274,7 @@ class OrganizationQuotaStatsSerializer(serializers.ModelSerializer):
|
||||
representation['pre_sale'] = instance.quota.pre_sale
|
||||
|
||||
if instance.distributions:
|
||||
representation['distributions'] = [dist.id for dist in instance.distributions.all()]
|
||||
representation['distribution'] = instance.distributions.all().order_by('-create_date').first().id
|
||||
|
||||
if instance.quota:
|
||||
representation['quota'] = {
|
||||
|
||||
@@ -4,6 +4,7 @@ from rest_framework import status
|
||||
from rest_framework import viewsets, filters
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
@@ -198,6 +199,7 @@ class QuotaLiveStockAgeLimitation(viewsets.ModelViewSet):
|
||||
class OrganizationQuotaStatsViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDeviceMixin):
|
||||
queryset = OrganizationQuotaStats.objects.all()
|
||||
serializer_class = quota_serializers.OrganizationQuotaStatsSerializer
|
||||
permission_classes = [AllowAny]
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = [
|
||||
"quota__registerer_organization__name",
|
||||
|
||||
Reference in New Issue
Block a user