diff --git a/fava_client.py b/fava_client.py index 7719c38..8dcf31c 100644 --- a/fava_client.py +++ b/fava_client.py @@ -1626,21 +1626,15 @@ class FavaClient: logger.info(f"Account {account_name} already exists in {target_file}") return {"data": sha256sum, "mtime": source_data.get("mtime", "")} - # Step 3: Find insertion point (after last Open directive AND its metadata). - # If the file has no Open directives yet (e.g. the empty - # accounts/users.beancount seed), append at end of file - # so the seed header comments stay at the top. + # Step 3: Always append at end of file. + # Post-split layout, each include file has one mutation + # profile (only Open directives in chart/users, only + # Transactions in transactions.beancount), so there's no + # reason to slot new entries mid-file. Append-only also + # keeps the seed header comments at the top and makes + # the file's evolution trivially readable. lines = source.split('\n') - insert_index = None - for i, line in enumerate(lines): - if line.strip().startswith(('open ', f'{opening_date.year}-')) and 'open' in line: - # Found an Open directive, now skip over any metadata lines - insert_index = i + 1 - # Skip metadata lines (lines starting with whitespace) - while insert_index < len(lines) and lines[insert_index].startswith((' ', '\t')) and lines[insert_index].strip(): - insert_index += 1 - if insert_index is None: - insert_index = len(lines) + insert_index = len(lines) # Step 4: Format Open directive as Beancount text currencies_str = ", ".join(currencies)