# Generated by Django 5.1.4 on 2024-12-09 13:58

import django.db.models.deletion
import inventory.mixins
import phonenumber_field.modelfields
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Car',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('vin', models.CharField(max_length=17, unique=True, verbose_name='VIN')),
                ('year', models.IntegerField(verbose_name='Year')),
                ('status', models.CharField(choices=[('available', 'Available'), ('sold', 'Sold'), ('hold', 'Hold'), ('damaged', 'Damaged')], default='available', max_length=10, verbose_name='Status')),
                ('stock_type', models.CharField(choices=[('new', 'New'), ('used', 'Used')], default='new', max_length=10, verbose_name='Stock Type')),
                ('remarks', models.TextField(blank=True, null=True, verbose_name='Remarks')),
                ('mileage', models.IntegerField(blank=True, null=True, verbose_name='Mileage')),
                ('receiving_date', models.DateTimeField(verbose_name='Receiving Date')),
            ],
            options={
                'verbose_name': 'Car',
                'verbose_name_plural': 'Cars',
            },
        ),
        migrations.CreateModel(
            name='CarMake',
            fields=[
                ('id_car_make', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('arabic_name', models.CharField(max_length=255)),
                ('logo', models.ImageField(blank=True, null=True, upload_to='car_make', verbose_name='logo')),
                ('is_sa_import', models.BooleanField(default=False)),
            ],
            options={
                'verbose_name': 'Make',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='ExteriorColors',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Name')),
                ('arabic_name', models.CharField(max_length=255, verbose_name='Arabic Name')),
                ('rgb', models.CharField(blank=True, max_length=24, null=True, verbose_name='RGB')),
            ],
            options={
                'verbose_name': 'Exterior Colors',
                'verbose_name_plural': 'Exterior Colors',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='InteriorColors',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Name')),
                ('arabic_name', models.CharField(max_length=255, verbose_name='Arabic Name')),
                ('rgb', models.CharField(blank=True, max_length=24, null=True, verbose_name='RGB')),
            ],
            options={
                'verbose_name': 'Interior Colors',
                'verbose_name_plural': 'Interior Colors',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='CarFinance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cost_price', models.DecimalField(decimal_places=2, max_digits=14, verbose_name='Cost Price')),
                ('selling_price', models.DecimalField(decimal_places=2, max_digits=14, verbose_name='Selling Price')),
                ('profit_margin', models.DecimalField(decimal_places=2, editable=False, max_digits=14, verbose_name='Profit Margin')),
                ('discount_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14, verbose_name='Discount Amount')),
                ('registration_fee', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14, verbose_name='Registration Fee')),
                ('administration_fee', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14, verbose_name='Administration Fee')),
                ('transportation_fee', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14, verbose_name='Transportation Fee')),
                ('custom_card_fee', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14, verbose_name='Custom Card Fee')),
                ('vat_rate', models.DecimalField(decimal_places=2, default=Decimal('0.15'), max_digits=14, verbose_name='VAT Rate')),
                ('administration_vat_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=12, verbose_name='Administration VAT')),
                ('transportation_vat_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=12, verbose_name='Transportation VAT')),
                ('custom_card_vat_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=12, verbose_name='Custom Card VAT')),
                ('selling_vat_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=12, verbose_name='Selling VAT')),
                ('total_vat_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=12, verbose_name='Total VAT')),
                ('total_before_vat', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=14, verbose_name='Total Before VAT')),
                ('total', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=14, verbose_name='Total Amount')),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='finances', to='inventory.car')),
            ],
        ),
        migrations.AddField(
            model_name='car',
            name='id_car_make',
            field=models.ForeignKey(blank=True, db_column='id_car_make', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carmake', verbose_name='Make'),
        ),
        migrations.CreateModel(
            name='CarModel',
            fields=[
                ('id_car_model', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('arabic_name', models.CharField(max_length=255)),
                ('id_car_make', models.ForeignKey(db_column='id_car_make', on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carmake')),
            ],
            options={
                'verbose_name': 'Model',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.AddField(
            model_name='car',
            name='id_car_model',
            field=models.ForeignKey(blank=True, db_column='id_car_model', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carmodel', verbose_name='Model'),
        ),
        migrations.CreateModel(
            name='CarRegistration',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plate_number', models.IntegerField(verbose_name='Plate Number')),
                ('text1', models.CharField(max_length=1, verbose_name='Text 1')),
                ('text2', models.CharField(max_length=1, verbose_name='Text 2')),
                ('text3', models.CharField(max_length=1, verbose_name='Text 3')),
                ('registration_date', models.DateTimeField(verbose_name='Registration Date')),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='registrations', to='inventory.car', verbose_name='Car')),
            ],
            options={
                'verbose_name': 'Registration',
                'verbose_name_plural': 'Registrations',
            },
        ),
        migrations.CreateModel(
            name='CarSerie',
            fields=[
                ('id_car_serie', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('arabic_name', models.CharField(max_length=255)),
                ('id_car_model', models.ForeignKey(db_column='id_car_model', on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carmodel')),
            ],
            options={
                'verbose_name': 'Series',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.AddField(
            model_name='car',
            name='id_car_serie',
            field=models.ForeignKey(blank=True, db_column='id_car_serie', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carserie', verbose_name='Series'),
        ),
        migrations.CreateModel(
            name='CarSpecification',
            fields=[
                ('id_car_specification', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('arabic_name', models.CharField(max_length=255)),
                ('id_parent', models.ForeignKey(blank=True, db_column='id_parent', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carspecification')),
            ],
            options={
                'verbose_name': 'Specification',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='CarTrim',
            fields=[
                ('id_car_trim', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('arabic_name', models.CharField(max_length=255)),
                ('start_production_year', models.IntegerField(blank=True, null=True)),
                ('end_production_year', models.IntegerField(blank=True, null=True)),
                ('id_car_serie', models.ForeignKey(db_column='id_car_serie', on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carserie')),
            ],
            options={
                'verbose_name': 'Trim',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='CarSpecificationValue',
            fields=[
                ('id_car_specification_value', models.AutoField(primary_key=True, serialize=False)),
                ('value', models.CharField(max_length=500)),
                ('unit', models.CharField(blank=True, max_length=255, null=True)),
                ('id_car_specification', models.ForeignKey(db_column='id_car_specification', on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.carspecification')),
                ('id_car_trim', models.ForeignKey(db_column='id_car_trim', on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.cartrim')),
            ],
            options={
                'verbose_name': 'Specification Value',
            },
        ),
        migrations.AddField(
            model_name='car',
            name='id_car_trim',
            field=models.ForeignKey(blank=True, db_column='id_car_trim', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='inventory.cartrim', verbose_name='Trim'),
        ),
        migrations.CreateModel(
            name='CustomCard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('custom_number', models.CharField(max_length=255, verbose_name='Custom Number')),
                ('custom_date', models.DateField(verbose_name='Custom Date')),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='custom_cards', to='inventory.car', verbose_name='Car')),
            ],
            options={
                'verbose_name': 'Custom Card',
                'verbose_name_plural': 'Custom Cards',
            },
        ),
        migrations.CreateModel(
            name='Dealer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('crn', models.CharField(max_length=10, verbose_name='Commercial Registration Number')),
                ('vrn', models.CharField(max_length=15, verbose_name='VAT Registration Number')),
                ('arabic_name', models.CharField(max_length=255, verbose_name='Arabic Name')),
                ('name', models.CharField(max_length=255, verbose_name='English Name')),
                ('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region='SA', verbose_name='Phone Number')),
                ('address', models.CharField(blank=True, max_length=200, null=True, verbose_name='Address')),
                ('logo', models.ImageField(blank=True, null=True, upload_to='logos/users', verbose_name='Logo')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='dealer', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Dealer',
                'verbose_name_plural': 'Dealers',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(max_length=50, verbose_name='First Name')),
                ('middle_name', models.CharField(blank=True, max_length=50, null=True, verbose_name='Middle Name')),
                ('last_name', models.CharField(max_length=50, verbose_name='Last Name')),
                ('email', models.EmailField(max_length=254, unique=True, verbose_name='Email')),
                ('national_id', models.CharField(max_length=10, unique=True, verbose_name='National ID')),
                ('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region='SA', unique=True, verbose_name='Phone Number')),
                ('address', models.CharField(blank=True, max_length=200, null=True, verbose_name='Address')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='Created')),
                ('dealer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='customers', to='inventory.dealer')),
            ],
            options={
                'verbose_name': 'Customer',
                'verbose_name_plural': 'Customers',
            },
        ),
        migrations.AddField(
            model_name='car',
            name='dealer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='cars', to='inventory.dealer', verbose_name='Dealer'),
        ),
        migrations.CreateModel(
            name='SaleQuotation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('remarks', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.customer')),
            ],
        ),
        migrations.CreateModel(
            name='SaleQuotationCar',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.car')),
                ('financial_details', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quotation_finances', to='inventory.carfinance')),
                ('quotation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quotation_cars', to='inventory.salequotation')),
            ],
        ),
        migrations.CreateModel(
            name='Vendor',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('crn', models.CharField(max_length=10, unique=True, verbose_name='Commercial Registration Number')),
                ('vrn', models.CharField(max_length=15, unique=True, verbose_name='VAT Registration Number')),
                ('arabic_name', models.CharField(max_length=255, verbose_name='Arabic Name')),
                ('name', models.CharField(max_length=255, verbose_name='English Name')),
                ('contact_person', models.CharField(max_length=100, verbose_name='Contact Person')),
                ('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region='SA', verbose_name='Phone Number')),
                ('address', models.CharField(blank=True, max_length=200, null=True, verbose_name='Address')),
                ('logo', models.ImageField(blank=True, null=True, upload_to='logos/vendors', verbose_name='Logo')),
                ('dealer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vendors', to='inventory.dealer')),
            ],
            options={
                'verbose_name': 'Vendor',
                'verbose_name_plural': 'Vendors',
            },
            bases=(models.Model, inventory.mixins.LocalizedNameMixin),
        ),
        migrations.AddField(
            model_name='car',
            name='vendor',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='cars', to='inventory.vendor', verbose_name='Vendor'),
        ),
        migrations.CreateModel(
            name='CarReservation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('reserved_at', models.DateTimeField(auto_now_add=True)),
                ('reserved_until', models.DateTimeField()),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='inventory.car')),
                ('reserved_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-reserved_at'],
                'unique_together': {('car', 'reserved_until')},
            },
        ),
        migrations.CreateModel(
            name='CarColors',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('car', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='colors', to='inventory.car')),
                ('exterior', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='colors', to='inventory.exteriorcolors')),
                ('interior', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='colors', to='inventory.interiorcolors')),
            ],
            options={
                'verbose_name': 'Color',
                'verbose_name_plural': 'Colors',
                'unique_together': {('car', 'exterior', 'interior')},
            },
        ),
    ]
