Skip to content
Snippets Groups Projects
Commit 5b36e8e3 authored by Laurent Smet's avatar Laurent Smet
Browse files

[FIX] account: Fix 'reconcile' of statement line in foreign currency


The liquidity line of a statement line is always expressed in journal currency.
The counterpart lines (invoice lines most of the time) are expressed in the transaction currency.
When reconciling the statement line with an invoice line, the current code sums the amounts in foreign currency to detect if there is a rounding issue or not.
However, the considered amount for the liquidity line is not expressed in the right currency (journal currency instead of the transaction one).

Note: The current test is working even without the fix in 14.0 but is failing on the next version because the code has changed.

co-author: ushyme (sesn) <sesn@odoo.com>
opw-2991183

closes odoo/odoo#103676

Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
parent e24988fa
Branches
Tags
No related merge requests found
......@@ -1069,7 +1069,7 @@ class AccountBankStatementLine(models.Model):
reconciliation_overview = []
total_balance = liquidity_lines.balance
total_amount_currency = liquidity_lines.amount_currency
total_amount_currency = -self._prepare_move_line_default_vals()[1]['amount_currency']
# Step 1: Split 'lines_vals_list' into two batches:
# - The existing account.move.lines that need to be reconciled with the statement line.
......
......@@ -1422,6 +1422,51 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
{'name': 'whatever', 'account_id': random_acc_1.id, 'balance': -100.0},
])
def test_reconciliation_statement_line_foreign_currency(self):
statement = self.env['account.bank.statement'].create({
'name': 'test_statement',
'date': '2019-01-01',
'journal_id': self.bank_journal_1.id,
'line_ids': [
(0, 0, {
'date': '2019-01-01',
'payment_ref': 'line_1',
'partner_id': self.partner_a.id,
'foreign_currency_id': self.currency_2.id,
'amount': -80.0,
'amount_currency': -120.0,
}),
],
})
statement.button_post()
statement_line = statement.line_ids
invoice = self.env['account.move'].create({
'move_type': 'in_invoice',
'invoice_date': '2019-01-01',
'date': '2019-01-01',
'partner_id': self.partner_a.id,
'currency_id': self.currency_2.id,
'invoice_line_ids': [
(0, None, {
'name': 'counterpart line, same amount',
'account_id': self.company_data['default_account_revenue'].id,
'quantity': 1,
'price_unit': 120.0,
}),
],
})
invoice.action_post()
invoice_line = invoice.line_ids.filtered(lambda line: line.account_internal_type == 'payable')
statement_line.reconcile([{'id': invoice_line.id}])
self.assertRecordValues(statement_line.line_ids, [
# pylint: disable=bad-whitespace
{'amount_currency': -80.0, 'currency_id': self.currency_1.id, 'balance': -80.0, 'reconciled': False},
{'amount_currency': 120.0, 'currency_id': self.currency_2.id, 'balance': 80.0, 'reconciled': True},
])
def test_reconciliation_statement_line_with_generated_payments(self):
self.statement.button_post()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment