Set write-off as default when paying exact amount of invoice

When paying the exact remaining amount of an invoice with different currency,
it should normally be a payment with write-off for exchange rate.

Closes #11821
This commit is contained in:
Cédric Krier committed 2022-12-30 23:37:56 +01:00
1 parent f72502b1ad
commit 5d074f963a
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -3312,7 +3312,7 @@ class PayInvoice(Wizard):
default['currency_writeoff'] = invoice.company.currency.id
default['invoice'] = invoice.id
if (amount_invoice > invoice.amount_to_pay
if (amount_invoice >= invoice.amount_to_pay
or invoice.company.currency.is_zero(amount)):
default['type'] = 'writeoff'
return default
@@ -165,7 +165,8 @@ Pay the invoice with rate change::
>>> pay.form.payment_method = payment_method
>>> pay.form.date = tomorrow
>>> pay.execute('choice')
>>> pay.form.type = 'writeoff'
>>> pay.form.type
'writeoff'
>>> pay.form.writeoff = writeoff
>>> pay.form.amount
Decimal('460.00')