generated from felixm/defaultpy
Refactor ledger processing to explicit mapping which will make automated classfication easy
This commit is contained in:
17
src/write.py
Normal file
17
src/write.py
Normal 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)
|
||||
Reference in New Issue
Block a user