changeset 47452ac8d7c3 in modules/account_invoice:6.0
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=47452ac8d7c3
description:
        Use the total amount of the invoice as second currency total

        issue10923
        review381341002
        (grafted from 445db5742671487d6179237bf4c7c21c0d1017b6)
diffstat:

 invoice.py |  16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diffs (30 lines):

diff -r de52945e5a1f -r 47452ac8d7c3 invoice.py
--- a/invoice.py        Fri Oct 29 17:03:20 2021 +0200
+++ b/invoice.py        Sun Oct 31 10:27:03 2021 +0100
@@ -985,19 +985,17 @@
         for tax in self.taxes:
             move_lines += tax.get_move_lines()
 
-        total = Decimal('0.0')
-        total_currency = Decimal('0.0')
-        for line in move_lines:
-            total += line.debit - line.credit
-            if line.amount_second_currency:
-                total_currency += line.amount_second_currency
-
-        term_lines = [(self.payment_term_date or today, total)]
+        total = sum(l.debit - l.credit for l in move_lines)
         if self.payment_term:
             payment_date = self.payment_term_date or self.invoice_date
             term_lines = self.payment_term.compute(
                 total, self.company.currency, payment_date)
-        remainder_total_currency = total_currency
+        else:
+            term_lines = [(self.payment_term_date or today, total)]
+        if self.currency != self.company.currency:
+            remainder_total_currency = -self.total_amount
+        else:
+            remainder_total_currency = 0
         for date, amount in term_lines:
             if self.type == 'out' and date < today:
                 lang = Lang.get()

Reply via email to