# Generated by Django 5.0.10 on 2026-01-14 07:04

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('accounts', '0001_initial'),
        ('inventory', '0001_initial'),
        ('orders', '0001_initial'),
        ('products', '0001_initial'),
        ('user_roles', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='incomingdocumentitem',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='incoming_document_items', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='inventory',
            name='conducted_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inventories', to='user_roles.userrole', verbose_name='Провел инвентаризацию'),
        ),
        migrations.AddField(
            model_name='incomingdocument',
            name='inventory',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='incoming_documents', to='inventory.inventory', verbose_name='Инвентаризация'),
        ),
        migrations.AddField(
            model_name='inventoryline',
            name='inventory',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='inventory.inventory', verbose_name='Инвентаризация'),
        ),
        migrations.AddField(
            model_name='inventoryline',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='locked_by_user',
            field=models.ForeignKey(blank=True, help_text='Кассир, который добавил комплект в корзину', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cart_locks', to='accounts.customuser', verbose_name='Заблокировано пользователем'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='order_item',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='orders.orderitem', verbose_name='Позиция заказа'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='product_kit',
            field=models.ForeignKey(blank=True, help_text='Временный комплект, для которого создан резерв', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='products.productkit', verbose_name='Комплект'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='sales_unit',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reservations', to='products.productsalesunit', verbose_name='Единица продажи'),
        ),
        migrations.AddField(
            model_name='sale',
            name='order',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sales', to='orders.order', verbose_name='Заказ'),
        ),
        migrations.AddField(
            model_name='sale',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sales', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='sale',
            name='sales_unit',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sales', to='products.productsalesunit', verbose_name='Единица продажи'),
        ),
        migrations.AddField(
            model_name='salebatchallocation',
            name='sale',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='batch_allocations', to='inventory.sale', verbose_name='Продажа'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='showcase',
            field=models.ForeignKey(blank=True, help_text='Витрина, на которой выложен букет', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.showcase', verbose_name='Витрина'),
        ),
        migrations.AddField(
            model_name='showcaseitem',
            name='locked_by_user',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='locked_showcase_items', to='accounts.customuser', verbose_name='Заблокировано пользователем'),
        ),
        migrations.AddField(
            model_name='showcaseitem',
            name='product_kit',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='showcase_items', to='products.productkit', verbose_name='Шаблон комплекта'),
        ),
        migrations.AddField(
            model_name='showcaseitem',
            name='showcase',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='showcase_items', to='inventory.showcase', verbose_name='Витрина'),
        ),
        migrations.AddField(
            model_name='showcaseitem',
            name='sold_order_item',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sold_showcase_items', to='orders.orderitem', verbose_name='Позиция заказа (продажа)'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='showcase_item',
            field=models.ForeignKey(blank=True, help_text='Для какого физического экземпляра создан резерв', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.showcaseitem', verbose_name='Экземпляр на витрине'),
        ),
        migrations.AddField(
            model_name='stock',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stocks', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='stockbatch',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_batches', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='salebatchallocation',
            name='batch',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sale_allocations', to='inventory.stockbatch', verbose_name='Партия'),
        ),
        migrations.AddField(
            model_name='transferdocumentitem',
            name='batch',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_document_items', to='inventory.stockbatch', verbose_name='Исходная партия (FIFO)'),
        ),
        migrations.AddField(
            model_name='transferdocumentitem',
            name='new_batch',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transfer_document_items_created', to='inventory.stockbatch', verbose_name='Созданная партия на целевом складе'),
        ),
        migrations.AddField(
            model_name='transferdocumentitem',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_document_items', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='transferdocumentitem',
            name='transfer_document',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='inventory.transferdocument', verbose_name='Документ перемещения'),
        ),
        migrations.AddField(
            model_name='transformation',
            name='employee',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transformations', to='accounts.customuser', verbose_name='Сотрудник'),
        ),
        migrations.AddField(
            model_name='transformationinput',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='transformation_inputs', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='transformationinput',
            name='transformation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inputs', to='inventory.transformation', verbose_name='Трансформация'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='transformation_input',
            field=models.ForeignKey(blank=True, help_text='Резерв для входного товара трансформации (черновик)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.transformationinput', verbose_name='Входной товар трансформации'),
        ),
        migrations.AddField(
            model_name='transformationoutput',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='transformation_outputs', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='transformationoutput',
            name='stock_batch',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transformation_outputs', to='inventory.stockbatch', verbose_name='Созданная партия'),
        ),
        migrations.AddField(
            model_name='transformationoutput',
            name='transformation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outputs', to='inventory.transformation', verbose_name='Трансформация'),
        ),
        migrations.AddIndex(
            model_name='warehouse',
            index=models.Index(fields=['is_active'], name='inventory_w_is_acti_3ddeac_idx'),
        ),
        migrations.AddIndex(
            model_name='warehouse',
            index=models.Index(fields=['is_default'], name='inventory_w_is_defa_4b7615_idx'),
        ),
        migrations.AddIndex(
            model_name='warehouse',
            index=models.Index(fields=['is_pickup_point'], name='inventory_w_is_pick_e86268_idx'),
        ),
        migrations.AddField(
            model_name='transformation',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='transformations', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='transferdocument',
            name='from_warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_documents_from', to='inventory.warehouse', verbose_name='Склад-отгрузки'),
        ),
        migrations.AddField(
            model_name='transferdocument',
            name='to_warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_documents_to', to='inventory.warehouse', verbose_name='Склад-приемки'),
        ),
        migrations.AddField(
            model_name='stockbatch',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_batches', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='stock',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stocks', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='showcase',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='showcases', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='sale',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sales', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='inventory',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inventories', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='incomingdocument',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='incoming_documents', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='writeoff',
            name='batch',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='writeoffs', to='inventory.stockbatch', verbose_name='Партия'),
        ),
        migrations.AddField(
            model_name='writeoffdocument',
            name='confirmed_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='confirmed_writeoff_documents', to='accounts.customuser', verbose_name='Провёл'),
        ),
        migrations.AddField(
            model_name='writeoffdocument',
            name='created_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_writeoff_documents', to='accounts.customuser', verbose_name='Создал'),
        ),
        migrations.AddField(
            model_name='writeoffdocument',
            name='inventory',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='writeoff_documents', to='inventory.inventory', verbose_name='Инвентаризация'),
        ),
        migrations.AddField(
            model_name='writeoffdocument',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='writeoff_documents', to='inventory.warehouse', verbose_name='Склад'),
        ),
        migrations.AddField(
            model_name='writeoffdocumentitem',
            name='document',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='inventory.writeoffdocument', verbose_name='Документ'),
        ),
        migrations.AddField(
            model_name='writeoffdocumentitem',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='writeoff_document_items', to='products.product', verbose_name='Товар'),
        ),
        migrations.AddField(
            model_name='writeoffdocumentitem',
            name='reservation',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='writeoff_document_item_reverse', to='inventory.reservation', verbose_name='Резерв'),
        ),
        migrations.AddField(
            model_name='reservation',
            name='writeoff_document_item',
            field=models.ForeignKey(blank=True, help_text='Резерв для документа списания (черновик)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.writeoffdocumentitem', verbose_name='Позиция документа списания'),
        ),
        migrations.AddIndex(
            model_name='incomingdocumentitem',
            index=models.Index(fields=['document'], name='inventory_i_documen_96d470_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocumentitem',
            index=models.Index(fields=['product'], name='inventory_i_product_932432_idx'),
        ),
        migrations.AddIndex(
            model_name='showcaseitem',
            index=models.Index(fields=['showcase', 'status'], name='inventory_s_showcas_116f7f_idx'),
        ),
        migrations.AddIndex(
            model_name='showcaseitem',
            index=models.Index(fields=['product_kit', 'status'], name='inventory_s_product_785870_idx'),
        ),
        migrations.AddIndex(
            model_name='showcaseitem',
            index=models.Index(fields=['status', 'cart_lock_expires_at'], name='inventory_s_status_6acf05_idx'),
        ),
        migrations.AddIndex(
            model_name='showcaseitem',
            index=models.Index(fields=['locked_by_user', 'status'], name='inventory_s_locked__88eac9_idx'),
        ),
        migrations.AddIndex(
            model_name='transferdocumentitem',
            index=models.Index(fields=['transfer_document'], name='inventory_t_transfe_02e7fe_idx'),
        ),
        migrations.AddIndex(
            model_name='transferdocumentitem',
            index=models.Index(fields=['product'], name='inventory_t_product_a5ed4b_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='transferdocumentitem',
            unique_together={('transfer_document', 'batch')},
        ),
        migrations.AddIndex(
            model_name='transformation',
            index=models.Index(fields=['document_number'], name='inventory_t_documen_559778_idx'),
        ),
        migrations.AddIndex(
            model_name='transformation',
            index=models.Index(fields=['warehouse', 'status'], name='inventory_t_warehou_934275_idx'),
        ),
        migrations.AddIndex(
            model_name='transformation',
            index=models.Index(fields=['-date'], name='inventory_t_date_65cfab_idx'),
        ),
        migrations.AddIndex(
            model_name='transferdocument',
            index=models.Index(fields=['document_number'], name='inventory_t_documen_d9087d_idx'),
        ),
        migrations.AddIndex(
            model_name='transferdocument',
            index=models.Index(fields=['from_warehouse', 'to_warehouse'], name='inventory_t_from_wa_118a47_idx'),
        ),
        migrations.AddIndex(
            model_name='transferdocument',
            index=models.Index(fields=['-created_at'], name='inventory_t_created_5ad653_idx'),
        ),
        migrations.AddIndex(
            model_name='stockbatch',
            index=models.Index(fields=['product', 'warehouse'], name='inventory_s_product_022460_idx'),
        ),
        migrations.AddIndex(
            model_name='stockbatch',
            index=models.Index(fields=['created_at'], name='inventory_s_created_10279b_idx'),
        ),
        migrations.AddIndex(
            model_name='stockbatch',
            index=models.Index(fields=['is_active'], name='inventory_s_is_acti_0dd559_idx'),
        ),
        migrations.AddIndex(
            model_name='stock',
            index=models.Index(fields=['product', 'warehouse'], name='inventory_s_product_112b63_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='stock',
            unique_together={('product', 'warehouse')},
        ),
        migrations.AddIndex(
            model_name='showcase',
            index=models.Index(fields=['warehouse'], name='inventory_s_warehou_1e4a8a_idx'),
        ),
        migrations.AddIndex(
            model_name='showcase',
            index=models.Index(fields=['is_active'], name='inventory_s_is_acti_387bfb_idx'),
        ),
        migrations.AddIndex(
            model_name='showcase',
            index=models.Index(fields=['is_default'], name='inventory_s_is_defa_bf9a7c_idx'),
        ),
        migrations.AddIndex(
            model_name='sale',
            index=models.Index(fields=['product', 'warehouse'], name='inventory_s_product_084314_idx'),
        ),
        migrations.AddIndex(
            model_name='sale',
            index=models.Index(fields=['date'], name='inventory_s_date_8972d4_idx'),
        ),
        migrations.AddIndex(
            model_name='sale',
            index=models.Index(fields=['order'], name='inventory_s_order_i_7d13ea_idx'),
        ),
        migrations.AddIndex(
            model_name='sale',
            index=models.Index(fields=['is_pending_cost'], name='inventory_s_is_pend_81a3db_idx'),
        ),
        migrations.AddIndex(
            model_name='inventory',
            index=models.Index(fields=['document_number'], name='inventory_i_documen_8df782_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocument',
            index=models.Index(fields=['document_number'], name='inventory_i_documen_5b89ad_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocument',
            index=models.Index(fields=['warehouse', 'status'], name='inventory_i_warehou_8f141d_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocument',
            index=models.Index(fields=['date'], name='inventory_i_date_8ace9b_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocument',
            index=models.Index(fields=['receipt_type'], name='inventory_i_receipt_92f322_idx'),
        ),
        migrations.AddIndex(
            model_name='incomingdocument',
            index=models.Index(fields=['-created_at'], name='inventory_i_created_174930_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoff',
            index=models.Index(fields=['batch'], name='inventory_w_batch_i_b098ce_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoff',
            index=models.Index(fields=['date'], name='inventory_w_date_70c7e3_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocument',
            index=models.Index(fields=['document_number'], name='inventory_w_documen_a9ae00_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocument',
            index=models.Index(fields=['warehouse', 'status'], name='inventory_w_warehou_69fbf6_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocument',
            index=models.Index(fields=['date'], name='inventory_w_date_a853cb_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocument',
            index=models.Index(fields=['-created_at'], name='inventory_w_created_02c298_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocumentitem',
            index=models.Index(fields=['document'], name='inventory_w_documen_d77c5e_idx'),
        ),
        migrations.AddIndex(
            model_name='writeoffdocumentitem',
            index=models.Index(fields=['product'], name='inventory_w_product_6e32fc_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['product', 'warehouse'], name='inventory_r_product_fa0d33_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['status'], name='inventory_r_status_806333_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['order_item'], name='inventory_r_order_i_ae991f_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['showcase'], name='inventory_r_showcas_bd3508_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['product_kit'], name='inventory_r_product_70aed5_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['cart_lock_expires_at'], name='inventory_r_cart_lo_e9b52a_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['locked_by_user'], name='inventory_r_locked__706cbf_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['product_kit', 'cart_lock_expires_at'], name='inventory_r_product_5dacdf_idx'),
        ),
        migrations.AddIndex(
            model_name='reservation',
            index=models.Index(fields=['showcase_item'], name='inventory_r_showcas_8cfff5_idx'),
        ),
    ]
