From a1f5699b12c76db028e592cfef994105cb195082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Murta?= Date: Wed, 1 Dec 2021 18:31:25 +0000 Subject: [PATCH] Add original and additional comment columns do DB To have cleared information on manually added transactions to the database, this patch adds the original column so those added after the parsing can be marked as such. Also adds a column to add comments to transaction, when they are not explicit from the transaction message. --- pfbudget/database.py | 14 ++++++++------ pfbudget/transactions.py | 4 ++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pfbudget/database.py b/pfbudget/database.py index 7a3bdc5..2d5705b 100644 --- a/pfbudget/database.py +++ b/pfbudget/database.py @@ -20,12 +20,14 @@ sqlite3.register_adapter(Decimal, lambda d: float(d)) __DB_NAME = "data.db" CREATE_TRANSACTIONS_TABLE = """ -CREATE TABLE IF NOT EXISTS transactions ( - date TEXT NOT NULL, - description TEXT, - bank TEXT, - value REAL NOT NULL, - category TEXT +CREATE TABLE IF NOT EXISTS "transactions" ( + "date" TEXT NOT NULL, + "description" TEXT, + "bank" TEXT NOT NULL, + "value" REAL NOT NULL, + "category" TEXT, + "original" TEXT, + "additional comments" TEXT ); """ diff --git a/pfbudget/transactions.py b/pfbudget/transactions.py index f8ed94b..406c87d 100644 --- a/pfbudget/transactions.py +++ b/pfbudget/transactions.py @@ -15,6 +15,8 @@ class Transaction: self.bank = "" self.value = 0 self.category = None + self.original = "" + self.additional_comment = "" arg = args[0] if len(args) == 1 else list(args) try: @@ -29,6 +31,8 @@ class Transaction: else: self.value = Decimal(args[3]) self.category = arg[4] + self.original = arg[5] + self.additional_comment = arg[6] except IndexError: pass except InvalidOperation: