From d26c0a6dde34e4c4a9dafc6806d0a90aafef3fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 6 Dec 2017 01:10:35 +0100 Subject: [PATCH] Compare amount in the invoice currency against amount_to_pay issue6842 review40841002 --- invoice.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/invoice.py b/invoice.py index 92e22df575..b30747ee83 100644 --- a/invoice.py +++ b/invoice.py @@ -2546,8 +2546,11 @@ class PayInvoice(Wizard): with Transaction().set_context(date=self.start.date): amount = Currency.compute(self.start.currency, self.start.amount, invoice.company.currency) + amount_invoice = Currency.compute( + self.start.currency, self.start.amount, invoice.currency) _, remainder = self.get_reconcile_lines_for_amount(invoice, amount) - if remainder == Decimal('0.0') and amount <= invoice.amount_to_pay: + if (remainder == Decimal('0.0') + and amount_invoice <= invoice.amount_to_pay): return 'pay' return 'ask' @@ -2570,6 +2573,8 @@ class PayInvoice(Wizard): with Transaction().set_context(date=self.start.date): amount = Currency.compute(self.start.currency, self.start.amount, invoice.company.currency) + amount_invoice = Currency.compute( + self.start.currency, self.start.amount, invoice.currency) if invoice.company.currency.is_zero(amount): lines = invoice.lines_to_pay @@ -2588,7 +2593,7 @@ class PayInvoice(Wizard): default['currency_digits_writeoff'] = invoice.company.currency.digits default['invoice'] = invoice.id - if (amount > invoice.amount_to_pay + if (amount_invoice > invoice.amount_to_pay or invoice.company.currency.is_zero(amount)): default['type'] = 'writeoff' return default