diff --git a/views_api.py b/views_api.py index b1aeed4..8c22f96 100644 --- a/views_api.py +++ b/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", []):