Add groups to categories in YAML
Groups will later be used to aggregate categories into related groups to present graphs and reports by type of categories.
This commit is contained in:
parent
9ba7f87a37
commit
dc6d1d0b02
@ -1,24 +1,29 @@
|
||||
Income1:
|
||||
group: income
|
||||
regex:
|
||||
- company A
|
||||
|
||||
Income2:
|
||||
group: income
|
||||
regex:
|
||||
- transfer
|
||||
banks:
|
||||
- BankA
|
||||
|
||||
Income3:
|
||||
group: income
|
||||
regex:
|
||||
- company B
|
||||
|
||||
Commute:
|
||||
group: required
|
||||
regex:
|
||||
- uber
|
||||
regular:
|
||||
- [train, 50]
|
||||
|
||||
Utilities:
|
||||
group: fixed
|
||||
regex:
|
||||
- electricity
|
||||
regular:
|
||||
@ -26,24 +31,29 @@ Utilities:
|
||||
- [internet, 30.5]
|
||||
|
||||
Groceries:
|
||||
group: required
|
||||
regex:
|
||||
- lidl
|
||||
- e.leclerc
|
||||
- aldi
|
||||
|
||||
Eating Out:
|
||||
group: discretionary
|
||||
regex:
|
||||
- restaurant 1
|
||||
- restaurant 2
|
||||
|
||||
Entertainment:
|
||||
group: discretionary
|
||||
regex:
|
||||
- cinema
|
||||
- steam
|
||||
|
||||
Pets:
|
||||
group: required
|
||||
|
||||
Medical:
|
||||
group: health
|
||||
regex:
|
||||
- hospital
|
||||
- pharmacy
|
||||
@ -51,6 +61,7 @@ Medical:
|
||||
Miscellaneous:
|
||||
|
||||
Travel:
|
||||
group: discretionary
|
||||
regex:
|
||||
- ryanair
|
||||
- easyjet
|
||||
|
||||
@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
||||
Options = namedtuple(
|
||||
"Options",
|
||||
[
|
||||
"group",
|
||||
"regex",
|
||||
"banks",
|
||||
"regular",
|
||||
@ -23,11 +24,17 @@ Options = namedtuple(
|
||||
"vacations",
|
||||
"timedelta",
|
||||
],
|
||||
defaults=[[], [], [], [], "", [], 4],
|
||||
defaults=["", [], [], [], [], "", [], 4],
|
||||
)
|
||||
|
||||
cfg = yaml.safe_load(open("categories.yaml"))
|
||||
categories = {k: Options(**v) if v else Options() for k, v in cfg.items()}
|
||||
groups = {
|
||||
group: [
|
||||
category for category, options in categories.items() if options.group == group
|
||||
]
|
||||
for group in set(category.group for category in categories.values())
|
||||
}
|
||||
categories["Null"] = Options()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user