[FIX] account: company currency in payment
The company currency should be the company currency of the invoice, not the company currency of the account journal linked to the payment. The following use case causes an issue: - invoice in GBP - journal of the invoice in AED - journal of the payment in CHF In this case, residual_company_signed will be considered to be in CHF while it was recorded in AED. opw-666595
This commit is contained in:
@@ -87,10 +87,12 @@ class account_abstract_payment(models.AbstractModel):
|
||||
if all(inv.currency_id == payment_currency for inv in invoices):
|
||||
total = sum(invoices.mapped('residual_signed'))
|
||||
else:
|
||||
total = sum(invoices.mapped('residual_company_signed'))
|
||||
company_currency = self.company_id.currency_id if self.company_id else self.env.user.company_id.currency_id
|
||||
if company_currency and company_currency != payment_currency:
|
||||
total = company_currency.with_context(date=self.payment_date).compute(total, payment_currency)
|
||||
total = 0
|
||||
for inv in invoices:
|
||||
if inv.company_currency_id != payment_currency:
|
||||
total += inv.company_currency_id.with_context(date=self.payment_date).compute(inv.residual_company_signed, payment_currency)
|
||||
else:
|
||||
total += inv.residual_company_signed
|
||||
return abs(total)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user