# Generated by Django 4.1.8 on 2023-04-06 12:07

import django.db.models.deletion
import wbcore.contrib.currency.import_export.handlers.currency
import wbcore.contrib.currency.import_export.handlers.currency_fx_rates
import wbcore.utils.models
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("io", "0001_initial_squashed"),
    ]

    operations = [
        migrations.CreateModel(
            name="Currency",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
                ),
                ("title", models.CharField(max_length=255)),
                ("symbol", models.CharField(blank=True, max_length=10, null=True)),
                ("key", models.CharField(max_length=3, unique=True)),
                (
                    "import_source",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="io.importsource",
                    ),
                ),
            ],
            options={
                "verbose_name": "Currency",
                "verbose_name_plural": "Currencies",
                "ordering": ("title",),
            },
            bases=(
                wbcore.utils.models.LabelKeyMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name="CurrencyFXRates",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
                ),
                ("date", models.DateField()),
                ("value", models.DecimalField(decimal_places=6, max_digits=20)),
                (
                    "currency",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="fx_rates",
                        to="currency.currency",
                    ),
                ),
                (
                    "import_source",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="io.importsource",
                    ),
                ),
            ],
            options={
                "verbose_name": "FX Rate",
                "verbose_name_plural": "FX Rates",
            },
            bases=(models.Model,),
        ),
        migrations.AddIndex(
            model_name="currencyfxrates",
            index=models.Index(fields=["date", "currency"], name="currency_fx_rate_idx"),
        ),
        migrations.AlterUniqueTogether(
            name="currencyfxrates",
            unique_together={("date", "currency")},
        ),
    ]
