# Generated by Django 5.2.9 on 2025-12-31 10:09

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


class Migration(migrations.Migration):

    dependencies = [
        ("account", "0005_documentationmodel"),
    ]

    operations = [
        migrations.CreateModel(
            name="CurrencyModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("code", models.CharField(max_length=10, unique=True, verbose_name="币种代码")),
                ("name", models.CharField(max_length=50, verbose_name="币种名称")),
                ("symbol", models.CharField(max_length=10, verbose_name="货币符号")),
                ("is_base", models.BooleanField(default=False, verbose_name="是否基准货币")),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("precision", models.IntegerField(default=2, verbose_name="小数位数")),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
            ],
            options={
                "verbose_name": "币种",
                "verbose_name_plural": "币种",
                "db_table": "currency",
                "ordering": ["-is_base", "code"],
            },
        ),
        migrations.CreateModel(
            name="AssetCategoryModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "code",
                    models.CharField(
                        db_index=True, max_length=50, unique=True, verbose_name="分类代码"
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="分类名称")),
                ("level", models.IntegerField(default=1, verbose_name="层级")),
                ("path", models.CharField(max_length=200, verbose_name="分类路径")),
                ("description", models.TextField(blank=True, verbose_name="描述")),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("sort_order", models.IntegerField(default=0, verbose_name="排序")),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="account.assetcategorymodel",
                        verbose_name="父分类",
                    ),
                ),
            ],
            options={
                "verbose_name": "资产分类",
                "verbose_name_plural": "资产分类",
                "db_table": "asset_category",
                "ordering": ["path", "sort_order"],
                "indexes": [
                    models.Index(fields=["code"], name="asset_categ_code_d4a75c_idx"),
                    models.Index(fields=["parent"], name="asset_categ_parent__38e6e7_idx"),
                    models.Index(fields=["level"], name="asset_categ_level_36c62f_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="ExchangeRateModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("rate", models.DecimalField(decimal_places=6, max_digits=20, verbose_name="汇率")),
                ("effective_date", models.DateField(db_index=True, verbose_name="生效日期")),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                (
                    "from_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="rates_from",
                        to="account.currencymodel",
                        verbose_name="源币种",
                    ),
                ),
                (
                    "to_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="rates_to",
                        to="account.currencymodel",
                        verbose_name="目标币种",
                    ),
                ),
            ],
            options={
                "verbose_name": "汇率",
                "verbose_name_plural": "汇率",
                "db_table": "exchange_rate",
                "ordering": ["-effective_date"],
                "indexes": [
                    models.Index(
                        fields=["from_currency", "to_currency", "effective_date"],
                        name="exchange_ra_from_cu_b4ec81_idx",
                    )
                ],
                "unique_together": {("from_currency", "to_currency", "effective_date")},
            },
        ),
    ]
