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
(grafted from 46dc70e63342ec41efdf55f2c9e77f2ec27882a8)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier committed 2025-04-25 17:29:38 +02:00
1 parent e2077bb557
commit 626622d439
1 file changed
+6 -3
+6 -3
View File
@@ -57,14 +57,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