Update ledgerai to read existing transactions from beancount file

This commit is contained in:
2025-12-20 15:33:08 -05:00
parent f56c559c84
commit 54871d04cd
11 changed files with 156 additions and 461 deletions

View File

@@ -3,7 +3,7 @@ import logging
import os
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Dict, List
from pydantic import ValidationError
@@ -57,14 +57,6 @@ def category_to_bean(c: str) -> str:
return ":".join(new_sections)
def write_meta(config: Config):
with open(config.output_file, "a") as f:
for category in config.categories:
f.write(f"2017-01-01 open {category_to_bean(category)}\n")
f.write("\n")
f.write('option "operating_currency" "USD"\n\n')
def write_mappings(transactions: List[Transaction], mappings_file: Path):
"""Write transactions to the mappings file."""
@@ -74,10 +66,8 @@ def write_mappings(transactions: List[Transaction], mappings_file: Path):
pass
else:
mapping = Mapping(
**{
"account2": t.account2.strip(),
"narration": t.description,
}
account2=t.account2.strip(),
narration=t.description,
)
mappings[t.key()] = mapping