Refactor ledger processing to explicit mapping which will make automated classfication easy

This commit is contained in:
2023-06-24 22:54:31 +02:00
parent b6de0e5514
commit ba0c906e3c
9 changed files with 421 additions and 8 deletions

17
src/write.py Normal file
View File

@@ -0,0 +1,17 @@
from pathlib import Path
from typing import List
from src.models import Transaction
LEDGER_TRANSACTION_TEMPLATE = """
{t.date} {t.description} ; {t.row}
{t.account2} {t.currency} {t.debit}
{t.account1} {t.currency} {t.credit}
"""
def render_to_file(transactions: List[Transaction], ledger_file: Path):
content = "".join([LEDGER_TRANSACTION_TEMPLATE.format(t=t)
for t in transactions])
with open(ledger_file, 'a') as f:
f.write(content)