Section groups with collapsible headers + Sinking Funds #12
2 changed files with 49 additions and 0 deletions
47
src/quartermaster/groups.py
Normal file
47
src/quartermaster/groups.py
Normal file
|
|
@ -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]
|
||||
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue