# Generated by Django 5.2.4 on 2025-09-20 23:10

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0037_alter_publicwifiaccess_options"),
    ]

    operations = [
        migrations.CreateModel(
            name="EnergyTariff",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "year",
                    models.PositiveIntegerField(
                        help_text="Calendar year when the tariff applies.",
                        validators=[django.core.validators.MinValueValidator(2000)],
                    ),
                ),
                (
                    "month",
                    models.PositiveSmallIntegerField(
                        choices=[
                            (1, "January"),
                            (2, "February"),
                            (3, "March"),
                            (4, "April"),
                            (5, "May"),
                            (6, "June"),
                            (7, "July"),
                            (8, "August"),
                            (9, "September"),
                            (10, "October"),
                            (11, "November"),
                            (12, "December"),
                        ],
                        help_text="Calendar month when the tariff applies.",
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(12),
                        ],
                    ),
                ),
                (
                    "zone",
                    models.CharField(
                        choices=[
                            ("1", "Zone 1"),
                            ("1A", "Zone 1A"),
                            ("1B", "Zone 1B"),
                            ("1C", "Zone 1C"),
                            ("1D", "Zone 1D"),
                            ("1E", "Zone 1E"),
                            ("1F", "Zone 1F"),
                        ],
                        help_text="CFE climate zone associated with the tariff.",
                        max_length=3,
                    ),
                ),
                (
                    "contract_type",
                    models.CharField(
                        choices=[
                            ("domestic", "Domestic service (Tarifa 1)"),
                            ("dac", "High consumption domestic (DAC)"),
                            ("pdbt", "General service low demand (PDBT)"),
                            ("gdmto", "General distribution medium tension (GDMTO)"),
                            (
                                "gdmth",
                                "General distribution medium tension hourly (GDMTH)",
                            ),
                        ],
                        help_text="Type of service contract regulated by CFE.",
                        max_length=16,
                    ),
                ),
                (
                    "time_of_day",
                    models.CharField(
                        choices=[
                            ("flat", "All day"),
                            ("base", "Base"),
                            ("intermediate", "Intermediate"),
                            ("peak", "Peak"),
                            ("critical_peak", "Critical peak"),
                        ],
                        help_text="Day-part or consumption block where the tariff applies.",
                        max_length=32,
                    ),
                ),
                (
                    "start_time",
                    models.TimeField(
                        help_text="Start time for the tariff's applicability window."
                    ),
                ),
                (
                    "end_time",
                    models.TimeField(
                        help_text="End time for the tariff's applicability window."
                    ),
                ),
                (
                    "price_mxn",
                    models.DecimalField(
                        decimal_places=4,
                        help_text="Customer price per kWh in MXN.",
                        max_digits=10,
                    ),
                ),
                (
                    "cost_mxn",
                    models.DecimalField(
                        decimal_places=4,
                        help_text="Provider cost per kWh in MXN.",
                        max_digits=10,
                    ),
                ),
            ],
            options={
                "verbose_name": "Energy Tariff",
                "verbose_name_plural": "Energy Tariffs",
                "ordering": (
                    "-year",
                    "-month",
                    "zone",
                    "contract_type",
                    "time_of_day",
                    "start_time",
                ),
                "indexes": [
                    models.Index(
                        fields=["year", "month", "zone", "contract_type"],
                        name="energy_tariff_schedule_idx",
                    )
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=(
                            "year",
                            "month",
                            "zone",
                            "contract_type",
                            "time_of_day",
                            "start_time",
                            "end_time",
                        ),
                        name="uniq_energy_tariff_schedule",
                    )
                ],
            },
        ),
    ]
