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
This commit is contained in:
Cédric Krier
2025-04-25 17:29:38 +02:00
parent 8348ca4379
commit 47c173f74b
+6 -3
View File
@@ -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