[Interactive] Adds new tag
This commit is contained in:
parent
fd24ac3318
commit
13709b7a04
@ -7,9 +7,12 @@ from pfbudget.utils.utils import parse_args_period
|
|||||||
|
|
||||||
def interactive(manager: Manager):
|
def interactive(manager: Manager):
|
||||||
with manager.db.session() as session:
|
with manager.db.session() as session:
|
||||||
|
|
||||||
categories = session.get(type.Category)
|
categories = session.get(type.Category)
|
||||||
print(f"Available categories: {categories}")
|
print(f"Available categories: {[c.name for c in categories]}")
|
||||||
print(f"Available tags: {session.get(type.Tag)}")
|
tags = session.get(type.Tag)
|
||||||
|
print(f"Available tags: {[t.name for t in tags]}")
|
||||||
|
|
||||||
transactions = session.get(type.Transaction, ~type.Transaction.category.has())
|
transactions = session.get(type.Transaction, ~type.Transaction.category.has())
|
||||||
print(f"{len(transactions)} transactions left to categorize")
|
print(f"{len(transactions)} transactions left to categorize")
|
||||||
|
|
||||||
@ -25,6 +28,9 @@ def interactive(manager: Manager):
|
|||||||
|
|
||||||
case "tag":
|
case "tag":
|
||||||
tag = input("tag: ")
|
tag = input("tag: ")
|
||||||
|
if tag not in [t.name for t in tags]:
|
||||||
|
session.add([type.Tag(tag)])
|
||||||
|
|
||||||
transaction.tags.add(type.TransactionTag(tag))
|
transaction.tags.add(type.TransactionTag(tag))
|
||||||
|
|
||||||
case "note":
|
case "note":
|
||||||
|
|||||||
@ -116,7 +116,14 @@ class Manager:
|
|||||||
banks = NordigenInput().country_banks(params[0])
|
banks = NordigenInput().country_banks(params[0])
|
||||||
print(banks)
|
print(banks)
|
||||||
|
|
||||||
case Operation.BankAdd | Operation.CategoryAdd | Operation.NordigenAdd | Operation.RuleAdd | Operation.TagAdd | Operation.TagRuleAdd:
|
case (
|
||||||
|
Operation.BankAdd
|
||||||
|
| Operation.CategoryAdd
|
||||||
|
| Operation.NordigenAdd
|
||||||
|
| Operation.RuleAdd
|
||||||
|
| Operation.TagAdd
|
||||||
|
| Operation.TagRuleAdd
|
||||||
|
):
|
||||||
with self.db.session() as session:
|
with self.db.session() as session:
|
||||||
session.add(params)
|
session.add(params)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user