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.
This commit is contained in:
Luís Murta 2021-12-01 18:31:25 +00:00
parent 865874f637
commit a1f5699b12
Signed by: satprog
GPG Key ID: DDF2EFC6179009DC
2 changed files with 12 additions and 6 deletions

View File

@ -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
);
"""

View File

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