diff --git a/src/quartermaster/groups.py b/src/quartermaster/groups.py new file mode 100644 index 0000000..650d4ab --- /dev/null +++ b/src/quartermaster/groups.py @@ -0,0 +1,47 @@ +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] diff --git a/src/quartermaster/models.py b/src/quartermaster/models.py index 8fb87c1..ee81008 100644 --- a/src/quartermaster/models.py +++ b/src/quartermaster/models.py @@ -24,6 +24,7 @@ class Section(str, enum.Enum): food = "food" subscription = "subscription" other = "other" + sinking_fund = "sinking_fund" SECTION_LABELS: dict[Section, str] = { @@ -33,6 +34,7 @@ SECTION_LABELS: dict[Section, str] = { Section.food: "Food and Essentials", Section.subscription: "Subscriptions", Section.other: "Other", + Section.sinking_fund: "Sinking Funds", }