# Generated by Django 5.2.14 on 2026-08-25 17:14

import django.db.models.deletion
import simple_history.models
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('orders', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Distributor',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('is_deleted', models.BooleanField(default=False, verbose_name='Eliminado')),
                ('created_at', models.DateField(auto_now_add=True, verbose_name='Fecha de Creación')),
                ('updated_at', models.DateField(auto_now=True, verbose_name='Fecha de Modificación')),
                ('deleted_at', models.DateField(blank=True, null=True, verbose_name='Fecha de Eliminación')),
                ('name', models.CharField(max_length=200, verbose_name='Nombre del distribuidor')),
                ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='Teléfono')),
                ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='Correo electrónico')),
                ('rif', models.CharField(help_text='Registro de Información Fiscal del distribuidor', max_length=20, unique=True, verbose_name='RIF')),
                ('is_active', models.BooleanField(default=True, verbose_name='Está activo')),
            ],
            options={
                'verbose_name': 'Distribuidor',
                'verbose_name_plural': 'Distribuidores',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalDistributor',
            fields=[
                ('id', models.IntegerField(blank=True, db_index=True)),
                ('is_deleted', models.BooleanField(default=False, verbose_name='Eliminado')),
                ('created_at', models.DateField(blank=True, editable=False, verbose_name='Fecha de Creación')),
                ('updated_at', models.DateField(blank=True, editable=False, verbose_name='Fecha de Modificación')),
                ('deleted_at', models.DateField(blank=True, null=True, verbose_name='Fecha de Eliminación')),
                ('name', models.CharField(max_length=200, verbose_name='Nombre del distribuidor')),
                ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='Teléfono')),
                ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='Correo electrónico')),
                ('rif', models.CharField(db_index=True, help_text='Registro de Información Fiscal del distribuidor', max_length=20, verbose_name='RIF')),
                ('is_active', models.BooleanField(default=True, verbose_name='Está activo')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical Distribuidor',
                'verbose_name_plural': 'historical Distribuidores',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalShipment',
            fields=[
                ('id', models.IntegerField(blank=True, db_index=True)),
                ('is_deleted', models.BooleanField(default=False, verbose_name='Eliminado')),
                ('created_at', models.DateField(blank=True, editable=False, verbose_name='Fecha de Creación')),
                ('updated_at', models.DateField(blank=True, editable=False, verbose_name='Fecha de Modificación')),
                ('deleted_at', models.DateField(blank=True, null=True, verbose_name='Fecha de Eliminación')),
                ('address', models.TextField(verbose_name='Dirección de entrega')),
                ('phone', models.CharField(max_length=20, verbose_name='Teléfono de contacto')),
                ('status', models.CharField(choices=[('pending', 'Pendiente'), ('in_transit', 'En camino'), ('delivered', 'Entregado'), ('returned', 'Devuelto'), ('failed', 'Fallido')], default='pending', max_length=15, verbose_name='Estado')),
                ('estimated_date', models.DateField(blank=True, null=True, verbose_name='Fecha estimada de entrega')),
                ('price', models.DecimalField(blank=True, decimal_places=2, help_text='Costo del servicio de envío (opcional)', max_digits=10, null=True, verbose_name='Precio del envío')),
                ('notes', models.TextField(blank=True, help_text='Instrucciones especiales para el distribuidor o destinatario', null=True, verbose_name='Notas de envío')),
                ('delivered_at', models.DateTimeField(blank=True, null=True, verbose_name='Fecha de entrega real')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('distributor', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='shipment.distributor', verbose_name='Distribuidor')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('order', models.ForeignKey(blank=True, db_constraint=False, help_text='Una orden puede tener múltiples envíos (p.ej. ante devoluciones)', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'historical Envío',
                'verbose_name_plural': 'historical Envíos',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Shipment',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('is_deleted', models.BooleanField(default=False, verbose_name='Eliminado')),
                ('created_at', models.DateField(auto_now_add=True, verbose_name='Fecha de Creación')),
                ('updated_at', models.DateField(auto_now=True, verbose_name='Fecha de Modificación')),
                ('deleted_at', models.DateField(blank=True, null=True, verbose_name='Fecha de Eliminación')),
                ('address', models.TextField(verbose_name='Dirección de entrega')),
                ('phone', models.CharField(max_length=20, verbose_name='Teléfono de contacto')),
                ('status', models.CharField(choices=[('pending', 'Pendiente'), ('in_transit', 'En camino'), ('delivered', 'Entregado'), ('returned', 'Devuelto'), ('failed', 'Fallido')], default='pending', max_length=15, verbose_name='Estado')),
                ('estimated_date', models.DateField(blank=True, null=True, verbose_name='Fecha estimada de entrega')),
                ('price', models.DecimalField(blank=True, decimal_places=2, help_text='Costo del servicio de envío (opcional)', max_digits=10, null=True, verbose_name='Precio del envío')),
                ('notes', models.TextField(blank=True, help_text='Instrucciones especiales para el distribuidor o destinatario', null=True, verbose_name='Notas de envío')),
                ('delivered_at', models.DateTimeField(blank=True, null=True, verbose_name='Fecha de entrega real')),
                ('distributor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='shipments', to='shipment.distributor', verbose_name='Distribuidor')),
                ('order', models.ForeignKey(help_text='Una orden puede tener múltiples envíos (p.ej. ante devoluciones)', on_delete=django.db.models.deletion.CASCADE, related_name='shipments', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'Envío',
                'verbose_name_plural': 'Envíos',
                'ordering': ['-created_at'],
            },
        ),
    ]
