From 109d7549001bf9d115798c7c52de85b788294cd2 Mon Sep 17 00:00:00 2001 From: Red S Date: Fri, 5 May 2023 18:08:38 -0700 Subject: [PATCH] fix: allow file_date() to be called without initialization #61 --- beancount_reds_importers/libreader/ofxreader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/beancount_reds_importers/libreader/ofxreader.py b/beancount_reds_importers/libreader/ofxreader.py index 6e52f27..ebd0a93 100644 --- a/beancount_reds_importers/libreader/ofxreader.py +++ b/beancount_reds_importers/libreader/ofxreader.py @@ -37,8 +37,13 @@ def match_account_number(self, file_account, config_account): return file_account == config_account def file_date(self, file): - "Get the maximum date from the file." - return self.ofx_account.statement.end_date + """Get the ending date of the statement.""" + if not getattr(self, 'ofx_account', None): + self.initialize(file) + try: + return self.ofx_account.statement.end_date + except AttributeError: + return None def read_file(self, file): pass