add - org quota stat to inventory_entry / inventory_balance to org_quota_stat
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-11-19 13:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0096_organizationquotastats_inventory_received'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='organizationquotastats',
|
||||
name='inventory_entry_balance',
|
||||
field=models.PositiveBigIntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -470,6 +470,7 @@ class Quota(BaseModel):
|
||||
organization=org
|
||||
)
|
||||
return {
|
||||
"id": stat.first().id if stat.exists() else 0,
|
||||
"quota_weight": stat.first().total_amount if stat.exists() else 0,
|
||||
"remaining_weight": stat.first().remaining_amount if stat.exists() else 0,
|
||||
"quota_distributed": stat.first().total_distributed if stat.exists() else 0,
|
||||
@@ -817,6 +818,7 @@ class OrganizationQuotaStats(BaseModel):
|
||||
total_amount = models.PositiveBigIntegerField(default=0)
|
||||
total_distributed = models.PositiveBigIntegerField(default=0)
|
||||
inventory_received = models.PositiveBigIntegerField(default=0)
|
||||
inventory_entry_balance = models.PositiveBigIntegerField(default=0)
|
||||
sold_amount = models.PositiveBigIntegerField(default=0)
|
||||
remaining_amount = models.PositiveBigIntegerField(default=0) # total - sold
|
||||
stat_type = models.CharField(max_length=150, choices=(
|
||||
|
||||
@@ -29,6 +29,9 @@ class QuotaSerializer(serializers.ModelSerializer):
|
||||
org = self.context['org']
|
||||
quota_weight_by_org = instance.quota_amount_by_org(org)
|
||||
if quota_weight_by_org:
|
||||
# organization quota stat record
|
||||
representation['org_quota_stat'] = quota_weight_by_org['id']
|
||||
|
||||
representation['quota_weight'] = quota_weight_by_org['quota_weight']
|
||||
representation['quota_distributed'] = quota_weight_by_org['quota_distributed']
|
||||
representation['remaining_weight'] = quota_weight_by_org['remaining_weight']
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.0 on 2025-11-19 13:16
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0097_organizationquotastats_inventory_entry_balance'),
|
||||
('warehouse', '0043_inventoryentry_quota'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='inventoryentry',
|
||||
name='org_quota_stat',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='inventory_entry', to='product.organizationquotastats'),
|
||||
),
|
||||
]
|
||||
@@ -31,6 +31,12 @@ class InventoryEntry(BaseModel):
|
||||
related_name="inventory",
|
||||
null=True
|
||||
)
|
||||
org_quota_stat = models.ForeignKey(
|
||||
product_models.OrganizationQuotaStats,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='inventory_entry',
|
||||
null=True
|
||||
)
|
||||
weight = models.PositiveBigIntegerField(default=0)
|
||||
balance = models.PositiveBigIntegerField(default=0)
|
||||
lading_number = models.CharField(max_length=50, null=True)
|
||||
|
||||
@@ -15,6 +15,7 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
"modify_date",
|
||||
"organization",
|
||||
"quota",
|
||||
'org_quota_stat',
|
||||
"weight",
|
||||
"balance",
|
||||
"lading_number",
|
||||
|
||||
Reference in New Issue
Block a user