# 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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Address',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('street_address', models.CharField(max_length=100)),
                ('apartment_address', models.CharField(max_length=100)),
                ('zip', models.CharField(max_length=100)),
                ('default', models.BooleanField(default=False)),
                ('active', models.BooleanField(default=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': ' Addresses',
            },
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('ordered_at', models.DateTimeField(blank=True, null=True)),
                ('customer_name', models.CharField(blank=True, max_length=100, null=True)),
                ('customer_phone', models.CharField(blank=True, max_length=10)),
                ('store_cancelled_reason', models.CharField(blank=True, max_length=200)),
                ('order_status', models.CharField(choices=[('STORE_PICKUP', 'Store Pickup'), ('STORE_CANCELLED', 'Store Cancelled'), ('ORDERED', 'Ordered'), ('CANCELLED', 'Cancelled'), ('OUT_FOR_DELIVERY', 'Out for delivery'), ('DELIVERED', 'Delivered'), ('DECLINED', 'Declined'), ('RETURNED', 'Returned'), ('REFUND_REQUESTED', 'Refund Requested'), ('REFUND_DECLINED', 'Refund Declined'), ('REFUND_GRANTED', 'Refund Granted')], default='STORE_PICKUP', max_length=50)),
                ('refund_reason', models.CharField(blank=True, max_length=200)),
                ('mode_of_payment', models.CharField(choices=[('CASH', 'Cash'), ('UPI', 'UPI'), ('CARD', 'Card'), ('COD', 'COD')], default='CASH', max_length=50, verbose_name='Payment')),
                ('total', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
                ('biller', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='biller', to=settings.AUTH_USER_MODEL)),
                ('ordered_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='ordered_by', to=settings.AUTH_USER_MODEL)),
                ('shipping_address', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='sales.address')),
            ],
            options={
                'verbose_name_plural': ' Orders',
            },
        ),
        migrations.CreateModel(
            name='OrderItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=8)),
                ('item_rate', models.DecimalField(decimal_places=2, max_digits=8)),
                ('discounted_rate', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
                ('instructions', models.CharField(blank=True, max_length=100)),
                ('extra_info', models.CharField(blank=True, max_length=100)),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='order_item', to='items.item')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='sales.order')),
            ],
            options={
                'verbose_name_plural': 'Order Items',
            },
        ),
        migrations.CreateModel(
            name='HistoricalOrderItem',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=8)),
                ('item_rate', models.DecimalField(decimal_places=2, max_digits=8)),
                ('discounted_rate', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
                ('instructions', models.CharField(blank=True, max_length=100)),
                ('extra_info', models.CharField(blank=True, max_length=100)),
                ('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)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('item', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='items.item')),
                ('order', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='sales.order')),
            ],
            options={
                'verbose_name': 'historical order item',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalOrder',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('created_at', models.DateTimeField(blank=True, editable=False)),
                ('ordered_at', models.DateTimeField(blank=True, null=True)),
                ('customer_name', models.CharField(blank=True, max_length=100, null=True)),
                ('customer_phone', models.CharField(blank=True, max_length=10)),
                ('store_cancelled_reason', models.CharField(blank=True, max_length=200)),
                ('order_status', models.CharField(choices=[('STORE_PICKUP', 'Store Pickup'), ('STORE_CANCELLED', 'Store Cancelled'), ('ORDERED', 'Ordered'), ('CANCELLED', 'Cancelled'), ('OUT_FOR_DELIVERY', 'Out for delivery'), ('DELIVERED', 'Delivered'), ('DECLINED', 'Declined'), ('RETURNED', 'Returned'), ('REFUND_REQUESTED', 'Refund Requested'), ('REFUND_DECLINED', 'Refund Declined'), ('REFUND_GRANTED', 'Refund Granted')], default='STORE_PICKUP', max_length=50)),
                ('refund_reason', models.CharField(blank=True, max_length=200)),
                ('mode_of_payment', models.CharField(choices=[('CASH', 'Cash'), ('UPI', 'UPI'), ('CARD', 'Card'), ('COD', 'COD')], default='CASH', max_length=50, verbose_name='Payment')),
                ('total', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
                ('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)),
                ('biller', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('ordered_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)),
                ('shipping_address', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='sales.address')),
            ],
            options={
                'verbose_name': 'historical order',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalAddress',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('street_address', models.CharField(max_length=100)),
                ('apartment_address', models.CharField(max_length=100)),
                ('zip', models.CharField(max_length=100)),
                ('default', models.BooleanField(default=False)),
                ('active', models.BooleanField(default=True)),
                ('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)),
                ('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)),
            ],
            options={
                'verbose_name': 'historical address',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
