"""Default chart of accounts (V2 §7.1). Seeded after migrate; idempotent."""

from .models import LedgerAccount


CHART_OF_ACCOUNTS = [
    ("1000", "AzamPay settlement / custody asset", LedgerAccount.Type.ASSET),
    ("2000", "Customer escrow liability", LedgerAccount.Type.LIABILITY),
    ("2100", "Seller payable", LedgerAccount.Type.LIABILITY),
    ("2200", "VAT / tax payable", LedgerAccount.Type.LIABILITY),
    ("4000", "Platform fee revenue", LedgerAccount.Type.REVENUE),
]


def seed_chart_of_accounts() -> list[str]:
    created = []
    for code, name, acct_type in CHART_OF_ACCOUNTS:
        _, was_created = LedgerAccount.objects.get_or_create(
            code=code, defaults={"name": name, "type": acct_type}
        )
        if was_created:
            created.append(code)
    return created
