fix difference_in_exchange

This commit is contained in:
Wilson Gomez 2023-09-26 16:04:15 -05:00
parent a7008a4be0
commit 6a664be024
2 changed files with 6 additions and 2 deletions

View file

@ -1,5 +1,5 @@
[tryton]
version=6.0.10
version=6.0.11
depends:
account
account_invoice

View file

@ -540,6 +540,9 @@ class Voucher(Workflow, ModelSQL, ModelView):
pool = Pool()
Invoice = pool.get('account.invoice')
MoveLine = pool.get('account.move.line')
pool = Pool()
config = pool.get('account.configuration')(1)
writeoff = None
# reconcile check
lines_list = []
for sl, ml in to_reconcile.values():
@ -549,6 +552,7 @@ class Voucher(Workflow, ModelSQL, ModelView):
amount = abs(ml.credit - ml.debit)
if invoice.currency != invoice.company.currency:
amount = abs(ml.amount_second_currency)
writeoff = config.difference_in_exchange
if self.currency.is_zero(abs(invoice.amount_to_pay) - amount) or self.currency.is_zero(invoice.amount_to_pay):
pending_reconcile = [l for l in invoice.payment_lines + invoice.lines_to_pay
if not l.reconciliation]
@ -585,7 +589,7 @@ class Voucher(Workflow, ModelSQL, ModelView):
if to_reconcile_lines:
lines_list.append(to_reconcile_lines)
if lines_list:
MoveLine.reconcile(*lines_list)
MoveLine.reconcile(*lines_list, writeoff=writeoff)
@classmethod
def delete(cls, vouchers):