From 1a9c91d0426f6780de9a9d4115285b4f2ad59032 Mon Sep 17 00:00:00 2001 From: padreug Date: Thu, 23 Oct 2025 01:09:43 +0200 Subject: [PATCH] FIX Admin Net Balance: Filters entry lines by journal entry flag Ensures that only cleared entry lines are included when calculating fiat balances by filtering based on the journal entry's flag. Excludes pending, flagged, and voided entries --- crud.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crud.py b/crud.py index 75b1fc4..be8f830 100644 --- a/crud.py +++ b/crud.py @@ -464,8 +464,15 @@ async def get_all_user_balances() -> list[UserBalance]: balance = await get_account_balance(account.id) # Get all entry lines for this account to calculate fiat balances + # Only include cleared entries (exclude pending/flagged/voided) entry_lines = await db.fetchall( - "SELECT * FROM entry_lines WHERE account_id = :account_id", + """ + SELECT el.* + FROM entry_lines el + JOIN journal_entries je ON el.journal_entry_id = je.id + WHERE el.account_id = :account_id + AND je.flag = '*' + """, {"account_id": account.id}, )