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:
Luís Murta 2021-07-04 00:36:27 +01:00
parent 9ba7f87a37
commit dc6d1d0b02
Signed by: satprog
GPG Key ID: DDF2EFC6179009DC
2 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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()