# Generated by Django 5.2.9 on 2025-12-31 06:51

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


class Migration(migrations.Migration):

    dependencies = [
        ("account", "0003_investmentrulemodel"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="CapitalFlowModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "flow_type",
                    models.CharField(
                        choices=[
                            ("deposit", "入金"),
                            ("withdraw", "出金"),
                            ("dividend", "分红"),
                            ("interest", "利息"),
                            ("adjustment", "调整"),
                        ],
                        max_length=20,
                        verbose_name="流水类型",
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="金额"),
                ),
                ("flow_date", models.DateField(db_index=True, verbose_name="流水日期")),
                ("notes", models.TextField(blank=True, verbose_name="备注")),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                (
                    "portfolio",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="capital_flows",
                        to="account.portfoliomodel",
                        verbose_name="投资组合",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="capital_flows",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "资金流水",
                "verbose_name_plural": "资金流水",
                "db_table": "capital_flow",
                "ordering": ["-flow_date", "-created_at"],
                "indexes": [
                    models.Index(
                        fields=["user", "flow_type", "-flow_date"],
                        name="capital_flo_user_id_0522f4_idx",
                    )
                ],
            },
        ),
    ]
