import django.db.models.deletion
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
    dependencies = [
        ("shop_management", "0037_shopaccount"),
    ]

    operations = [
        migrations.CreateModel(
            name="AccountTransaction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "transaction_type",
                    models.CharField(
                        choices=[("credit", "Credit"), ("debit", "Debit")],
                        max_length=10,
                    ),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=18)),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, max_digits=20),
                ),
                (
                    "converted_amount",
                    models.DecimalField(decimal_places=2, max_digits=18),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "transaction_date",
                    models.DateField(default=django.utils.timezone.localdate),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="transactions",
                        to="shop_management.account",
                    ),
                ),
                (
                    "account_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="account_transactions_as_account_currency",
                        to="shop_management.currency",
                    ),
                ),
                (
                    "transaction_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="account_transactions_as_transaction_currency",
                        to="shop_management.currency",
                    ),
                ),
            ],
            options={
                "ordering": ["-transaction_date", "-id"],
            },
        ),
    ]
