from django.db import migrations

TEMPLATE_DATA = {
    'name': 'Accounting Ledger',
    'category': 'accounting',
    'price': 0,
    'usage_limit': None,
    'min_tier_required': 'free',
    'layout': {'style': 'classic', 'primary_color': '#14532d', 'accent_color': '#b7912f', 'font': 'serif'},
}


def seed_accounting_ledger(apps, schema_editor):
    InvoiceTemplate = apps.get_model('templates', 'InvoiceTemplate')
    InvoiceTemplate.objects.get_or_create(name=TEMPLATE_DATA['name'], defaults=TEMPLATE_DATA)


def unseed_accounting_ledger(apps, schema_editor):
    InvoiceTemplate = apps.get_model('templates', 'InvoiceTemplate')
    InvoiceTemplate.objects.filter(name=TEMPLATE_DATA['name']).delete()


class Migration(migrations.Migration):
    dependencies = [
        ('templates', '0005_alter_invoicetemplate_category'),
    ]

    operations = [
        migrations.RunPython(seed_accounting_ledger, unseed_accounting_ledger),
    ]
