flower_bs 1 روز پیش
والد
کامیت
7b636a1a56
2فایلهای تغییر یافته به همراه60 افزوده شده و 0 حذف شده
  1. 30 0
      reportcenter/migrations/0003_goodssummarymodel.py
  2. 30 0
      reportcenter/models.py

+ 30 - 0
reportcenter/migrations/0003_goodssummarymodel.py

@@ -0,0 +1,30 @@
+# Generated by Django 4.1.2 on 2025-07-25 18:15
+
+from decimal import Decimal
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('reportcenter', '0002_alter_flowmodel_goods_in_alter_flowmodel_goods_out'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='GoodsSummaryModel',
+            fields=[
+                ('goods_code', models.CharField(max_length=50, primary_key=True, serialize=False, verbose_name='货品编码')),
+                ('goods_desc', models.CharField(max_length=100, verbose_name='货品描述')),
+                ('total_in', models.DecimalField(decimal_places=3, default=Decimal('0'), max_digits=15, verbose_name='总入库量')),
+                ('total_out', models.DecimalField(decimal_places=3, default=Decimal('0'), max_digits=15, verbose_name='总出库量')),
+                ('net_change', models.DecimalField(decimal_places=3, default=Decimal('0'), max_digits=15, verbose_name='净变化量')),
+                ('last_updated', models.DateTimeField(auto_now=True, verbose_name='最后更新时间')),
+            ],
+            options={
+                'verbose_name': '货品汇总',
+                'verbose_name_plural': '货品汇总',
+                'db_table': 'goods_summary',
+            },
+        ),
+    ]

+ 30 - 0
reportcenter/models.py

@@ -43,4 +43,34 @@ class flowModel(models.Model):
         ]
     
 
+class GoodsSummaryModel(models.Model):
+    """货品变动汇总模型(按goods_code聚合)"""
+    goods_code = models.CharField(max_length=50, verbose_name='货品编码', primary_key=True)
+    goods_desc = models.CharField(max_length=100, verbose_name='货品描述')
+    total_in = models.DecimalField(
+        max_digits=15, 
+        decimal_places=3,
+        default=Decimal('0'),
+        verbose_name='总入库量'
+    )
+    total_out = models.DecimalField(
+        max_digits=15, 
+        decimal_places=3,
+        default=Decimal('0'),
+        verbose_name='总出库量'
+    )
+    net_change = models.DecimalField(
+        max_digits=15,
+        decimal_places=3,
+        default=Decimal('0'),
+        verbose_name='净变化量'
+    )
+    last_updated = models.DateTimeField(auto_now=True, verbose_name='最后更新时间')
 
+    class Meta:
+        db_table = 'goods_summary'
+        verbose_name = '货品汇总'
+        verbose_name_plural = "货品汇总"
+
+    def __str__(self):
+        return f"{self.goods_code} | 入库:{self.total_in} 出库:{self.total_out}"