changeset 28f7a05bf0f8 in modules/account_invoice:6.0 details: https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=28f7a05bf0f8 description: Warn all past payment terms at the same time
issue11058 review376221002 (grafted from 02be5467be12c4fabc75e31f3977faabe8155259) diffstat: invoice.py | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diffs (37 lines): diff -r 1d5b48634551 -r 28f7a05bf0f8 invoice.py --- a/invoice.py Fri Nov 05 00:18:37 2021 +0100 +++ b/invoice.py Tue Jan 25 23:30:35 2022 +0100 @@ -996,21 +996,23 @@ remainder_total_currency = self.total_amount.copy_sign(total) else: remainder_total_currency = 0 + past_payment_term_dates = [] for date, amount in term_lines: - if self.type == 'out' and date < today: - lang = Lang.get() - warning_key = 'invoice_payment_term_%d' % self.id - if Warning.check(warning_key): - raise InvoicePaymentTermDateWarning(warning_key, - gettext('account_invoice' - '.msg_invoice_payment_term_date_past', - invoice=self.rec_name, - date=lang.strftime(date))) - line = self._get_move_line(date, amount) if line.amount_second_currency: remainder_total_currency += line.amount_second_currency move_lines.append(line) + if self.type == 'out' and date < today: + past_payment_term_dates.append(date) + if any(past_payment_term_dates): + lang = Lang.get() + warning_key = 'invoice_payment_term_%d' % self.id + if Warning.check(warning_key): + raise InvoicePaymentTermDateWarning(warning_key, + gettext('account_invoice' + '.msg_invoice_payment_term_date_past', + invoice=self.rec_name, + date=lang.strftime(min(past_payment_term_dates)))) if not self.currency.is_zero(remainder_total_currency): move_lines[-1].amount_second_currency -= \ remainder_total_currency