From d4c70ae1e35f6a4456c8299e10e633690cdc674a Mon Sep 17 00:00:00 2001 From: "Paolo Gatti (pgi)" Date: Wed, 15 Nov 2023 15:51:48 +0000 Subject: [PATCH] [FIX] l10n_it_edi_withholding: Fix Natura field on Pension Fund Reproduce: Install l10n_it_edi_withholding Have an invoice with lines with two taxes: . 4% INPS . 0% with exoneration and exoneration kind Post Send to Tax Agency Tax Agency rejects it The Exoneration Kind tag is related to the VAT tax it is applied to, not to the Pension Fund tax itself, so we have to modify the template. A test has been added for the case. Task link: https://www.odoo.com/web#model=project.task&id=3495670 opw-3495670 closes odoo/odoo#142543 X-original-commit: cbbdd974da4ce55a7b10fba39db4f9278f161808 Signed-off-by: Josse Colpaert Signed-off-by: Paolo Gatti (pgi) --- .../data/invoice_it_template.xml | 4 +- .../tests/export_xmls/inps_tax_invoice.xml | 137 ++++++++++++++++++ .../tests/test_withholding.py | 50 +++++++ 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 addons/l10n_it_edi_withholding/tests/export_xmls/inps_tax_invoice.xml diff --git a/addons/l10n_it_edi_withholding/data/invoice_it_template.xml b/addons/l10n_it_edi_withholding/data/invoice_it_template.xml index 75fc5954f84..999eaa308f7 100644 --- a/addons/l10n_it_edi_withholding/data/invoice_it_template.xml +++ b/addons/l10n_it_edi_withholding/data/invoice_it_template.xml @@ -21,8 +21,8 @@ SI - - + + diff --git a/addons/l10n_it_edi_withholding/tests/export_xmls/inps_tax_invoice.xml b/addons/l10n_it_edi_withholding/tests/export_xmls/inps_tax_invoice.xml new file mode 100644 index 00000000000..0978fd4a064 --- /dev/null +++ b/addons/l10n_it_edi_withholding/tests/export_xmls/inps_tax_invoice.xml @@ -0,0 +1,137 @@ + + + + + + IT + 01234560157 + + ___ignore___ + FPR12 + 0000000 + + 0266766700 + test@test.it + + + + + + IT + 01234560157 + + 01234560157 + + company_2_data + + RF01 + + + 1234 Test Street + 12345 + Prova + IT + + + + + + IT + 00465840031 + + 93026890017 + + Alessi + + + + Via Privata Alessi 6 + 28887 + Milan + IT + + + + + + + TD01 + EUR + ___ignore___ + ___ignore___ + + TC22 + 4.00 + 30.00 + 750.00 + 0.00 + N2.2 + + 780.00 + + + + + 1 + + Ordinary accounting service for the year + + 1.00 + 350.000000 + 350.00 + 0.00 + N2.2 + + + 2 + + Balance deposit for the past year + + 1.00 + 300.000000 + 300.00 + 0.00 + N2.2 + + + 3 + + Ordinary accounting service for the trimester + + 1.00 + 50.000000 + 50.00 + 0.00 + N2.2 + + + 4 + + Electronic invoices management + + 1.00 + 50.000000 + 50.00 + 0.00 + N2.2 + + + 0.00 + N2.2 + 780.00 + 0.00 + I + Fatture emesse o ricevute da contribuenti forfettari o minimi + + + + TP02 + + MP05 + ___ignore___ + 780.00 + ___ignore___ + + + + diff --git a/addons/l10n_it_edi_withholding/tests/test_withholding.py b/addons/l10n_it_edi_withholding/tests/test_withholding.py index 2da158812c1..f528b5be40d 100644 --- a/addons/l10n_it_edi_withholding/tests/test_withholding.py +++ b/addons/l10n_it_edi_withholding/tests/test_withholding.py @@ -26,6 +26,17 @@ class TestWithholdingAndPensionFundTaxes(TestItEdi): cls.enasarco_sale_tax = find_tax_by_ref('enasarcov') cls.withholding_purchase_tax_23 = find_tax_by_ref('23awo') cls.enasarco_purchase_tax = find_tax_by_ref('enasarcoa') + cls.inps_tax = find_tax_by_ref('4vinps') + + cls.zero_tax = cls.env['account.tax'].with_company(cls.company).create({ + 'name': 'ZeroTax', + 'sequence': 31, + 'type_tax_use': 'sale', + 'amount': 0.0, + 'amount_type': 'percent', + 'l10n_it_exempt_reason': 'N2.2', + 'l10n_it_law_reference': 'Fatture emesse o ricevute da contribuenti forfettari o minimi', + }) cls.withholding_sale_line = { 'name': 'withholding_line', @@ -56,6 +67,12 @@ class TestWithholdingAndPensionFundTaxes(TestItEdi): ])] } + cls.inps_sale_line = { + 'name': 'inps_line', + 'quantity': 1, + 'tax_ids': [(6, 0, [cls.inps_tax.id, cls.zero_tax.id])] + } + invoice_data = cls.get_real_client_invoice_data() cls.withholding_tax_invoice = cls.env['account.move'].with_company(cls.company).create({ @@ -103,9 +120,25 @@ class TestWithholdingAndPensionFundTaxes(TestItEdi): ] }) + cls.inps_tax_invoice = cls.env['account.move'].with_company(cls.company).create({ + 'move_type': 'out_invoice', + 'company_id': cls.company.id, + 'partner_id': cls.italian_partner_a.id, + 'invoice_date': datetime.date(2022, 3, 24), + 'invoice_date_due': datetime.date(2022, 3, 24), + 'invoice_line_ids': [ + (0, 0, { + **cls.inps_sale_line, + 'name': name, + 'price_unit': price, + }) for (name, price) in invoice_data.lines + ] + }) + cls.withholding_tax_invoice._post() cls.pension_fund_tax_invoice._post() cls.enasarco_tax_invoice._post() + cls.inps_tax_invoice._post() cls.module = 'l10n_it_edi_withholding' @@ -261,3 +294,20 @@ class TestWithholdingAndPensionFundTaxes(TestItEdi): self.assertEqual(self.enasarco_purchase_tax, enasarco_imported_tax) self.assertEqual(-8.5, enasarco_imported_tax.amount) self.assertEqual(self.withholding_purchase_tax_23, line.tax_ids.filtered(lambda x: x.l10n_it_withholding_reason == 'ZO')) + + def test_inps_tax_export(self): + """ + Invoice + ----------------------------------------------------------------- + Ordinary accounting service for the year 350.00 + Balance deposit for the past year 300.00 + Ordinary accounting service for the trimester 50.00 + Electronic invoices management 50.00 + ----------------------------------------------------------------- + Total untaxed: 750.00 + VAT: 0% of Untaxed Amount 0.00 + INPS: 4% of Untaxed Amount 30.00 + Document total: Taxed Amount 780.00 + Payment amount: Document total 780.00 + """ + self._assert_export_invoice(self.inps_tax_invoice, 'inps_tax_invoice.xml')