Filter synthetic Beancount entries from journal listings
The Recent Transactions card was showing Beancount-generated opening-balance entries from ledger summarization (flag 'S'). Adds a _SYNTHETIC_FLAGS set mirroring Fava's _EXCL_FLAGS (S/T/C/P/U/R/M) and skips matching entries in the two user-facing endpoints that previously only filtered by transaction type. Other journal callers already filter by flag '!' so are unaffected. Closes #3 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b2b2c109a4
commit
4085280711
1 changed files with 10 additions and 0 deletions
10
views_api.py
10
views_api.py
|
|
@ -94,6 +94,12 @@ from .auth import (
|
|||
|
||||
libra_api_router = APIRouter()
|
||||
|
||||
# Synthetic Beancount flags marking auto-generated entries (summarization,
|
||||
# padding, transfers, conversions, unrealized gains, returns, merging) that
|
||||
# should not appear in user-facing transaction lists. Mirrors Fava's
|
||||
# _EXCL_FLAGS in fava/core/file.py.
|
||||
_SYNTHETIC_FLAGS = frozenset({"S", "T", "C", "P", "U", "R", "M"})
|
||||
|
||||
|
||||
# ===== HELPER FUNCTIONS =====
|
||||
|
||||
|
|
@ -391,6 +397,8 @@ async def api_get_journal_entries(
|
|||
for e in all_entries:
|
||||
if e.get("t") != "Transaction":
|
||||
continue
|
||||
if e.get("flag") in _SYNTHETIC_FLAGS:
|
||||
continue
|
||||
|
||||
# Extract user ID from metadata or account names
|
||||
user_id = None
|
||||
|
|
@ -475,6 +483,8 @@ async def api_get_user_entries(
|
|||
for e in all_entries:
|
||||
if e.get("t") != "Transaction":
|
||||
continue
|
||||
if e.get("flag") in _SYNTHETIC_FLAGS:
|
||||
continue
|
||||
|
||||
# Skip voided transactions
|
||||
if "voided" in e.get("tags", []):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue