# Generated by Django 5.2.7 on 2025-03-01 00:00

import core.entity
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from django.utils.translation import gettext_lazy as _


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0097_customer_account_rework"),
        ("ocpp", "0047_location_table_to_core"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(
            database_operations=[],
            state_operations=[
                migrations.CreateModel(
                    name="Location",
                    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)),
                        ("name", models.CharField(max_length=200)),
                        (
                            "latitude",
                            models.DecimalField(
                                blank=True, decimal_places=6, max_digits=9, null=True
                            ),
                        ),
                        (
                            "longitude",
                            models.DecimalField(
                                blank=True, decimal_places=6, max_digits=9, null=True
                            ),
                        ),
                        (
                            "zone",
                            models.CharField(
                                blank=True,
                                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 used to select matching energy tariffs.",
                                max_length=3,
                                null=True,
                            ),
                        ),
                        (
                            "contract_type",
                            models.CharField(
                                blank=True,
                                choices=[
                                    ("domestic", "Domestic service (Tarifa 1)"),
                                    ("dac", "High consumption domestic (DAC)"),
                                    ("pdbt", "General service low demand (PDBT)"),
                                    ("gdbt", "General service high demand (GDBT)"),
                                    ("gdmto", "General distribution medium tension (GDMTO)"),
                                    ("gdmth", "General distribution medium tension hourly (GDMTH)"),
                                ],
                                help_text="CFE service contract type required to match energy tariff pricing.",
                                max_length=16,
                                null=True,
                            ),
                        ),
                    ],
                    options={
                        "verbose_name": "Location",
                        "verbose_name_plural": "Locations",
                        "db_table": "core_location",
                    },
                    bases=(core.entity.Entity,),
                )
            ],
        ),
        migrations.AddField(
            model_name="location",
            name="address_line1",
            field=models.CharField(
                default="",
                help_text=_("Primary street address or location description."),
                max_length=255,
                verbose_name=_("Street address"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="address_line2",
            field=models.CharField(
                default="",
                help_text=_("Additional address information such as suite or building."),
                max_length=255,
                verbose_name=_("Street address line 2"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="city",
            field=models.CharField(
                default="",
                max_length=128,
                verbose_name=_("City"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="country",
            field=models.CharField(
                default="",
                max_length=64,
                verbose_name=_("Country"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="phone_number",
            field=models.CharField(
                default="",
                max_length=32,
                verbose_name=_("Phone number"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="postal_code",
            field=models.CharField(
                default="",
                max_length=32,
                verbose_name=_("Postal code"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="state",
            field=models.CharField(
                default="",
                max_length=128,
                verbose_name=_("State / Province"),
                blank=True,
            ),
        ),
        migrations.AddField(
            model_name="location",
            name="assigned_to",
            field=models.ForeignKey(
                blank=True,
                help_text=_("Optional user responsible for this location."),
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="assigned_locations",
                to=settings.AUTH_USER_MODEL,
                verbose_name=_("Assigned to"),
            ),
        ),
    ]
