details:   https://code.tryton.org/tryton/commit/0b4fca5fe44b
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Mon Mar 16 15:54:38 2026 +0100
description:
        Create a hook to compute the reverse tax and amount from the tax type

        Closes #14681
diffstat:

 modules/account/tax.py |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 3e58474b6aed -r 0b4fca5fe44b modules/account/tax.py
--- a/modules/account/tax.py    Sun Mar 29 20:05:46 2026 +0200
+++ b/modules/account/tax.py    Mon Mar 16 15:54:38 2026 +0100
@@ -1020,6 +1020,14 @@
             price_unit += unit_price_variation
         return res
 
+    def _reverse_rate_amount_from_type(self, rate, amount):
+        if self.type == 'percentage':
+            return rate + self.rate, amount
+        elif self.type == 'fixed':
+            return rate, amount + self.amount
+        elif self.type == 'none':
+            return rate, amount
+
     @classmethod
     def _reverse_rate_amount(cls, taxes, date):
         rate, amount = 0, 0
@@ -1029,10 +1037,7 @@
             if not (start_date <= date <= end_date):
                 continue
 
-            if tax.type == 'percentage':
-                rate += tax.rate
-            elif tax.type == 'fixed':
-                amount += tax.amount
+            rate, amount = tax._reverse_rate_amount_from_type(rate, amount)
 
             if tax.childs:
                 child_rate, child_amount = cls._reverse_rate_amount(

Reply via email to