[FIX] account: reconciled with forced amount_currency

This is possible to create bank statements
forcing the amount in the foreign currency,
along with the bank account currency, and therefore
to force the foreign currency rate.

In such a case, when reconciling the journal items,
the currency rate conversion must not be done
against the currency rates written in database,
in the rates records, at that date, but with
the rate that was forced in the bank statement.

opw-676048
This commit is contained in:
Denis Ledoux
2016-04-27 17:15:30 +02:00
parent 324dbcde57
commit 56d92213b8
+6 -2
View File
@@ -253,12 +253,16 @@ class AccountMoveLine(models.Model):
amount += sign_partial_line * partial_line.amount
#getting the date of the matched item to compute the amount_residual in currency
date = partial_line.credit_move_id.date if partial_line.debit_move_id == line else partial_line.debit_move_id.date
if line.currency_id:
if partial_line.currency_id and partial_line.currency_id == line.currency_id:
amount_residual_currency += sign_partial_line * partial_line.amount_currency
else:
amount_residual_currency += sign_partial_line * line.company_id.currency_id.with_context(date=date).compute(partial_line.amount, line.currency_id)
if line.balance and line.amount_currency:
rate = line.amount_currency / line.balance
else:
date = partial_line.credit_move_id.date if partial_line.debit_move_id == line else partial_line.debit_move_id.date
rate = line.currency_id.with_context(date=date).rate
amount_residual_currency += sign_partial_line * line.currency_id.round(partial_line.amount * rate)
#computing the `reconciled` field. As we book exchange rate difference on each partial matching,
#we can only check the amount in company currency