# 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 = [
        ('product', '0011_alter_productcolorimage_product'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='HistoricalOrder',
            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')),
                ('status', models.CharField(choices=[('pending_initial_payment', 'Pendiente de pago inicial'), ('initial_payment_review', 'Pago inicial en revisión'), ('manufacturing', 'En fabricación'), ('waiting_final_payment', 'Esperando pago final'), ('final_payment_review', 'Pago final en revisión'), ('shipped', 'Enviado'), ('finalized', 'Finalizado'), ('returned_manufacturing', 'Devuelto / En refabricación'), ('cancelled', 'Cancelado')], default='pending_initial_payment', max_length=30, verbose_name='Estado')),
                ('total_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=12, verbose_name='Precio total')),
                ('notes', models.TextField(blank=True, help_text='Observaciones adicionales del cliente sobre el pedido', null=True, verbose_name='Notas del pedido')),
                ('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)),
                ('user', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Cliente')),
            ],
            options={
                'verbose_name': 'historical Pedido',
                'verbose_name_plural': 'historical Pedidos',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Order',
            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')),
                ('status', models.CharField(choices=[('pending_initial_payment', 'Pendiente de pago inicial'), ('initial_payment_review', 'Pago inicial en revisión'), ('manufacturing', 'En fabricación'), ('waiting_final_payment', 'Esperando pago final'), ('final_payment_review', 'Pago final en revisión'), ('shipped', 'Enviado'), ('finalized', 'Finalizado'), ('returned_manufacturing', 'Devuelto / En refabricación'), ('cancelled', 'Cancelado')], default='pending_initial_payment', max_length=30, verbose_name='Estado')),
                ('total_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=12, verbose_name='Precio total')),
                ('notes', models.TextField(blank=True, help_text='Observaciones adicionales del cliente sobre el pedido', null=True, verbose_name='Notas del pedido')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to=settings.AUTH_USER_MODEL, verbose_name='Cliente')),
            ],
            options={
                'verbose_name': 'Pedido',
                'verbose_name_plural': 'Pedidos',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ManufacturingOrder',
            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')),
                ('status', models.CharField(choices=[('pending', 'Pendiente'), ('in_progress', 'En progreso'), ('completed', 'Completada'), ('cancelled', 'Cancelada')], default='pending', max_length=20, verbose_name='Estado')),
                ('iteration', models.PositiveIntegerField(default=1, help_text='Número de orden de fabricación para este pedido (incrementa en refabricaciones)', verbose_name='Iteración')),
                ('issued_at', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de emisión')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Fecha de completado')),
                ('notes', models.TextField(blank=True, help_text='Instrucciones especiales para la fábrica', null=True, verbose_name='Notas de fabricación')),
                ('issued_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='issued_manufacturing_orders', to=settings.AUTH_USER_MODEL, verbose_name='Emitida por')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='manufacturing_orders', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'Orden de fabricación',
                'verbose_name_plural': 'Órdenes de fabricación',
                'ordering': ['-issued_at'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalOrderDetail',
            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')),
                ('quantity', models.PositiveIntegerField(default=1, verbose_name='Cantidad')),
                ('unit_price', models.DecimalField(decimal_places=2, default=0.0, help_text='Precio acordado por unidad en el momento del pedido', max_digits=12, verbose_name='Precio unitario')),
                ('final_price', models.DecimalField(decimal_places=2, default=0.0, help_text='Precio total de este detalle (quantity × unit_price)', max_digits=12, verbose_name='Precio final')),
                ('notes', models.TextField(blank=True, help_text='Especificaciones personalizadas del producto (color, dimensiones, etc.)', null=True, verbose_name='Especificaciones')),
                ('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)),
                ('order', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'historical Detalle de pedido',
                'verbose_name_plural': 'historical Detalles de pedido',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalManufacturingOrder',
            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')),
                ('status', models.CharField(choices=[('pending', 'Pendiente'), ('in_progress', 'En progreso'), ('completed', 'Completada'), ('cancelled', 'Cancelada')], default='pending', max_length=20, verbose_name='Estado')),
                ('iteration', models.PositiveIntegerField(default=1, help_text='Número de orden de fabricación para este pedido (incrementa en refabricaciones)', verbose_name='Iteración')),
                ('issued_at', models.DateTimeField(blank=True, editable=False, verbose_name='Fecha de emisión')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Fecha de completado')),
                ('notes', models.TextField(blank=True, help_text='Instrucciones especiales para la fábrica', null=True, verbose_name='Notas de fabricación')),
                ('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)),
                ('issued_by', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Emitida por')),
                ('order', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'historical Orden de fabricación',
                'verbose_name_plural': 'historical Órdenes de fabricación',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='OrderDetail',
            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')),
                ('quantity', models.PositiveIntegerField(default=1, verbose_name='Cantidad')),
                ('unit_price', models.DecimalField(decimal_places=2, default=0.0, help_text='Precio acordado por unidad en el momento del pedido', max_digits=12, verbose_name='Precio unitario')),
                ('final_price', models.DecimalField(decimal_places=2, default=0.0, help_text='Precio total de este detalle (quantity × unit_price)', max_digits=12, verbose_name='Precio final')),
                ('notes', models.TextField(blank=True, help_text='Especificaciones personalizadas del producto (color, dimensiones, etc.)', null=True, verbose_name='Especificaciones')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='details', to='orders.order', verbose_name='Pedido')),
            ],
            options={
                'verbose_name': 'Detalle de pedido',
                'verbose_name_plural': 'Detalles de pedido',
            },
        ),
        migrations.CreateModel(
            name='HistoricalOrderProduct',
            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')),
                ('price_at_order', models.DecimalField(decimal_places=2, help_text='Precio del producto registrado en el momento en que se realizó el pedido', max_digits=12, verbose_name='Precio al momento del pedido')),
                ('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)),
                ('product', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='product.product', verbose_name='Producto')),
                ('order_detail', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='orders.orderdetail', verbose_name='Detalle de pedido')),
            ],
            options={
                'verbose_name': 'historical Producto en pedido',
                'verbose_name_plural': 'historical Productos en pedido',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='OrderProduct',
            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')),
                ('price_at_order', models.DecimalField(decimal_places=2, help_text='Precio del producto registrado en el momento en que se realizó el pedido', max_digits=12, verbose_name='Precio al momento del pedido')),
                ('order_detail', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='order_products', to='orders.orderdetail', verbose_name='Detalle de pedido')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='order_products', to='product.product', verbose_name='Producto')),
            ],
            options={
                'verbose_name': 'Producto en pedido',
                'verbose_name_plural': 'Productos en pedido',
            },
        ),
    ]
