diff --git a/l10n_it_fatturapa_out_wt/README.rst b/l10n_it_fatturapa_out_wt/README.rst new file mode 100644 index 000000000000..750edcc13b79 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/README.rst @@ -0,0 +1,84 @@ +================================================= +ITA - Fattura elettronica - Integrazione ritenuta +================================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_out_wt + :alt: OCA/l10n-italy +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_out_wt + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/122/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Modulo ponte tra emissione fatture elettroniche e ritenute. + +Con questo modulo, l'elemento XML DatiRitenuta verrà correttamente valorizzato. + +**English** + +Bridge module within e-invoice emission and withholding tax. + +With this module, XML element DatiRitenuta will be correctly filled. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Sergio Corato + +Contributors +~~~~~~~~~~~~ + +* Sergio Corato +* Ciro Urselli + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/l10n-italy `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_fatturapa_out_wt/__init__.py b/l10n_it_fatturapa_out_wt/__init__.py new file mode 100644 index 000000000000..78369e77d948 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import wizard diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py new file mode 100644 index 000000000000..998b39cecb91 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -0,0 +1,27 @@ +# Author(s): Andrea Colangelo (andreacolangelo@openforce.it) +# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it) +# Copyright 2018 Sergio Corato (https://efatto.it) +# Copyright 2018-2019 Lorenzo Battistini +# Copyright 2021 Ciro Urselli +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "ITA - Fattura elettronica - Integrazione " "ritenuta", + "summary": "Modulo ponte tra emissione fatture elettroniche e ritenute.", + "version": "14.0.1.0.0", + "development_status": "Beta", + "category": "Hidden", + "website": "https://github.com/OCA/l10n-italy", + "author": "Sergio Corato, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa", + "l10n_it_fatturapa_out", + "l10n_it_withholding_tax", + "l10n_it_withholding_tax_reason", + ], + "data": [ + "views/account_invoice_it_dati_ritenuta.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..1783ba4797f0 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Sergio Corato +* Ciro Urselli diff --git a/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst b/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..5d02045793b5 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +**Italiano** + +Modulo ponte tra emissione fatture elettroniche e ritenute. + +Con questo modulo, l'elemento XML DatiRitenuta verrà correttamente valorizzato. + +**English** + +Bridge module within e-invoice emission and withholding tax. + +With this module, XML element DatiRitenuta will be correctly filled. diff --git a/l10n_it_fatturapa_out_wt/static/description/icon.png b/l10n_it_fatturapa_out_wt/static/description/icon.png new file mode 100644 index 000000000000..1f07394c3b79 Binary files /dev/null and b/l10n_it_fatturapa_out_wt/static/description/icon.png differ diff --git a/l10n_it_fatturapa_out_wt/static/description/index.html b/l10n_it_fatturapa_out_wt/static/description/index.html new file mode 100644 index 000000000000..37e54814c979 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +ITA - Fattura elettronica - Integrazione ritenuta + + + +
+

ITA - Fattura elettronica - Integrazione ritenuta

+ + +

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Italiano

+

Modulo ponte tra emissione fatture elettroniche e ritenute.

+

Con questo modulo, l’elemento XML DatiRitenuta verrà correttamente valorizzato.

+

English

+

Bridge module within e-invoice emission and withholding tax.

+

With this module, XML element DatiRitenuta will be correctly filled.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Sergio Corato
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/l10n-italy project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_it_fatturapa_out_wt/tests/__init__.py b/l10n_it_fatturapa_out_wt/tests/__init__.py new file mode 100644 index 000000000000..b980725c5efc --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/__init__.py @@ -0,0 +1 @@ +from . import test_fatturapa_wt diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml new file mode 100644 index 000000000000..3fd495be61f7 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml @@ -0,0 +1,106 @@ + + + + + IT + 06363391001 + + 00011 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0013 + + RT02 + 2.00 + 20.00 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 10.20 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml new file mode 100644 index 000000000000..98e59404a04c --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml @@ -0,0 +1,112 @@ + + + + + IT + 06363391001 + + 00014 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0014 + + RT02 + 2.00 + 20.00 + A + + + RT04 + 0.83 + 8.25 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 9.37 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml new file mode 100644 index 000000000000..10540db330ee --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml @@ -0,0 +1,127 @@ + + + + + IT + 06363391001 + + 00015 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0015 + + RT02 + 2.00 + 20.00 + A + + + RT04 + 0.83 + 8.25 + A + + + TC07 + 8.25 + 0.83 + 0.00 + N2.2 + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + 0.00 + N2.2 + 0.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 9.37 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml new file mode 100644 index 000000000000..b681bab41589 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml @@ -0,0 +1,123 @@ + + + + + IT + 06363391001 + + 00016 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0016 + + RT02 + 2.00 + 20.00 + A + + + RT04 + 0.83 + 8.25 + A + + + TC07 + 8.25 + 0.83 + 0.00 + N2.2 + + 10.00 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 0.00 + SI + N2.2 + + + 0.00 + N2.2 + 10.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 7.17 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml new file mode 100644 index 000000000000..8085a287fea8 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml @@ -0,0 +1,112 @@ + + + + + IT + 06363391001 + + 00014 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0017 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 9.67 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml new file mode 100644 index 000000000000..17e4438e7fa7 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml @@ -0,0 +1,127 @@ + + + + + IT + 06363391001 + + 00015 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0018 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + + TC22 + 5.25 + 0.53 + 0.00 + N2.2 + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + 0.00 + N2.2 + 0.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 9.67 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml new file mode 100644 index 000000000000..2121e0b77bd5 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml @@ -0,0 +1,123 @@ + + + + + IT + 06363391001 + + 00016 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0019 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + + TC22 + 5.25 + 0.53 + 0.00 + N2.2 + + 10.00 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 0.00 + SI + N2.2 + + + 0.00 + N2.2 + 10.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 7.47 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py new file mode 100644 index 000000000000..b9d140d2fcde --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -0,0 +1,510 @@ +import base64 + +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon + + +class TestInvoiceWT(FatturaPACommon): + def setUp(self): + super().setUp() + + ### + # XXX this should really be in FatturaPACommon + # tested 2021/08/06 @TheMule71 + + # XXX - a company named "YourCompany" alread exists + # we move it out of the way but we should do better here + self.env.company.sudo().search([("name", "=", "YourCompany")]).write( + {"name": "YourCompany_"} + ) + self.env.company.name = "YourCompany" + self.env.company.vat = "IT06363391001" + self.env.company.fatturapa_art73 = True + self.env.company.partner_id.street = "Via Milano, 1" + self.env.company.partner_id.city = "Roma" + self.env.company.partner_id.state_id = self.env.ref("base.state_us_2").id + self.env.company.partner_id.country_id = self.env.ref("base.it").id + self.env.company.partner_id.zip = "00100" + self.env.company.partner_id.phone = "06543534343" + self.env.company.email = "info@yourcompany.example.com" + self.env.company.fatturapa_fiscal_position_id = self.env.ref( + "l10n_it_fatturapa.fatturapa_RF01" + ).id + self.env["decimal.precision"].search( + [("name", "=", "Product Unit of Measure")] + ).digits = 3 + self.env["uom.uom"].search([("name", "=", "Units")]).name = "Unit(s)" + ### + + type_payable = self.env.ref("account.data_account_type_payable") + type_receivable = self.env.ref("account.data_account_type_receivable") + self.tax_0 = ( + self.env.ref("l10n_it_fatturapa.tax_00_enas") + .sudo() + .copy({"company_id": self.env.company.id}) + ) + self.wt_account_payable = self.env["account.account"].create( + { + "name": "Debiti per ritenute da versare", + "code": "WT_001", + "user_type_id": type_payable.id, + "reconcile": True, + } + ) + self.wt_account_receivable = self.env["account.account"].create( + { + "name": "Crediti per ritenute subite", + "code": "WT_002", + "user_type_id": type_receivable.id, + "reconcile": True, + } + ) + self.journal_misc = self.env["account.journal"].search( + [("type", "=", "general")] + )[0] + vals_payment = { + "name": "", + "line_ids": [(0, 0, {"value": "balance", "days": 15})], + } + self.payment_term_15 = self.env["account.payment.term"].create(vals_payment) + wt_vals = { + "name": "Code 1040", + "code": "1040", + "certification": True, + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "payment_term": self.payment_term_15.id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 20, + "base": 1, + }, + ) + ], + } + self.wt1040 = self.env["withholding.tax"].create(wt_vals) + wt_vals = { + "name": "Enasarco", + "code": "Enasarco", + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "wt_types": "enasarco", + "payment_term": self.payment_term_15.id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 8.25, + "base": 1, + }, + ) + ], + } + self.enasarco = self.env["withholding.tax"].create(wt_vals) + wt_vals = { + "name": "INPS", + "code": "INPS", + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "wt_types": "enasarco", + "payment_term": self.payment_term_15.id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 5.25, + "base": 1, + }, + ) + ], + } + self.inps = self.env["withholding.tax"].create(wt_vals) + + def test_e_invoice_wt(self): + self.set_sequences(13, "2019-01-07") + + invoice = self.invoice_model.create( + { + "name": "INV/2019/0013", + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [(6, 0, [self.wt1040.id])], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00011.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, + "IT06363391001_00011.xml", + module_name="l10n_it_fatturapa_out_wt", + ) + + def test_e_invoice_wt_enas_0(self): + self.set_sequences(14, "2019-01-07") + invoice = self.invoice_model.create( + { + "name": "INV/2019/0014", + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00014.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, + "IT06363391001_00014.xml", + module_name="l10n_it_fatturapa_out_wt", + ) + + def test_e_invoice_wt_enas_1(self): + """ + Fill DatiCassaPrevidenziale with Enasarco data + """ + self.set_sequences(15, "2019-01-07") + self.enasarco.use_daticassaprev = True + self.enasarco.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "name": "INV/2019/0015", + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00015.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, + "IT06363391001_00015.xml", + module_name="l10n_it_fatturapa_out_wt", + ) + + def test_e_invoice_wt_enas_2(self): + """ + Fill DatiCassaPrevidenziale with Enasarco data, + when DatiRiepilogo already has 0 VAT + """ + self.set_sequences(16, "2019-01-07") + self.enasarco.use_daticassaprev = True + self.enasarco.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "name": "INV/2019/0016", + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_0.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00016.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, + "IT06363391001_00016.xml", + module_name="l10n_it_fatturapa_out_wt", + ) + + +def test_e_invoice_wt_inps_0(self): + self.set_sequences(17, "2019-01-07") + invoice = self.invoice_model.create( + { + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00017.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00017.xml", module_name="l10n_it_fatturapa_out_wt" + ) + + +def test_e_invoice_wt_inps_1(self): + """ + Fill DatiCassaPrevidenziale with INPS data + """ + self.set_sequences(18, "2019-01-07") + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00018.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00018.xml", module_name="l10n_it_fatturapa_out_wt" + ) + + +def test_e_invoice_wt_inps_2(self): + """ + Fill DatiCassaPrevidenziale with INPS data, + when DatiRiepilogo already has 0 VAT + """ + self.set_sequences(19, "2019-01-07") + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "invoice_date": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "invoice_payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "move_type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "product_uom_id": self.product_uom_unit.id, + "price_unit": 10, + "tax_ids": [(6, 0, [self.tax_0.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), + ], + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_post() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00019.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00019.xml", module_name="l10n_it_fatturapa_out_wt" + ) diff --git a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml new file mode 100644 index 000000000000..d4310470ec74 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py new file mode 100644 index 000000000000..861a0af3e6aa --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -0,0 +1,2 @@ +from . import efattura +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_wt/wizard/efattura.py b/l10n_it_fatturapa_out_wt/wizard/efattura.py new file mode 100644 index 000000000000..e5c53a8710a1 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/efattura.py @@ -0,0 +1,71 @@ +# Copyright 2021 Ciro Urselli +# Copyright 2021 Marco Colombo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tools.float_utils import float_round + +from odoo.addons.l10n_it_account.tools.account_tools import encode_for_export +from odoo.addons.l10n_it_fatturapa_out.wizard.efattura import ( + EFatturaOut as _EFatturaOut, +) + +WT_TAX_CODE = {"inps": "RT03", "enasarco": "RT04", "enpam": "RT05", "other": "RT06"} + + +class EFatturaOut(_EFatturaOut): + def get_template_values(self): + """Add/override some functions used in the template""" + + def get_withholding_type(wt_types, partner): + if wt_types == "ritenuta": + if partner.is_company: + withholding_type = "RT02" + else: + withholding_type = "RT01" + else: + withholding_type = WT_TAX_CODE[wt_types] + return withholding_type + + def get_all_taxes(record): + template_values = super(EFatturaOut, self).get_template_values() + _get_all_taxes = template_values["get_all_taxes"] + format_numbers = template_values["format_numbers"] + + all_taxes = _get_all_taxes(record) + + wt_lines_to_write = record.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types not in ("ritenuta", "other") + and x.withholding_tax_id.use_daticassaprev + ) + for wt_line in wt_lines_to_write: + tax_id = wt_line.withholding_tax_id.daticassprev_tax_id + key = "{}_{}".format("0.00", tax_id.kind_id.code) + if key in all_taxes: + base_amount = ( + float(all_taxes[key]["ImponibileImporto"]) + wt_line.tax + ) + all_taxes[key]["ImponibileImporto"] = float_round(base_amount, 2) + else: + all_taxes[key] = { + "AliquotaIVA": format_numbers(0.0), + "Natura": tax_id.kind_id.code, + # 'Arrotondamento':'', + "ImponibileImporto": float_round(wt_line.tax, 2), + "Imposta": 0.0, + "EsigibilitaIVA": tax_id.payability, + } + if tax_id.law_reference: + all_taxes[key]["RiferimentoNormativo"] = encode_for_export( + tax_id.law_reference, 100 + ) + return all_taxes + + template_values = super().get_template_values() + template_values.update( + { + "get_withholding_type": get_withholding_type, + "get_all_taxes": get_all_taxes, + } + ) + + return template_values diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py new file mode 100644 index 000000000000..0c3dfd42b9d4 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -0,0 +1,10 @@ +from odoo import models + +from .efattura import EFatturaOut + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + def _get_efattura_class(self): + return EFatturaOut diff --git a/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt b/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt new file mode 120000 index 000000000000..9a62739d02d7 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt @@ -0,0 +1 @@ +../../../../l10n_it_fatturapa_out_wt \ No newline at end of file diff --git a/setup/l10n_it_fatturapa_out_wt/setup.py b/setup/l10n_it_fatturapa_out_wt/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_wt/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)