# Generated by Django 3.1.2 on 2020-10-31 12:37

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('category', models.CharField(max_length=50)),
            ],
            options={
                'verbose_name_plural': 'Categories',
            },
        ),
        migrations.CreateModel(
            name='Item',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('item_name', models.CharField(max_length=50)),
                ('image', models.ImageField(blank=True, upload_to='image/')),
                ('available_quantity', models.DecimalField(decimal_places=2, max_digits=8)),
                ('rate', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='Sales Rate')),
                ('purchase_price_multiplier', models.DecimalField(decimal_places=2, default=1.3, max_digits=4)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='items.category')),
                ('item_unit', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='item_unit', to='units.unit')),
            ],
            options={
                'verbose_name_plural': ' Items (Sales)',
            },
        ),
        migrations.CreateModel(
            name='Tag',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tag_name', models.CharField(max_length=50)),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='items.item')),
            ],
        ),
        migrations.CreateModel(
            name='SubCategory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('subcategory', models.CharField(max_length=50)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='items.category')),
            ],
        ),
        migrations.AddField(
            model_name='item',
            name='subcategory',
            field=smart_selects.db_fields.ChainedForeignKey(auto_choose=True, chained_field='category', chained_model_field='category', on_delete=django.db.models.deletion.PROTECT, to='items.subcategory'),
        ),
        migrations.CreateModel(
            name='HistoricalItem',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('item_name', models.CharField(max_length=50)),
                ('image', models.TextField(blank=True, max_length=100)),
                ('available_quantity', models.DecimalField(decimal_places=2, max_digits=8)),
                ('rate', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='Sales Rate')),
                ('purchase_price_multiplier', models.DecimalField(decimal_places=2, default=1.3, max_digits=4)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('category', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='items.category')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('item_unit', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='units.unit')),
                ('subcategory', smart_selects.db_fields.ChainedForeignKey(auto_choose=True, blank=True, chained_field='category', chained_model_field='category', db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='items.subcategory')),
            ],
            options={
                'verbose_name': 'historical item',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
