# Generated by Django 4.2.27 on 2026-01-12 20:40

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('account_code', models.CharField(max_length=20)),
                ('account_name', models.CharField(max_length=200)),
                ('account_type', models.CharField(choices=[('ASSET', 'Asset'), ('LIABILITY', 'Liability'), ('EQUITY', 'Equity'), ('REVENUE', 'Revenue'), ('EXPENSE', 'Expense'), ('COGS', 'Cost of Goods Sold')], max_length=20)),
                ('description', models.TextField(blank=True)),
                ('is_active', models.BooleanField(default=True)),
                ('balance', models.DecimalField(decimal_places=2, default=0, max_digits=15)),
                ('quickbooks_id', models.CharField(blank=True, max_length=100, null=True)),
                ('quickbooks_sync_token', models.CharField(blank=True, max_length=50, null=True)),
                ('last_synced_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['account_code'],
            },
        ),
        migrations.CreateModel(
            name='CommissionStructure',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('commission_type', models.CharField(choices=[('PERCENTAGE', 'Percentage of Sale'), ('FIXED', 'Fixed Amount'), ('TIERED', 'Tiered Structure')], max_length=20)),
                ('percentage', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True)),
                ('fixed_amount', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('tier_rules', models.JSONField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('applies_to_categories', models.JSONField(blank=True, default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='CreditPayment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('payment_date', models.DateField()),
                ('payment_method', models.CharField(max_length=50)),
                ('reference_number', models.CharField(blank=True, max_length=100)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'ordering': ['-payment_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='JournalDetail',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=500)),
                ('debit_amount', models.DecimalField(decimal_places=2, default=0, max_digits=15, validators=[django.core.validators.MinValueValidator(0)])),
                ('credit_amount', models.DecimalField(decimal_places=2, default=0, max_digits=15, validators=[django.core.validators.MinValueValidator(0)])),
            ],
            options={
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='JournalEntry',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('entry_number', models.CharField(max_length=50)),
                ('entry_date', models.DateField()),
                ('description', models.TextField()),
                ('reference_number', models.CharField(blank=True, max_length=100)),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('POSTED', 'Posted'), ('VOIDED', 'Voided')], default='DRAFT', max_length=10)),
                ('object_id', models.PositiveIntegerField(blank=True, null=True)),
                ('quickbooks_id', models.CharField(blank=True, max_length=100, null=True)),
                ('quickbooks_sync_token', models.CharField(blank=True, max_length=50, null=True)),
                ('last_synced_at', models.DateTimeField(blank=True, null=True)),
                ('sync_status', models.CharField(default='PENDING', max_length=20)),
                ('sync_error', models.TextField(blank=True)),
                ('posted_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name_plural': 'Journal Entries',
                'ordering': ['-entry_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='QuickBooksConnection',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('realm_id', models.CharField(max_length=100)),
                ('access_token', models.TextField()),
                ('refresh_token', models.TextField()),
                ('token_expires_at', models.DateTimeField()),
                ('is_active', models.BooleanField(default=True)),
                ('connected_at', models.DateTimeField(auto_now_add=True)),
                ('last_sync_at', models.DateTimeField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Transaction',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(blank=True, null=True)),
                ('transaction_type', models.CharField(choices=[('SALE', 'Sale'), ('PURCHASE', 'Purchase'), ('PAYMENT', 'Payment'), ('CREDIT_PAYMENT', 'Credit Payment'), ('COMMISSION', 'Commission'), ('EXPENSE', 'Expense'), ('ADJUSTMENT', 'Adjustment'), ('TRANSFER', 'Transfer'), ('RETURN', 'Return')], max_length=20)),
                ('transaction_date', models.DateTimeField(db_index=True)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('description', models.TextField()),
                ('reference', models.CharField(blank=True, max_length=100)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('COMPLETED', 'Completed'), ('RECONCILED', 'Reconciled'), ('VOID', 'Void')], default='PENDING', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['-transaction_date', '-created_at'],
            },
        ),
    ]
