diff --git a/CHANGELOG.md b/CHANGELOG.md index 023c2ac..782dd2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.13 + +- Fix: Income record split value should be subtracted, not added, to the account balance + ## 0.1.12 - Added total amount in persons view diff --git a/pyproject.toml b/pyproject.toml index 53680ca..cc15867 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "Bagels" -version = "0.1.12" +version = "0.1.13" authors = [ { name = "Jax", email = "enhancedjax@gmail.com" } ] diff --git a/src/bagels/managers/accounts.py b/src/bagels/managers/accounts.py index 797db5e..62ee6ca 100644 --- a/src/bagels/managers/accounts.py +++ b/src/bagels/managers/accounts.py @@ -31,7 +31,10 @@ def get_account_balance(accountId, session=None): try: # Initialize balance balance = ( - session.query(Account).filter(Account.id == accountId).first().beginningBalance + session.query(Account) + .filter(Account.id == accountId) + .first() + .beginningBalance ) # Get all records for this account @@ -66,7 +69,10 @@ def get_account_balance(accountId, session=None): # Add paid splits (they represent money coming into this account) for split in splits: if split.isPaid: - balance += split.amount + if split.record.isIncome: + balance -= split.amount + else: + balance += split.amount return round(balance, 2) finally: