# Generated by Django 5.2.11 on 2026-04-20 17:50

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


class Migration(migrations.Migration):

    dependencies = [
        ('companies', '0006_companysettings_auto_print_on_sale_and_more'),
        ('core', '0017_aichatlog_aiprompt'),
        ('inventory', '0013_migrate_global_stock_to_main_branch'),
    ]

    operations = [
        migrations.CreateModel(
            name='ProductBundle',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('sku', models.CharField(max_length=100)),
                ('barcode', models.CharField(blank=True, max_length=100)),
                ('price', models.DecimalField(decimal_places=2, max_digits=10)),
                ('image', models.ImageField(blank=True, null=True, upload_to='bundles/')),
                ('notes', models.TextField(blank=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='product_bundles', to='companies.company')),
            ],
            options={
                'verbose_name': 'Product Bundle',
                'verbose_name_plural': 'Product Bundles',
                'ordering': ['name'],
                'unique_together': {('company', 'sku')},
            },
        ),
        migrations.CreateModel(
            name='ProductVariant',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('attribute_values', models.JSONField(default=dict, help_text='e.g. {"Size": "XL", "Colour": "Red"}')),
                ('sku', models.CharField(help_text='Variant-level SKU - unique per company', max_length=100)),
                ('barcode', models.CharField(blank=True, max_length=100)),
                ('price', models.DecimalField(blank=True, decimal_places=2, help_text='Leave blank to inherit parent product price', max_digits=10, null=True)),
                ('cost_price', models.DecimalField(blank=True, decimal_places=2, help_text='Leave blank to inherit parent product cost', max_digits=10, null=True)),
                ('stock_quantity', models.IntegerField(default=0)),
                ('minimum_stock', models.PositiveIntegerField(default=5)),
                ('stock_status', models.CharField(choices=[('in_stock', 'In Stock'), ('low_stock', 'Low Stock'), ('out_of_stock', 'Out of Stock')], default='in_stock', max_length=15)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='product_variants', to='companies.company')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='inventory.product')),
            ],
            options={
                'verbose_name': 'Product Variant',
                'verbose_name_plural': 'Product Variants',
                'ordering': ['product', 'sku'],
                'unique_together': {('company', 'sku')},
            },
        ),
        migrations.CreateModel(
            name='BundleItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='inventory.product')),
                ('bundle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='inventory.productbundle')),
                ('variant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='inventory.productvariant')),
            ],
            options={
                'verbose_name': 'Bundle Item',
            },
        ),
        migrations.CreateModel(
            name='StockTransfer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('approved', 'Approved'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='draft', max_length=15)),
                ('reference', models.CharField(blank=True, max_length=60)),
                ('notes', models.TextField(blank=True)),
                ('transferred_by', models.CharField(max_length=150)),
                ('approved_by', models.CharField(blank=True, max_length=150)),
                ('completed_by', models.CharField(blank=True, max_length=150)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('approved_at', models.DateTimeField(blank=True, null=True)),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_transfers', to='companies.company')),
                ('from_branch', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='transfers_out', to='core.branch')),
                ('to_branch', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='transfers_in', to='core.branch')),
            ],
            options={
                'verbose_name': 'Stock Transfer',
                'verbose_name_plural': 'Stock Transfers',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='StockTransferItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField()),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='inventory.product')),
                ('transfer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='inventory.stocktransfer')),
                ('variant', models.ForeignKey(blank=True, help_text='Optional - only set for variant products', null=True, on_delete=django.db.models.deletion.PROTECT, to='inventory.productvariant')),
            ],
            options={
                'verbose_name': 'Stock Transfer Item',
            },
        ),
    ]
