# Generated by Django 5.2.14 on 2026-06-03 04:23

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 = [
        ("auth", "0012_alter_user_first_name_max_length"),
        ("buybackprogram", "0017_alter_contract_price_alter_contract_volume_and_more"),
        ("eveuniverse", "0012_alter_evebloodline_eve_ship_type"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="StructureNameCache",
            fields=[
                (
                    "structure_id",
                    models.BigIntegerField(primary_key=True, serialize=False),
                ),
                ("name", models.CharField(max_length=255)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.AlterModelOptions(
            name="general",
            options={
                "default_permissions": (),
                "managed": False,
                "permissions": (
                    ("basic_access", "Can access this app and see own statics."),
                    (
                        "manage_programs",
                        "Can manage own buyback programs and see own program statics.",
                    ),
                    (
                        "see_leaderboard",
                        "Can see leaderboards for all available programs.",
                    ),
                    (
                        "see_performance",
                        "Can see performance for all available programs.",
                    ),
                    ("see_all_statics", "Can see all program statics."),
                    ("manage_all_programs", "Can manage ALL buyback programs"),
                ),
            },
        ),
        migrations.AddField(
            model_name="location",
            name="asset_location_id",
            field=models.BigIntegerField(
                blank=True,
                default=None,
                help_text="The ESI asset system location ID for this structure. Differs from Structure ID on some structures. Leave blank to use Structure ID.",
                null=True,
                verbose_name="Asset system location ID",
            ),
        ),
        migrations.AddField(
            model_name="program",
            name="is_public",
            field=models.BooleanField(
                default=False,
                help_text="If enabled, unauthenticated users can access the price calculator for this program via a public URL.",
                verbose_name="Public calculator",
            ),
        ),
        migrations.AddField(
            model_name="program",
            name="t1_refining_rate",
            field=models.DecimalField(
                decimal_places=2,
                default=50.0,
                help_text="The reprocessing efficiency used exclusively for calculating the scrap value of modules, ships, and drones.",
                max_digits=5,
                verbose_name="T1 Scrap Refining Rate (%)",
            ),
        ),
        migrations.AddField(
            model_name="program",
            name="use_reprocessed_value_for_t1",
            field=models.BooleanField(
                default=False,
                help_text="If enabled, ships, modules, and drones with a meta level of 4 or lower will be valued based on their reprocessed mineral value using the program's refining rate.",
                verbose_name="Use reprocessed value for T1/Named (Meta 1-4)",
            ),
        ),
        migrations.AddField(
            model_name="programitem",
            name="market_group",
            field=models.ForeignKey(
                blank=True,
                help_text="Select a market group for special tax",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="eveuniverse.evemarketgroup",
            ),
        ),
        migrations.AlterField(
            model_name="programitem",
            name="disallow_item",
            field=models.BooleanField(
                default=False,
                help_text="Disallow this item or market group from the program.",
                verbose_name="Disallow item in program",
            ),
        ),
        migrations.AlterField(
            model_name="programitem",
            name="item_tax",
            field=models.IntegerField(
                default=0,
                help_text="How much do you want to adjust the default tax on this item.",
                null=True,
                validators=[
                    django.core.validators.MaxValueValidator(100),
                    django.core.validators.MinValueValidator(-100),
                ],
                verbose_name="Item tax adjustment",
            ),
        ),
        migrations.AlterField(
            model_name="programitem",
            name="item_type",
            field=models.ForeignKey(
                blank=True,
                help_text="Select a specific item for special tax",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="eveuniverse.evetype",
            ),
        ),
        migrations.AlterField(
            model_name="tracking",
            name="issuer_user",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.CreateModel(
            name="HangarDivision",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("division_id", models.IntegerField()),
                ("name", models.CharField(max_length=128)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hangars",
                        to="buybackprogram.owner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "unique_together": {("owner", "division_id")},
            },
        ),
        migrations.CreateModel(
            name="ReverseProgram",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="A name or description for this reverse buyback program.",
                        max_length=64,
                    ),
                ),
                (
                    "is_corporation",
                    models.BooleanField(
                        default=False,
                        help_text="If the contract should be issued from the owner's corporation.",
                    ),
                ),
                (
                    "expiration",
                    models.CharField(
                        choices=[
                            ("1 Day", "1 Day"),
                            ("3 Days", "3 Days"),
                            ("1 Week", "1 Week"),
                            ("2 Weeks", "2 Weeks"),
                            ("4 Weeks", "4 Weeks"),
                        ],
                        default="2 Weeks",
                        help_text="Expiration time for contracts.",
                        max_length=7,
                    ),
                ),
                (
                    "price_type",
                    models.CharField(
                        choices=[("Buy", "Buy"), ("Sell", "Sell"), ("Split", "Split")],
                        default="Sell",
                        help_text="Price type to use as the base price. Default: Sell",
                        max_length=7,
                    ),
                ),
                (
                    "markup",
                    models.IntegerField(
                        default=0,
                        help_text="Markup percentage added on top of the base price. May also be negative.",
                        validators=[
                            django.core.validators.MaxValueValidator(100),
                            django.core.validators.MinValueValidator(-100),
                        ],
                        verbose_name="Sell markup %",
                    ),
                ),
                (
                    "is_public",
                    models.BooleanField(
                        default=False,
                        help_text="If enabled, this program is visible and usable without login.",
                        verbose_name="Public program",
                    ),
                ),
                (
                    "discord_dm_notification",
                    models.BooleanField(
                        default=False,
                        help_text="Receive a DM notification each time a new buy request is created.",
                        verbose_name="Discord direct messages for new requests",
                    ),
                ),
                (
                    "discord_channel_notification",
                    models.CharField(
                        blank=True,
                        help_text="Discord webhook to send buy request notifications to.",
                        max_length=256,
                        null=True,
                        verbose_name="Discord webhook for notifications",
                    ),
                ),
                (
                    "hangar_division",
                    models.ForeignKey(
                        blank=True,
                        help_text="The corporation hangar division where stock is stored.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="buybackprogram.hangardivision",
                    ),
                ),
                (
                    "location",
                    models.ManyToManyField(
                        help_text="Locations where stock is held and contracts will be created.",
                        related_name="+",
                        to="buybackprogram.location",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="buybackprogram.owner",
                        verbose_name="Manager",
                    ),
                ),
                (
                    "restricted_to_group",
                    models.ManyToManyField(
                        blank=True,
                        help_text="The group(s) that will be able to see this reverse buyback program. If none is selected program is open for all.",
                        related_name="buybackprogram_reverse_require_groups",
                        to="auth.group",
                    ),
                ),
                (
                    "restricted_to_state",
                    models.ManyToManyField(
                        blank=True,
                        help_text="The state(s) that will be able to see this reverse buyback program. If none is selected program is open for all.",
                        related_name="buybackprogram_reverse_require_states",
                        to="authentication.state",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="ReverseTracking",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("net_price", models.DecimalField(decimal_places=2, max_digits=20)),
                ("tracking_number", models.CharField(max_length=32)),
                ("created_at", models.DateTimeField(blank=True, null=True)),
                ("additional_notes", models.TextField(blank=True, null=True)),
                (
                    "contract",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="buybackprogram.contract",
                    ),
                ),
                (
                    "issuer_user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "program",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="buybackprogram.reverseprogram",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="ReverseTrackingItem",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("quantity", models.IntegerField()),
                ("buy_value", models.DecimalField(decimal_places=2, max_digits=20)),
                (
                    "eve_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eveuniverse.evetype",
                    ),
                ),
                (
                    "tracking",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="buybackprogram.reversetracking",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="WalletDivision",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("division_id", models.IntegerField()),
                ("name", models.CharField(max_length=128)),
                (
                    "balance",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=20),
                ),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="wallets",
                        to="buybackprogram.owner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "unique_together": {("owner", "division_id")},
            },
        ),
        migrations.AddField(
            model_name="program",
            name="wallet",
            field=models.ForeignKey(
                blank=True,
                help_text="The wallet division used to fund this buyback program.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="buybackprogram.walletdivision",
            ),
        ),
        migrations.CreateModel(
            name="HangarStock",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("quantity", models.IntegerField()),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "eve_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eveuniverse.evetype",
                    ),
                ),
                (
                    "program",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="stock",
                        to="buybackprogram.reverseprogram",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "unique_together": {("program", "eve_type")},
            },
        ),
        migrations.CreateModel(
            name="StaticItemPrice",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "price",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="The static price to use instead of market data",
                        max_digits=20,
                    ),
                ),
                (
                    "eve_type",
                    models.ForeignKey(
                        help_text="The item to set a static price for",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eveuniverse.evetype",
                    ),
                ),
                (
                    "program",
                    models.ForeignKey(
                        help_text="The program this price applies to",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="static_prices",
                        to="buybackprogram.program",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "unique_together": {("program", "eve_type")},
            },
        ),
        migrations.CreateModel(
            name="WatchlistItem",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "eve_group",
                    models.ForeignKey(
                        blank=True,
                        help_text="Entire item group to watch (e.g. 'Officer Modules')",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eveuniverse.evegroup",
                    ),
                ),
                (
                    "item_type",
                    models.ForeignKey(
                        blank=True,
                        help_text="Specific item to watch (leave blank if watching a whole group)",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eveuniverse.evetype",
                    ),
                ),
                (
                    "program",
                    models.ForeignKey(
                        help_text="The program this watchlist applies to",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="buybackprogram.program",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "unique_together": {("program", "item_type", "eve_group")},
            },
        ),
    ]
