# Generated by Django 5.2.8 on 2026-06-06 08:01

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('basic_info', '0027_employee_wecom_user_id'),
    ]

    operations = [
        migrations.CreateModel(
            name='CostCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('unique_key', models.CharField(max_length=100, verbose_name='唯一标识键')),
                ('name', models.CharField(max_length=100, verbose_name='类目名称')),
                ('description', models.TextField(blank=True, null=True, verbose_name='描述')),
                ('merchant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cost_categories', to='basic_info.merchant', verbose_name='所属商户')),
                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='children', to='cost.costcategory', verbose_name='父类目')),
            ],
            options={
                'verbose_name': '支出类目',
                'verbose_name_plural': '支出类目',
                'ordering': ('merchant', 'name'),
                'unique_together': {('merchant', 'unique_key')},
            },
        ),
        migrations.CreateModel(
            name='CostEntry',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='金额')),
                ('occurred_at', models.DateField(verbose_name='发生日期')),
                ('image1', models.ImageField(blank=True, null=True, upload_to='cost/entries/', verbose_name='凭证图片')),
                ('image2', models.ImageField(blank=True, null=True, upload_to='cost/entries/', verbose_name='备用凭证图片')),
                ('source_module', models.CharField(blank=True, max_length=50, null=True, verbose_name='来源模块')),
                ('source_id', models.CharField(blank=True, max_length=100, null=True, verbose_name='来源记录ID')),
                ('remarks', models.TextField(blank=True, null=True, verbose_name='备注')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='entries', to='cost.costcategory', verbose_name='支出类目')),
                ('merchant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cost_entries', to='basic_info.merchant', verbose_name='所属商户')),
                ('operator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='cost_entries', to='basic_info.employee', verbose_name='经办人')),
            ],
            options={
                'verbose_name': '支出明细',
                'verbose_name_plural': '支出明细',
                'ordering': ('-occurred_at', '-created_at'),
            },
        ),
    ]
