# Generated by Django 5.0 on 2025-06-09 12:38

import django.contrib.postgres.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('product', '0007_remove_attribute_reference_product_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='IncentivePlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('description', models.TextField(blank=True, null=True)),
            ],
        ),
        migrations.RemoveField(
            model_name='attributevalue',
            name='product',
        ),
        migrations.AddField(
            model_name='attribute',
            name='is_global',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='attribute',
            name='product',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attributes', to='product.product'),
        ),
        migrations.AddField(
            model_name='broker',
            name='product',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='product_broker', to='product.product'),
        ),
        migrations.AddField(
            model_name='saleunit',
            name='product',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_unit', to='product.product'),
        ),
        migrations.AlterField(
            model_name='attributevalue',
            name='attribute',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='values', to='product.attribute'),
        ),
        migrations.CreateModel(
            name='ProductCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('modify_date', models.DateTimeField(auto_now=True)),
                ('creator_info', models.CharField(max_length=100, null=True)),
                ('modifier_info', models.CharField(max_length=100, null=True)),
                ('trash', models.BooleanField(default=False)),
                ('name', models.CharField(default='empty', max_length=250)),
                ('type', models.CharField(choices=[('F', 'Free'), ('G', 'Governmental')], default='empty', max_length=3)),
                ('img', models.CharField(default='empty', max_length=100)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_createddby', to=settings.AUTH_USER_MODEL)),
                ('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_modifiedby', to=settings.AUTH_USER_MODEL)),
                ('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='parents', to='product.productcategory')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='product',
            name='category',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='products', to='product.productcategory'),
        ),
        migrations.CreateModel(
            name='Quota',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sale_type', models.CharField(choices=[('free', 'آزاد'), ('gov', 'دولتی')], max_length=50)),
                ('month_choices', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), null=True, size=None)),
                ('group', models.CharField(choices=[('roostaei', 'روستایی'), ('sanati', 'صنعتی'), ('ashayeri', 'عشایری')], max_length=50)),
                ('has_distribution_limit', models.BooleanField(default=False)),
                ('distribution_mode', models.CharField(blank=True, max_length=50, null=True)),
                ('base_price_factory', models.DecimalField(decimal_places=2, max_digits=12)),
                ('base_price_cooperative', models.DecimalField(decimal_places=2, max_digits=12)),
                ('final_price', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quota', to='product.product')),
            ],
        ),
        migrations.AddField(
            model_name='attributevalue',
            name='quota',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attribute_values', to='product.quota'),
        ),
        migrations.CreateModel(
            name='QuotaBrokerValue',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.DecimalField(decimal_places=2, max_digits=12)),
                ('broker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='values', to='product.broker')),
                ('quota', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='broker_values', to='product.quota')),
            ],
        ),
        migrations.CreateModel(
            name='QuotaIncentiveAssignment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('heavy_value', models.DecimalField(decimal_places=2, max_digits=12)),
                ('light_value', models.DecimalField(decimal_places=2, max_digits=12)),
                ('incentive_plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quota_assignment', to='product.incentiveplan')),
                ('quota', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='incentive_assignments', to='product.quota')),
            ],
        ),
        migrations.CreateModel(
            name='QuotaLivestockAllocation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('livestock_group', models.CharField(choices=[('roostaei', 'روستایی'), ('sanati', 'صنعتی'), ('ashayeri', 'عشایری')], max_length=20)),
                ('livestock_type', models.CharField(choices=[('light', 'سبک'), ('heavy', 'سنگین')], max_length=20)),
                ('livestock_subtype', models.CharField(choices=[('milking', 'شیری'), ('fattening', 'پرواری')], max_length=20)),
                ('quantity_kg', models.DecimalField(decimal_places=2, max_digits=12)),
                ('quota', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='livestock_allocations', to='product.quota')),
            ],
            options={
                'unique_together': {('quota', 'livestock_group', 'livestock_type', 'livestock_subtype')},
            },
        ),
    ]
