diff --git a/account.py b/account.py index 9d097cf525..86a0e784a5 100644 --- a/account.py +++ b/account.py @@ -58,7 +58,11 @@ class StatementImport(metaclass=PoolMeta): raise ImportStatementError( gettext('account_statement_ofx.msg_import_no_statement')) statement.date = ofx_account.statement.balance_date.date() - statement.total_amount = ofx_account.statement.balance + total_amount = sum( + t.amount for t in ofx_account.statement.transactions) + statement.total_amount = total_amount + statement.start_balance = ofx_account.statement.balance - total_amount + statement.end_balance = ofx_account.statement.balance statement.number_of_lines = len(ofx_account.statement.transactions) return statement diff --git a/tests/OFX.txt b/tests/OFX.txt index 41d65766c9..5eaa0fd866 100644 --- a/tests/OFX.txt +++ b/tests/OFX.txt @@ -48,11 +48,11 @@ NEWFILEUID:NONE -100.00 +500.00 20180222 -100.00 +500.00 20180222 diff --git a/tests/scenario_account_statement_ofx.rst b/tests/scenario_account_statement_ofx.rst index 5cb198cbd0..e8b7f99770 100644 --- a/tests/scenario_account_statement_ofx.rst +++ b/tests/scenario_account_statement_ofx.rst @@ -102,6 +102,10 @@ Check Statement:: Decimal('100.00') >>> statement.number_of_lines 1 + >>> statement.start_balance + Decimal('400.00') + >>> statement.end_balance + Decimal('500.00') >>> len(statement.origins) 1 >>> origin, = statement.origins