Do not fail on missing balance_date

The balance date is optional in OFX format. So we fall-back to the default
value if it is missing.

issue9777
review293041002
This commit is contained in:
Cédric Krier
2021-01-03 13:04:53 +01:00
parent a6332c491c
commit 1b7b14422d
+4 -1
View File
@@ -57,7 +57,10 @@ class StatementImport(metaclass=PoolMeta):
if not isinstance(ofx_account.statement, ofxparse.Statement):
raise ImportStatementError(
gettext('account_statement_ofx.msg_import_no_statement'))
statement.date = ofx_account.statement.balance_date.date()
try:
statement.date = ofx_account.statement.balance_date.date()
except AttributeError:
pass
total_amount = sum(
t.amount for t in ofx_account.statement.transactions)
statement.total_amount = total_amount