# Generated by Django 6.0.4 on 2026-06-11 06:14

import apps.finance.models
from django.db import migrations, models


def seed_currencies(apps, schema_editor):
    Currency = apps.get_model("finance", "Currency")
    defaults = [
        {"code": "IDR", "abbreviation": "Rp", "name": "Indonesian Rupiah"},
        {"code": "USD", "abbreviation": "$USD", "name": "US Dollar"},
    ]
    for d in defaults:
        Currency.objects.get_or_create(code=d["code"], defaults=d)


def unseed_currencies(apps, schema_editor):
    Currency = apps.get_model("finance", "Currency")
    Currency.objects.filter(code__in=["IDR", "USD"]).delete()


class Migration(migrations.Migration):

    dependencies = [
        ('finance', '0002_budgetitem_parent_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='Currency',
            fields=[
                ('id', models.UUIDField(default=apps.finance.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(help_text='ISO-ish code, e.g. USD, IDR.', max_length=10, unique=True)),
                ('abbreviation', models.CharField(help_text='Display abbreviation, e.g. $USD, Rp.', max_length=10)),
                ('name', models.CharField(blank=True, max_length=100)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name_plural': 'currencies',
                'db_table': 'currencies',
                'ordering': ['code'],
            },
        ),
        migrations.RunPython(seed_currencies, unseed_currencies),
    ]
