# Generated by Django 4.2.27 on 2026-04-24 06:50

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('system', '0007_alter_dept_create_by_alter_dept_third_info_and_more'),
        ('wf', '0006_auto_20251215_1645'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='MaterialRequisition',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=20, unique=True, verbose_name='编号')),
                ('req_date', models.DateField(blank=True, null=True, verbose_name='填报时间')),
                ('collector', models.CharField(blank=True, max_length=50, null=True, verbose_name='领取人')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_belong_dept', to='system.dept', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('ticket', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='material_requisition_ticket', to='wf.ticket', verbose_name='关联工单')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PurchaseRequisition',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=20, unique=True, verbose_name='编号')),
                ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='联系电话')),
                ('req_date', models.DateField(blank=True, null=True, verbose_name='申购日期')),
                ('total_amount', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='合计金额')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_belong_dept', to='system.dept', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('ticket', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpr_ticket', to='wf.ticket', verbose_name='关联工单')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WareHouse',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=20, verbose_name='库房编号')),
                ('name', models.CharField(max_length=20, verbose_name='库房名称')),
                ('place', models.CharField(max_length=50, verbose_name='具体地点')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpr_warehouse_belong_dept', to='system.dept', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpr_warehouse_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpr_warehouse_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WarehouseEntry',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=20, unique=True, verbose_name='编号')),
                ('entry_date', models.DateField(blank=True, null=True, verbose_name='入库日期')),
                ('entry_type', models.CharField(choices=[('raw_normal', '原材料正常入库'), ('raw_estimated', '原材料暂估入库'), ('product', '产品入库'), ('other', '其他')], default='raw_normal', max_length=20, verbose_name='入库类型')),
                ('entry_method', models.CharField(choices=[('purchase', '采购'), ('self_made', '自制'), ('other', '其他')], default='purchase', max_length=20, verbose_name='入库方式')),
                ('total_amount', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='合计金额')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_belong_dept', to='system.dept', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('ticket', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='warehouse_entry_ticket', to='wf.ticket', verbose_name='关联工单')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
                ('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='entries', to='mpr.warehouse', verbose_name='库房')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WarehouseStock',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('entry_number', models.CharField(max_length=20, verbose_name='入库单号')),
                ('entry_date', models.DateField(blank=True, null=True, verbose_name='入库日期')),
                ('entry_type', models.CharField(choices=[('raw_normal', '原材料正常入库'), ('raw_estimated', '原材料暂估入库'), ('product', '产品入库'), ('other', '其他')], max_length=20, verbose_name='入库类型')),
                ('entry_method', models.CharField(choices=[('purchase', '采购'), ('self_made', '自制'), ('other', '其他')], max_length=20, verbose_name='入库方式')),
                ('name', models.CharField(max_length=100, verbose_name='名称')),
                ('spec', models.CharField(blank=True, max_length=200, null=True, verbose_name='规格')),
                ('unit', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位')),
                ('quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='数量')),
                ('unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='单价')),
                ('amount', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='金额')),
                ('supplier_name', models.CharField(blank=True, max_length=100, null=True, verbose_name='供应商名称')),
                ('invoice_received', models.BooleanField(default=False, verbose_name='账单是否收到')),
                ('status', models.CharField(choices=[('idle', '闲置'), ('in_requisition', '领用中'), ('requisitioned', '已领用')], default='idle', max_length=20, verbose_name='状态')),
                ('entry', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stocks', to='mpr.warehouseentry', verbose_name='来源入库单')),
                ('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mpr_stocks', to='mpr.warehouse', verbose_name='库房')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WarehouseEntryItem',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('name', models.CharField(max_length=100, verbose_name='名称')),
                ('spec', models.CharField(blank=True, max_length=200, null=True, verbose_name='规格')),
                ('unit', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位')),
                ('quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='数量')),
                ('unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='单价')),
                ('amount', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='金额')),
                ('supplier_name', models.CharField(blank=True, max_length=100, null=True, verbose_name='供应商名称')),
                ('invoice_received', models.BooleanField(default=False, verbose_name='账单是否收到')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='mpr.warehouseentry', verbose_name='关联入库单')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PurchaseRequisitionItem',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('item_name', models.CharField(max_length=100, verbose_name='物品名称')),
                ('spec', models.CharField(blank=True, max_length=200, null=True, verbose_name='规格及型号')),
                ('unit', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位')),
                ('req_quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='申购数量')),
                ('current_stock', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='现库存量')),
                ('need_date', models.DateField(blank=True, null=True, verbose_name='需用日期')),
                ('purchase_quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='需采购数量')),
                ('unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='单价')),
                ('total_price', models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='总价')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('requisition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='mpr.purchaserequisition', verbose_name='关联申购单')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='MaterialRequisitionItem',
            fields=[
                ('id', models.CharField(editable=False, help_text='主键ID', max_length=20, primary_key=True, serialize=False, verbose_name='主键ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('is_stock_item', models.BooleanField(default=True, verbose_name='是否库存物品')),
                ('req_type', models.CharField(blank=True, max_length=50, null=True, verbose_name='领用类型')),
                ('name', models.CharField(max_length=100, verbose_name='物资名称')),
                ('spec', models.CharField(blank=True, max_length=200, null=True, verbose_name='规格型号')),
                ('unit', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位')),
                ('quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12, verbose_name='领用量')),
                ('note', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('requisition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='mpr.materialrequisition', verbose_name='关联领用单')),
                ('stock', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='requisition_items', to='mpr.warehousestock', verbose_name='关联库存')),
            ],
            options={
                'abstract': False,
            },
        ),
    ]
