diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml
index 52135400e84..b9ac656bad0 100644
--- a/addons/l10n_it_edi/data/invoice_it_template.xml
+++ b/addons/l10n_it_edi/data/invoice_it_template.xml
@@ -175,8 +175,8 @@
-
-
+
+
@@ -219,4 +219,3 @@
-
diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py
index 26debc5dd68..10d5eac9925 100644
--- a/addons/l10n_it_edi/models/account_invoice.py
+++ b/addons/l10n_it_edi/models/account_invoice.py
@@ -112,7 +112,7 @@ class AccountMove(models.Model):
})
return invoice_lines
- def _l10n_it_edi_prepare_fatturapa_tax_details(self, tax_details, reverse_charge_refund=False):
+ def _l10n_it_edi_prepare_fatturapa_tax_details(self, tax_details):
""" Returns a list of dictionaries passed to the template for the invoice lines (DatiRiepilogo)
"""
tax_lines = []
@@ -131,10 +131,6 @@ class AccountMove(models.Model):
tax_dict['rounding'] = base_amount - (tax_amount * 100 / tax_rate)
tax_dict['base_amount'] = base_amount - tax_dict['rounding']
- if not reverse_charge_refund:
- tax_dict['base_amount'] = abs(tax_dict['base_amount'])
- tax_dict['tax_amount'] = abs(tax_dict['tax_amount'])
-
tax_line_dict = {
'tax': tax,
'rounding': tax_dict.get('rounding', False),
@@ -251,7 +247,7 @@ class AccountMove(models.Model):
) if convert_to_euros and conversion_line else None
invoice_lines = self._l10n_it_edi_prepare_fatturapa_line_details(reverse_charge_refund, is_downpayment, convert_to_euros)
- tax_lines = self._l10n_it_edi_prepare_fatturapa_tax_details(tax_details, reverse_charge_refund)
+ tax_lines = self._l10n_it_edi_prepare_fatturapa_tax_details(tax_details)
# Reduce downpayment views to a single recordset
downpayment_moves = [l.get('downpayment_moves', self.env['account.move']) for l in invoice_lines]
diff --git a/addons/l10n_it_edi/tests/export_xmls/invoice_negative_price.xml b/addons/l10n_it_edi/tests/export_xmls/invoice_negative_price.xml
index 2c585d8133b..31076ca3622 100644
--- a/addons/l10n_it_edi/tests/export_xmls/invoice_negative_price.xml
+++ b/addons/l10n_it_edi/tests/export_xmls/invoice_negative_price.xml
@@ -62,7 +62,7 @@
EUR
2022-03-24
INV/2022/00001
- 854.49
+ 799.49
@@ -82,19 +82,33 @@
-100.00
22.00
+
+ 3
+ negative_line_different_tax
+ 1.00
+ -50.000000
+ -50.00
+ 10.00
+
22.00
700.40
154.09
I
+
+ 10.00
+ -50.00
+ -5.00
+ I
+
TP02
MP05
2022-03-24
- 854.49
+ 799.49
INV/2022/00001
diff --git a/addons/l10n_it_edi/tests/test_edi_export.py b/addons/l10n_it_edi/tests/test_edi_export.py
index 5ffa162abed..4588b9334c0 100644
--- a/addons/l10n_it_edi/tests/test_edi_export.py
+++ b/addons/l10n_it_edi/tests/test_edi_export.py
@@ -298,6 +298,13 @@ class TestItEdiExport(TestItEdi):
self._assert_export_invoice(invoice, 'invoice_zero_percent_taxes.xml')
def test_invoice_negative_price(self):
+ tax_10 = self.env['account.tax'].create({
+ 'name': '10% tax',
+ 'amount': 10.0,
+ 'amount_type': 'percent',
+ 'company_id': self.company.id,
+ })
+
invoice = self.env['account.move'].with_company(self.company).create({
'move_type': 'out_invoice',
'invoice_date': '2022-03-24',
@@ -315,6 +322,11 @@ class TestItEdiExport(TestItEdi):
'price_unit': -100.0,
'tax_ids': [Command.set(self.default_tax.ids)],
}),
+ Command.create({
+ 'name': 'negative_line_different_tax',
+ 'price_unit': -50.0,
+ 'tax_ids': [Command.set(tax_10.ids)],
+ }),
],
})
invoice.action_post()