# Generated by Django 4.2.29 on 2026-03-24 10:18

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qb_id', models.CharField(max_length=100, unique=True)),
                ('name', models.CharField(max_length=255)),
                ('account_type', models.CharField(blank=True, max_length=100)),
                ('account_sub_type', models.CharField(blank=True, max_length=100)),
                ('current_balance', models.DecimalField(decimal_places=2, default=0, max_digits=14)),
                ('active', models.BooleanField(default=True)),
                ('synced_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qb_id', models.CharField(max_length=100, unique=True)),
                ('display_name', models.CharField(max_length=255)),
                ('email', models.EmailField(blank=True, max_length=254)),
                ('phone', models.CharField(blank=True, max_length=50)),
                ('balance', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('active', models.BooleanField(default=True)),
                ('synced_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='QuickBooksToken',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('realm_id', models.CharField(max_length=255)),
                ('access_token', models.TextField()),
                ('refresh_token', models.TextField()),
                ('access_token_expires_at', models.DateTimeField(blank=True, null=True)),
                ('refresh_token_expires_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='qb_token', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qb_id', models.CharField(max_length=100, unique=True)),
                ('doc_number', models.CharField(blank=True, max_length=100)),
                ('customer_name', models.CharField(blank=True, max_length=255)),
                ('txn_date', models.DateField(blank=True, null=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('total_amt', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('balance', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('status', models.CharField(choices=[('Draft', 'Draft'), ('Pending', 'Pending'), ('Overdue', 'Overdue'), ('Paid', 'Paid'), ('Voided', 'Voided')], default='Draft', max_length=20)),
                ('synced_at', models.DateTimeField(auto_now=True)),
                ('customer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoices', to='quickbooks_app.customer')),
            ],
        ),
    ]
