# Generated by Django 4.1.4 on 2023-04-22 09:01

import datetime
import uuid

import django.core.validators
import django.db.models.deletion
import media.utils
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("main", "0002_segmentation"),
        ("category", "0001_initial"),
        ("account", "0001_initial"),
        ("statement", "0001_initial"),
    ]

    state_operations = [
        migrations.CreateModel(
            name="Transaction",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        default="Transaction", max_length=256, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "value",
                    models.DecimalField(
                        decimal_places=2, default=0, max_digits=12, verbose_name="Value"
                    ),
                ),
                (
                    "date",
                    models.DateField(default=datetime.date.today, verbose_name="Date"),
                ),
                (
                    "real_date",
                    models.DateField(blank=True, null=True, verbose_name="Real date"),
                ),
                (
                    "trader",
                    models.CharField(
                        blank=True, max_length=128, null=True, verbose_name="Trader"
                    ),
                ),
                (
                    "payment",
                    models.CharField(
                        blank=True, max_length=128, null=True, verbose_name="Payment"
                    ),
                ),
                (
                    "account",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="account.account",
                        verbose_name="Account",
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="category.category",
                        verbose_name="Category",
                    ),
                ),
                (
                    "statement",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="statement.statement",
                        verbose_name="Statement",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "Transaction",
                "verbose_name_plural": "Transactions",
                "ordering": ["-date", "statement"],
                "db_table": "transaction_transaction",
            },
        ),
        migrations.CreateModel(
            name="Invoice",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        default="Invoice", max_length=256, verbose_name="Name"
                    ),
                ),
                (
                    "file",
                    models.FileField(
                        max_length=128,
                        upload_to=media.utils.get_path,
                        validators=[
                            django.core.validators.FileExtensionValidator(["pdf"])
                        ],
                        verbose_name="File",
                    ),
                ),
                (
                    "transaction",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="transaction.transaction",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "Invoice",
                "verbose_name_plural": "Invoices",
                "ordering": ["transaction", "name"],
                "db_table": "transaction_invoice",
            },
        ),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(state_operations=state_operations)
    ]
