From 294638385316b95dd35587d323c3462ad6893cd8 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Tue, 8 Jul 2025 07:50:08 +0100 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E2=9C=A8=20Added=20wireframe=20of?= =?UTF-8?q?=20Account=20Class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/account.py | 65 +++++++++++++++++++++++++++++++++++++++++++++ api/src/category.py | 2 +- api/src/user.py | 11 +++++++- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 api/src/account.py diff --git a/api/src/account.py b/api/src/account.py new file mode 100644 index 0000000..411c2e1 --- /dev/null +++ b/api/src/account.py @@ -0,0 +1,65 @@ +"Account Module" + +import logging + +from api.src.user import User # probably the other way round +from api.src.data_handler import Database + +logger = logging.getLogger(__name__) + + +class Account: + "Main account class for any 'real' storage of currency" + + def __init__( + self, + database: Database, + name: str = "", + id: int = 0, + ): + self.database = database + self.name = name + self.id = id + logger.info(f"Account {self.name} | {self.id} initialised") + + def __repr__(self): + pass + + def __str__(self): + pass + + def add(self): + "add account to database" + pass + + def get_name(self): + "get name with id" + pass + + def get_id(self): + "get id with name" + pass + + def get(self): + "get account details from database" + pass + + +class currentAccount(Account): + "Current Bank Account for every day banking" + + +class cashAccount(Account): + "Cash Account for tracking your real money" + + +class savingAccount(Account): + "Saving Account for tracking your savings" + + +class creditAccount(Account): + "Credit Acount, for tracking your debts like credit cards" + + +class untrackedAccount(Account): + "for money you still want to see, but dont use as part of your budget." diff --git a/api/src/category.py b/api/src/category.py index 65bf6c4..47ceac6 100644 --- a/api/src/category.py +++ b/api/src/category.py @@ -9,7 +9,7 @@ class Category: - "Main category class, for anything related to the category" + "Main category class, for any theoretical storage of currency" def __init__( self, diff --git a/api/src/user.py b/api/src/user.py index d670ea5..1117859 100644 --- a/api/src/user.py +++ b/api/src/user.py @@ -3,6 +3,14 @@ from api.src.category import Category from api.src.data_handler import Database +from api.src.account import ( + Account, + currentAccount, + cashAccount, + savingAccount, + creditAccount, + untrackedAccount, +) logger = logging.getLogger(__name__) @@ -14,8 +22,9 @@ def __init__(self, database: Database, user_name: str = "", id: int = 0): self.database: Database = database self.name: str = user_name self.id: int = id - self.categories: List = [] + self.categories: List[Category] = [] self.internal_category_id = 0 + self.accounts: list[Account] = [] logger.info(f"{self.name} initialised.") def __str__(self): From eee1868ccc19a81f9658bcc1238016e9b25fe3b3 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Tue, 8 Jul 2025 07:57:45 +0100 Subject: [PATCH 2/8] Added parent initialise to child account classes --- api/src/account.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/api/src/account.py b/api/src/account.py index 411c2e1..bbad3e2 100644 --- a/api/src/account.py +++ b/api/src/account.py @@ -2,7 +2,6 @@ import logging -from api.src.user import User # probably the other way round from api.src.data_handler import Database logger = logging.getLogger(__name__) @@ -48,18 +47,38 @@ def get(self): class currentAccount(Account): "Current Bank Account for every day banking" + def __init__(self, database, name, id): + self.type = "Current" + super(currentAccount, self).__init__(database, name, id) + class cashAccount(Account): "Cash Account for tracking your real money" + def __init__(self, database, name, id): + self.type = "Cash" + super(currentAccount, self).__init__(database, name, id) + class savingAccount(Account): "Saving Account for tracking your savings" + def __init__(self, database, name, id): + self.type = "Saving" + super(currentAccount, self).__init__(database, name, id) + class creditAccount(Account): "Credit Acount, for tracking your debts like credit cards" + def __init__(self, database, name, id): + self.type = "Credit" + super(currentAccount, self).__init__(database, name, id) + class untrackedAccount(Account): "for money you still want to see, but dont use as part of your budget." + + def __init__(self, database, name, id): + self.type = "Untracked" + super(currentAccount, self).__init__(database, name, id) From 22177c1600ae2ad3038e67b184b081deccad9b81 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Thu, 17 Jul 2025 15:37:07 +0100 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=F0=9F=94=8D=20Added=20the=20docs?= =?UTF-8?q?=20for=20Accounts=20and=20fixed=20a=20small=20issue=20with=20fi?= =?UTF-8?q?rst=20time=20runs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/src/components/accounts.md | 38 ++++++++++++++++++++++++++++++++- verity.py | 7 +++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/src/components/accounts.md b/docs/src/components/accounts.md index 9dea6d7..6f9e357 100644 --- a/docs/src/components/accounts.md +++ b/docs/src/components/accounts.md @@ -1,3 +1,39 @@ # Accounts -## coming soon + + +The Attributes of the accounts class are: + +- database (Database Object) + * passed in so we can test with a theoretical database + +- name (String) + * The name of the account as stored in the database + +- id (int) + * the id of the account as stored in the database + +The Methods of the account class are: + +- add + * Adds the account to the database + +- get_name + * Gets the name of the account, sets it in the name attribute + +- get_id + * gets the id od the account, sets it in the id attribute + +- get + * gets all sored information about the account + * _Probably_ returns the results, so we can build an object with the data. + +The Attribute class is a parent class to the following children: +The use case of these will allow for more fexible handling of specific tasks that each account type +will be able to do. + +- CurrentAccount +- cashAccount +- savingAccount +- creditAccount +- untrackedAccount diff --git a/verity.py b/verity.py index c475100..4d62c0a 100644 --- a/verity.py +++ b/verity.py @@ -9,9 +9,14 @@ from api.src.data_handler import Database from front.home import home_bp +os.makedirs("./logs", exist_ok=True) +os.makedirs("./api/data", exist_ok=True) +if not os.path.exists("./logs/verity.log"): + with open("./logs/verity.log", mode="w"): + pass # create empty file, so logging file handler can work + def set_up_logging(config): - os.makedirs("../logs", exist_ok=True) logging.config.dictConfig(config.LOGGING_CONFIG) queue_handler = logging.getHandlerByName("queue_handler") if queue_handler is not None: From a8dee518aa90d09e69d0b80f71d48073495dd786 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Thu, 24 Jul 2025 07:39:16 +0100 Subject: [PATCH 4/8] Added first account method --- api/config_files/verity_schema.yaml | 7 ++++- api/src/account.py | 42 ++++++++++++++++++++++------- docs/src/components/accounts.md | 6 +++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/api/config_files/verity_schema.yaml b/api/config_files/verity_schema.yaml index a9ab43c..71029bf 100644 --- a/api/config_files/verity_schema.yaml +++ b/api/config_files/verity_schema.yaml @@ -43,6 +43,11 @@ tables: is_pk: False datatype: TEXT nullable: False + - column_name: balance + is_pk: False + is_fk: False + datatype: INTEGER + nullable: False - table_name: party table_columns: @@ -128,4 +133,4 @@ tables: - column_name: datetime is_pk: False datatype: TEXT - nullable: False \ No newline at end of file + nullable: False diff --git a/api/src/account.py b/api/src/account.py index bbad3e2..2576934 100644 --- a/api/src/account.py +++ b/api/src/account.py @@ -10,26 +10,45 @@ class Account: "Main account class for any 'real' storage of currency" - def __init__( - self, - database: Database, - name: str = "", - id: int = 0, - ): + def __init__(self, database: Database, name: str = "", id: int = 0, user_id: int = 0): self.database = database self.name = name self.id = id + self.user_id = user_id + self.type = "" + self.balance = 0 logger.info(f"Account {self.name} | {self.id} initialised") def __repr__(self): - pass + return f"""Account:( + Name: {self.name} + Id: {self.id} + Type: {self.type} + Balance: {self.balance} + ) + """ def __str__(self): - pass + return f"Account: {self.name} of type: {self.type}" def add(self): "add account to database" - pass + logger.info(f"Adding {self.name} to {self.user_id}") + if self.user_id == 0: + logger.error("Account not attached to a user, cannot continue") + return 0 + if not self.type_id: + logger.error("Cannot add a non-typed account, please use Children of Account") + return 0 + sql_statement = """ + INSERT INTO account (user_id, type_id, name, balance) + VALUES (?, ?, ?, ?) + """ + params = (self.user_id, self.type_id, self.name, self.balance) + success, self.id = self.database.execute(sql_statement, params, return_id=True) + if not success: + logger.error(f"Failed to add Account {self.name}, Check the logs") + return self.id def get_name(self): "get name with id" @@ -49,6 +68,7 @@ class currentAccount(Account): def __init__(self, database, name, id): self.type = "Current" + self.type_id = 1 super(currentAccount, self).__init__(database, name, id) @@ -57,6 +77,7 @@ class cashAccount(Account): def __init__(self, database, name, id): self.type = "Cash" + self.type_id = 2 super(currentAccount, self).__init__(database, name, id) @@ -65,6 +86,7 @@ class savingAccount(Account): def __init__(self, database, name, id): self.type = "Saving" + self.type_id = 2 super(currentAccount, self).__init__(database, name, id) @@ -73,6 +95,7 @@ class creditAccount(Account): def __init__(self, database, name, id): self.type = "Credit" + self.type_id = 3 super(currentAccount, self).__init__(database, name, id) @@ -81,4 +104,5 @@ class untrackedAccount(Account): def __init__(self, database, name, id): self.type = "Untracked" + self.type_id = 4 super(currentAccount, self).__init__(database, name, id) diff --git a/docs/src/components/accounts.md b/docs/src/components/accounts.md index 6f9e357..0c49177 100644 --- a/docs/src/components/accounts.md +++ b/docs/src/components/accounts.md @@ -13,6 +13,12 @@ The Attributes of the accounts class are: - id (int) * the id of the account as stored in the database +- Type (String) + * The type of account (see children below) + +- balance (int) + * The amount of currency the account holds + The Methods of the account class are: - add From acb66edd0074816276ed122a6db59e89dd9c83b8 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Sat, 6 Dec 2025 20:30:59 +0000 Subject: [PATCH 5/8] . --- api/src/account.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/src/account.py b/api/src/account.py index 2576934..a95fa81 100644 --- a/api/src/account.py +++ b/api/src/account.py @@ -17,6 +17,7 @@ def __init__(self, database: Database, name: str = "", id: int = 0, user_id: int self.user_id = user_id self.type = "" self.balance = 0 + self.type_id = 0 logger.info(f"Account {self.name} | {self.id} initialised") def __repr__(self): @@ -37,7 +38,7 @@ def add(self): if self.user_id == 0: logger.error("Account not attached to a user, cannot continue") return 0 - if not self.type_id: + if self.type_id == 0: logger.error("Cannot add a non-typed account, please use Children of Account") return 0 sql_statement = """ @@ -86,7 +87,7 @@ class savingAccount(Account): def __init__(self, database, name, id): self.type = "Saving" - self.type_id = 2 + self.type_id = 3 super(currentAccount, self).__init__(database, name, id) @@ -95,7 +96,7 @@ class creditAccount(Account): def __init__(self, database, name, id): self.type = "Credit" - self.type_id = 3 + self.type_id = 4 super(currentAccount, self).__init__(database, name, id) @@ -104,5 +105,5 @@ class untrackedAccount(Account): def __init__(self, database, name, id): self.type = "Untracked" - self.type_id = 4 + self.type_id = 5 super(currentAccount, self).__init__(database, name, id) From 3e9a095c22c5efc2ec67de051a80bbe32b81c615 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Sat, 6 Dec 2025 21:22:58 +0000 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20=E2=9C=A8=20Basic=20Account=20Suppo?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agents.md | 10 + api/src/account.py | 20 +- api/src/data_handler.py | 42 +++- api/src/user.py | 24 ++ front/home.py | 48 ++++ front/templates/home.html | 26 +++ uv.lock | 448 ++++++++++++++++++++++++++------------ 7 files changed, 463 insertions(+), 155 deletions(-) create mode 100644 agents.md diff --git a/agents.md b/agents.md new file mode 100644 index 0000000..964bed3 --- /dev/null +++ b/agents.md @@ -0,0 +1,10 @@ +# Agent Guidelines + +This file contains instructions and preferences for AI agents working on this repository. + +## Environment and Package Management + +- **Tool**: Use `uv` for all environment and package management tasks. +- **Running Scripts**: Use `uv run