diff --git a/mixin.py b/mixin.py
index 8a75aca..9550384 100644
--- a/mixin.py
+++ b/mixin.py
@@ -4,12 +4,13 @@
# full copyright notices and license terms.
-from decimal import Decimal
+from decimal import Decimal, ROUND_HALF_EVEN
import html
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.tools import cached_property
from trytond.pool import Pool
+from trytond.modules.product import price_digits
class EdocumentMixin(object):
@@ -183,6 +184,21 @@ class EdocumentMixin(object):
taxname=tax.rec_name))
return unece_category_code
+ def round_unitprice(self, value):
+ """ round value by digits in unit_price of account.invoice.line
+
+ Args:
+ value (Decimal): unit-price
+
+ Returns:
+ Decimal: rounded value
+ """
+ if isinstance(value, Decimal):
+ return value.quantize(
+ Decimal(str(1/10 ** price_digits[1])),
+ ROUND_HALF_EVEN)
+ return value
+
def quote_text(self, text):
""" replace critical chars
"""
diff --git a/template/Factur-X-1.07.2-extended/invoice.xml b/template/Factur-X-1.07.2-extended/invoice.xml
index f23354e..db85eb1 100644
--- a/template/Factur-X-1.07.2-extended/invoice.xml
+++ b/template/Factur-X-1.07.2-extended/invoice.xml
@@ -76,7 +76,7 @@ this repository contains the full copyright notices and license terms. -->
- ${this.invoice.currency.round(line.unit_price)}
+ ${this.round_unitprice(line.unit_price)}