# Generated by Django 4.2.27 on 2026-04-20 06:02

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


class Migration(migrations.Migration):

    dependencies = [
        ('system', '0007_alter_dept_create_by_alter_dept_third_info_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('sam', '0008_alter_orderitem_order'),
    ]

    operations = [
        migrations.AddField(
            model_name='contract',
            name='effective_date',
            field=models.DateField(blank=True, null=True, verbose_name='生效日期'),
        ),
        migrations.AddField(
            model_name='contract',
            name='end_date',
            field=models.DateField(blank=True, null=True, verbose_name='截止日期'),
        ),
        migrations.AddField(
            model_name='contract',
            name='receive_progress',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='到款进度'),
        ),
        migrations.AddField(
            model_name='contract',
            name='received_amount',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='累计已到款'),
        ),
        migrations.AddField(
            model_name='contract',
            name='settlement_status',
            field=models.PositiveSmallIntegerField(choices=[(10, '未到款'), (20, '部分到款'), (30, '全部到款')], default=10, help_text="((10, '未到款'), (20, '部分到款'), (30, '全部到款'))", verbose_name='结算状态'),
        ),
        migrations.AddField(
            model_name='contract',
            name='status',
            field=models.PositiveSmallIntegerField(choices=[(10, '草稿'), (20, '执行中'), (30, '已完成'), (40, '已终止')], default=10, help_text="((10, '草稿'), (20, '执行中'), (30, '已完成'), (40, '已终止'))", verbose_name='合同状态'),
        ),
        migrations.AddField(
            model_name='contract',
            name='unreceived_amount',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=14, verbose_name='累计未到款'),
        ),
        migrations.AlterField(
            model_name='contract',
            name='belong_dept',
            field=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='所属部门'),
        ),
        migrations.AlterField(
            model_name='contract',
            name='create_by',
            field=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='创建人'),
        ),
        migrations.AlterField(
            model_name='contract',
            name='update_by',
            field=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='最后编辑人'),
        ),
        migrations.AlterField(
            model_name='customer',
            name='belong_dept',
            field=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='所属部门'),
        ),
        migrations.AlterField(
            model_name='customer',
            name='create_by',
            field=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='创建人'),
        ),
        migrations.AlterField(
            model_name='customer',
            name='update_by',
            field=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='最后编辑人'),
        ),
        migrations.AlterField(
            model_name='order',
            name='belong_dept',
            field=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='所属部门'),
        ),
        migrations.AlterField(
            model_name='order',
            name='create_by',
            field=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='创建人'),
        ),
        migrations.AlterField(
            model_name='order',
            name='update_by',
            field=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='最后编辑人'),
        ),
        migrations.CreateModel(
            name='ContractRecord',
            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='删除标记')),
                ('record_date', models.DateField(verbose_name='到款日期')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=14, verbose_name='到款金额')),
                ('stage_type', models.PositiveSmallIntegerField(choices=[(10, '首款'), (20, '中间款'), (30, '尾款'), (40, '其他')], default=40, help_text="((10, '首款'), (20, '中间款'), (30, '尾款'), (40, '其他'))", verbose_name='阶段类型')),
                ('pay_method', models.PositiveSmallIntegerField(choices=[(10, '银行转账'), (20, '现金'), (30, '承兑'), (40, '微信'), (50, '支付宝'), (60, '其他')], default=10, help_text="((10, '银行转账'), (20, '现金'), (30, '承兑'), (40, '微信'), (50, '支付宝'), (60, '其他'))", verbose_name='收款方式')),
                ('voucher_no', models.CharField(blank=True, max_length=100, null=True, verbose_name='凭证号')),
                ('remark', models.CharField(blank=True, max_length=200, 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='所属部门')),
                ('contract', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='records', to='sam.contract', 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='创建人')),
                ('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={
                'verbose_name': '销售合同到款流水',
                'verbose_name_plural': '销售合同到款流水',
                'ordering': ['-record_date', '-create_time'],
            },
        ),
    ]
