From 1a774e3769d3328ea7037a91824cdc841fb326d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Murta?= Date: Thu, 23 Feb 2023 23:23:19 +0000 Subject: [PATCH] Adds get all transactions operation --- pfbudget/common/types.py | 1 + pfbudget/core/manager.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pfbudget/common/types.py b/pfbudget/common/types.py index 0fe3efe..d999009 100644 --- a/pfbudget/common/types.py +++ b/pfbudget/common/types.py @@ -6,6 +6,7 @@ from enum import Enum, auto class Operation(Enum): Init = auto() + Transactions = auto() Parse = auto() Download = auto() Categorize = auto() diff --git a/pfbudget/core/manager.py b/pfbudget/core/manager.py index 227a8f4..9435e90 100644 --- a/pfbudget/core/manager.py +++ b/pfbudget/core/manager.py @@ -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}