import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("shop_management", "0038_accounttransaction"),
    ]

    operations = [
        migrations.CreateModel(
            name="AccountTransfer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("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)),
                ("reference", models.CharField(blank=True, max_length=120, null=True)),
                ("note", models.TextField(blank=True, null=True)),
                (
                    "transfer_date",
                    models.DateField(default=django.utils.timezone.localdate),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "from_account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="outgoing_transfers",
                        to="shop_management.account",
                    ),
                ),
                (
                    "from_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="account_transfers_as_from_currency",
                        to="shop_management.currency",
                    ),
                ),
                (
                    "to_account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="incoming_transfers",
                        to="shop_management.account",
                    ),
                ),
                (
                    "to_currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="account_transfers_as_to_currency",
                        to="shop_management.currency",
                    ),
                ),
            ],
            options={
                "ordering": ["-transfer_date", "-id"],
            },
        ),
    ]
