from __future__ import annotations

import enum

from quartermaster.models import Section


class Group(str, enum.Enum):
    income = "income"
    committed = "committed"
    savings = "savings"
    flexible = "flexible"


GROUP_LABELS: dict[Group, str] = {
    Group.income: "Income",
    Group.committed: "Committed",
    Group.savings: "Savings",
    Group.flexible: "Flexible",
}


GROUP_OF_SECTION: dict[Section, Group] = {
    Section.income: Group.income,
    Section.fixed_bill: Group.committed,
    Section.debt_minimum: Group.committed,
    Section.sinking_fund: Group.savings,
    Section.food: Group.flexible,
    Section.subscription: Group.flexible,
    Section.other: Group.flexible,
}


GROUP_DEFAULT_OPEN: dict[Group, bool] = {
    Group.income: True,
    Group.committed: False,
    Group.savings: False,
    Group.flexible: True,
}


def sections_in_group(group: Group) -> list[Section]:
    return [s for s in Section if GROUP_OF_SECTION[s] == group]


def group_order() -> list[Group]:
    return [Group.income, Group.committed, Group.savings, Group.flexible]
