From 47c173f74b67fa964f6a18fd93a1494fb3b5c136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 25 Apr 2025 17:29:38 +0200 Subject: [PATCH] Do not use OFX balance statement if the balance date is not the statement end date The bank can put a balance for the statement at a different date than the end date of the statement. But for Tryton the end balance must be the balance at the end of the statement. Closes #13982 --- modules/account_statement_ofx/account.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/account_statement_ofx/account.py b/modules/account_statement_ofx/account.py index 28ace252b1..d3636f4000 100644 --- a/modules/account_statement_ofx/account.py +++ b/modules/account_statement_ofx/account.py @@ -51,14 +51,17 @@ class StatementImport(metaclass=PoolMeta): raise ImportStatementError( gettext('account_statement_ofx.msg_import_no_statement')) try: - statement.date = ofx_account.statement.balance_date.date() + statement.date = ofx_account.statement.end_date.date() except AttributeError: pass 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 + if (ofx_account.statement.end_date + == ofx_account.statement.balance_date): + 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