feat(groups): add sinking_fund section and define four-group layout
Section enum gains sinking_fund with label "Sinking Funds". A new groups module maps each section to one of Income, Committed, Savings, Flexible and records the default open state per group. The existing section column is a plain VARCHAR(32) with no CHECK, so no schema migration is needed to accept the new value. Refs #11 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
496f44cf8c
commit
032c35c75e
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