# Generated by Django 5.0.8 on 2024-09-25 09:37

from django.db import migrations, models
from wbcore.contrib.currency.models import Currency
from wbfdm.models import Instrument, InstrumentType


def create_cash_equivalents(apps, schema_editor):
    for currency in Currency.objects.all():
        Instrument.objects.create(
            name=f"Cash Equivalent {currency.key}",
            instrument_type=InstrumentType.CASHEQUIVALENT,
            currency=currency,
            is_cash_equivalent=True,
        )


class Migration(migrations.Migration):
    dependencies = [
        ("wbfdm", "0025_instrument_is_primary_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="instrument",
            name="is_cash_equivalent",
            field=models.BooleanField(default=False),
        ),
        migrations.RunPython(create_cash_equivalents),
    ]
