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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user