From 8516134687e83c69c2985d4f1e6c301d5798de4c Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 11 Nov 2019 10:18:21 -0500 Subject: [PATCH] hooks.ledger_entry: Improve date handling. Check that we have the date field used in the payee line, and not just 'date'. Allow other date fields to be None since they may not be used by the template. --- import2ledger/hooks/ledger_entry.py | 19 +++++++++++-------- setup.py | 2 +- tests/test_hook_ledger_entry.py | 12 ++++++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/import2ledger/hooks/ledger_entry.py b/import2ledger/hooks/ledger_entry.py index c470098..a677dcf 100644 --- a/import2ledger/hooks/ledger_entry.py +++ b/import2ledger/hooks/ledger_entry.py @@ -224,7 +224,7 @@ class AccountSplitter: class Template: ACCOUNT_SPLIT_RE = re.compile(r'(?:\t| )\s*') DATE_FMT = '%Y/%m/%d' - PAYEE_LINE_RE = re.compile(r'\{(\w*_)*date\}') + PAYEE_LINE_RE = re.compile(r'^\{(\w*_)*date\}\s') SIGNED_CURRENCY_FMT = '¤#,##0.###;¤-#,##0.###' UNSIGNED_CURRENCY_FMT = '#,##0.### ¤¤' @@ -234,6 +234,7 @@ class Template: unsigned_currency_fmt=UNSIGNED_CURRENCY_FMT, template_name='