generated from felixm/defaultpy
Implement new mapping format
This commit is contained in:
@@ -5,7 +5,7 @@ from toldg.models import Config, Transaction
|
||||
from toldg.utils import category_to_bean
|
||||
|
||||
BEANCOUNT_TRANSACTION_TEMPLATE = """
|
||||
{t.date} * "{t.description}"
|
||||
{t.date} * {t.description}
|
||||
{t.account2:<40} {t.debit:<6} {t.currency}
|
||||
{t.account1:<40} {t.credit:<6} {t.currency}
|
||||
"""
|
||||
@@ -13,7 +13,18 @@ BEANCOUNT_TRANSACTION_TEMPLATE = """
|
||||
|
||||
def format(t):
|
||||
t.date = t.date.replace("/", "-")
|
||||
t.description = t.description.replace('"', '\\"')
|
||||
if t.narration and t.payee:
|
||||
# A transaction may have an optional “payee” and/or a “narration.”
|
||||
t.description = f'"{t.payee}" "{t.narration}"'
|
||||
elif t.narration:
|
||||
# If you place a single string on a transaction line, it becomes its narration:
|
||||
t.description = f'"{t.narration}"'
|
||||
elif t.payee:
|
||||
# If you want to set just a payee, put an empty narration string:
|
||||
t.description = f'"{t.payee}" ""'
|
||||
else:
|
||||
t.description = f'"{t.description}"'
|
||||
|
||||
if not t.debit.startswith("-"):
|
||||
t.debit = " " + t.debit
|
||||
if not t.credit.startswith("-"):
|
||||
|
||||
Reference in New Issue
Block a user