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
This commit is contained in:
padreug 2025-10-23 01:09:43 +02:00
parent 3b371e3bec
commit 1a9c91d042

View file

@ -464,8 +464,15 @@ async def get_all_user_balances() -> list[UserBalance]:
balance = await get_account_balance(account.id) balance = await get_account_balance(account.id)
# Get all entry lines for this account to calculate fiat balances # Get all entry lines for this account to calculate fiat balances
# Only include cleared entries (exclude pending/flagged/voided)
entry_lines = await db.fetchall( 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}, {"account_id": account.id},
) )