Skip to content
Snippets Groups Projects
Commit 053a023f authored by Olivier Colson's avatar Olivier Colson
Browse files

[FIX] account: apply correct currency rate for taxes at account move creation

Before that, taxes were only applied with the most recent currency rate, which caused problems in multi currencies, when reconciling statement lines made in the past with invoices, causing the amount currencies in the payment account.move to be wrong.

//Scenario to reproduce the issue (from customer ticket 1903497):

(for a company with USD as base currency)

1. Create a new bank journal for EUR payments

2. Create a new customer invoice for 90€

3. Create a new tax for the reconciliation model, price-included and amounting to 15%

4. Create a new reconciliation model using this tax

5. Use the currency rates from the demo data, add one that is closer to current date than the most recent one.

6. Create a new bank statement for the created EUR bank journal. Make sure that the transaction is less than the actual amount due on the invoice so that we can apply the reconciliation model. Also make sure to set a date on the transaction that lies in the past at some point when the currency rate was (significantly) different.

7. Hit the reconcile button, select the amount due from the invoice and apply the discount reconciliation model(take note of the amount on the created tax move line). Now reconcile.

What is the current behavior that you observe?

Now go back to the bank statement and check the created journal entries. You will see a difference in the amount currency values of the payment and the tax account move line. This difference should not exist.
parent bbeb126c
Branches
Tags
No related merge requests found
......@@ -146,7 +146,7 @@ class AccountMove(models.Model):
if not journal.refund_sequence_id:
raise UserError(_('Please define a sequence for the refunds'))
sequence = journal.refund_sequence_id
new_name = sequence.with_context(ir_sequence_date=move.date).next_by_id()
else:
raise UserError(_('Please define a sequence on the journal.'))
......@@ -1200,6 +1200,8 @@ class AccountMoveLine(models.Model):
ctx = {}
if 'date' in vals:
ctx['date'] = vals['date']
elif 'date_maturity' in vals:
ctx['date'] = vals['date_maturity']
temp['currency_id'] = bank.currency_id.id
temp['amount_currency'] = bank.company_id.currency_id.with_context(ctx).compute(tax_vals['amount'], bank.currency_id, round=True)
tax_lines_vals.append(temp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment