Adds get all transactions operation

This commit is contained in:
Luís Murta 2023-02-23 23:23:19 +00:00
parent dd724b6c28
commit 1a774e3769
Signed by: satprog
GPG Key ID: 169EF1BBD7049F94
2 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ from enum import Enum, auto
class Operation(Enum):
Init = auto()
Transactions = auto()
Parse = auto()
Download = auto()
Categorize = auto()

View File

@ -34,14 +34,23 @@ class Manager:
self._db = db
self._verbosity = verbosity
def action(self, op: Operation, params: list):
def action(self, op: Operation, params=None):
if self._verbosity > 0:
print(f"op={op}, params={params}")
if params is None:
params = []
match (op):
case Operation.Init:
pass
case Operation.Transactions:
with self.db.session() as session:
transactions = session.get(Transaction)
ret = [t.format for t in transactions]
return ret
case Operation.Parse:
# Adapter for the parse_data method. Can be refactored.
args = {"bank": params[1], "creditcard": params[2], "category": None}