# Generated by Django 4.2.26 on 2025-11-14 13:21

# Django
import django.core.validators
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("eveonline", "0017_alliance_and_corp_names_are_not_unique"),
        ("taxsystem", "0009_payments_corporation_id"),
    ]

    operations = [
        migrations.RenameModel(
            old_name="OwnerAudit",
            new_name="CorporationOwner",
        ),
        migrations.RenameModel(
            old_name="Payments",
            new_name="CorporationPayments",
        ),
        migrations.RenameModel(
            old_name="PaymentSystem",
            new_name="CorporationPaymentAccount",
        ),
        migrations.RenameModel(
            old_name="OwnerUpdateStatus",
            new_name="CorporationUpdateStatus",
        ),
        migrations.CreateModel(
            name="AllianceOwner",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("active", models.BooleanField(default=True)),
                (
                    "tax_amount",
                    models.DecimalField(
                        decimal_places=0,
                        default=0,
                        help_text="Tax Amount in ISK that is set for the corporation. Max 16 Digits",
                        max_digits=16,
                        validators=[
                            django.core.validators.MaxValueValidator(9999999999999999)
                        ],
                    ),
                ),
                (
                    "tax_period",
                    models.PositiveIntegerField(
                        default=30,
                        help_text="Tax Period in days for the corporation. Max 365 days. Default: 30 days",
                        validators=[django.core.validators.MaxValueValidator(365)],
                    ),
                ),
                (
                    "eve_alliance",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="eveonline.eveallianceinfo",
                    ),
                ),
                (
                    "corporation",
                    models.ForeignKey(
                        help_text="The corporation that owns this alliance tax system.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="taxsystem.corporationowner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="AllianceOwnerUpdateStatus",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "is_success",
                    models.BooleanField(db_index=True, default=None, null=True),
                ),
                ("error_message", models.TextField()),
                ("has_token_error", models.BooleanField(default=False)),
                (
                    "last_run_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_run_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "section",
                    models.CharField(
                        choices=[
                            ("payments", "Payments"),
                            ("payment_system", "Payment System"),
                            ("payday", "Payday"),
                        ],
                        db_index=True,
                        max_length=32,
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ts_alliance_update_status",
                        to="taxsystem.allianceowner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="AlliancePaymentAccount",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                ("date", models.DateTimeField(auto_now_add=True, null=True)),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("active", "Active"),
                            ("inactive", "Inactive"),
                            ("deactivated", "Deactivated"),
                            ("missing", "Missing"),
                        ],
                        default="active",
                        max_length=16,
                    ),
                ),
                (
                    "deposit",
                    models.DecimalField(
                        decimal_places=0,
                        default=0,
                        help_text="Deposit Pool in ISK. Max 16 Digits",
                        max_digits=16,
                        validators=[
                            django.core.validators.MaxValueValidator(9999999999999999),
                            django.core.validators.MinValueValidator(-9999999999999999),
                        ],
                    ),
                ),
                ("last_paid", models.DateTimeField(blank=True, null=True)),
                ("notice", models.TextField(blank=True, null=True)),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ts_alliance_payment_accounts",
                        to="taxsystem.allianceowner",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="AlliancePayments",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                ("entry_id", models.BigIntegerField()),
                ("amount", models.DecimalField(decimal_places=0, max_digits=12)),
                ("date", models.DateTimeField(blank=True, null=True)),
                ("reason", models.TextField(blank=True, null=True)),
                (
                    "request_status",
                    models.CharField(
                        choices=[
                            ("approved", "Approved"),
                            ("pending", "Pending"),
                            ("rejected", "Rejected"),
                            ("needs_approval", "Requires Auditor"),
                        ],
                        default="pending",
                        max_length=16,
                        verbose_name="Request Status",
                    ),
                ),
                (
                    "reviser",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Reviser that approved or rejected the payment",
                        max_length=100,
                    ),
                ),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ts_alliance_payments",
                        to="taxsystem.alliancepaymentaccount",
                    ),
                ),
                (
                    "owner_id",
                    models.PositiveIntegerField(
                        help_text=(
                            "ID of the owner (corporation or alliance) associated with this payment"
                        ),
                        null=True,
                        blank=True,
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
    ]
