diff --git a/l10n_it_fatturapa_out_triple_discount/README.rst b/l10n_it_fatturapa_out_triple_discount/README.rst new file mode 100644 index 000000000000..f3d2fcb1cbce --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/README.rst @@ -0,0 +1,86 @@ +====================================================== +ITA - Fattura elettronica - Integrazione sconto triplo +====================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fcbf1f25b3cc5d6de7bd678b47ae99b15e5c9d65f08fb7b5c4a624f293b5320a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/l10n_it_fatturapa_out_triple_discount + :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-16-0/l10n-italy-16-0-l10n_it_fatturapa_out_triple_discount + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Questo modulo consente di generare correttamente la fattura elettronica +(XML) quando il modulo account_invoice_triple_discount è installato. + +**English** + +The module allows to use correctly generate the Electronic Invoice (XML) +when the module account_invoice_triple_discount is installed. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Agile Business Group + +Contributors +------------ + +- Simone Rubino +- Alex Comba +- Lorenzo Battistini + +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_triple_discount/__init__.py b/l10n_it_fatturapa_out_triple_discount/__init__.py new file mode 100644 index 000000000000..5cb1c49143f5 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/l10n_it_fatturapa_out_triple_discount/__manifest__.py b/l10n_it_fatturapa_out_triple_discount/__manifest__.py new file mode 100644 index 000000000000..29a681bba2fd --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "ITA - Fattura elettronica - Integrazione sconto triplo", + "summary": "Modulo ponte tra emissione " "fatture elettroniche e sconto triplo", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Hidden", + "website": "https://github.com/OCA/l10n-italy" + "/tree/16.0/l10n_it_fatturapa_out_triple_discount", + "author": "Agile Business Group, Odoo Community Association (OCA)", + "license": "AGPL-3", + "auto_install": True, + "depends": [ + "l10n_it_fatturapa_out", + "account_invoice_triple_discount", + ], + "data": [ + "data/invoice_it_template.xml", + ], +} diff --git a/l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml b/l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml new file mode 100644 index 000000000000..371212a4ba48 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/l10n_it_fatturapa_out_triple_discount/i18n/it.po b/l10n_it_fatturapa_out_triple_discount/i18n/it.po new file mode 100644 index 000000000000..30fac07095c1 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_triple_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-06 23:34+0000\n" +"Last-Translator: Francesco Foresti \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model,name:l10n_it_fatturapa_out_triple_discount.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "Esporta e-fattura" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa__id +msgid "ID" +msgstr "ID" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" diff --git a/l10n_it_fatturapa_out_triple_discount/i18n/l10n_it_fatturapa_out_triple_discount.pot b/l10n_it_fatturapa_out_triple_discount/i18n/l10n_it_fatturapa_out_triple_discount.pot new file mode 100644 index 000000000000..04a0d72e8e49 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/i18n/l10n_it_fatturapa_out_triple_discount.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_triple_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa__display_name +msgid "Display Name" +msgstr "" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model,name:l10n_it_fatturapa_out_triple_discount.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa__id +msgid "ID" +msgstr "" + +#. module: l10n_it_fatturapa_out_triple_discount +#: model:ir.model.fields,field_description:l10n_it_fatturapa_out_triple_discount.field_wizard_export_fatturapa____last_update +msgid "Last Modified on" +msgstr "" diff --git a/l10n_it_fatturapa_out_triple_discount/pyproject.toml b/l10n_it_fatturapa_out_triple_discount/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.md b/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..a203f216df91 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Simone Rubino +- Alex Comba \ +- Lorenzo Battistini diff --git a/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.md b/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.md new file mode 100644 index 000000000000..cd592a35040a --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +**Italiano** + +Questo modulo consente di generare correttamente la fattura elettronica +(XML) quando il modulo account_invoice_triple_discount è installato. + +**English** + +The module allows to use correctly generate the Electronic Invoice (XML) +when the module account_invoice_triple_discount is installed. diff --git a/l10n_it_fatturapa_out_triple_discount/static/description/icon.png b/l10n_it_fatturapa_out_triple_discount/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_fatturapa_out_triple_discount/static/description/icon.png differ diff --git a/l10n_it_fatturapa_out_triple_discount/static/description/index.html b/l10n_it_fatturapa_out_triple_discount/static/description/index.html new file mode 100644 index 000000000000..dd1c0a81e13a --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +ITA - Fattura elettronica - Integrazione sconto triplo + + + +
+

ITA - Fattura elettronica - Integrazione sconto triplo

+ + +

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

+

Italiano

+

Questo modulo consente di generare correttamente la fattura elettronica +(XML) quando il modulo account_invoice_triple_discount è installato.

+

English

+

The module allows to use correctly generate the Electronic Invoice (XML) +when the module account_invoice_triple_discount is installed.

+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Agile Business Group
  • +
+
+
+

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_triple_discount/tests/__init__.py b/l10n_it_fatturapa_out_triple_discount/tests/__init__.py new file mode 100644 index 000000000000..9b21821eb8ee --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_fatturapa_triple_discount diff --git a/l10n_it_fatturapa_out_triple_discount/tests/data/IT06363391001_00001.xml b/l10n_it_fatturapa_out_triple_discount/tests/data/IT06363391001_00001.xml new file mode 100644 index 000000000000..c87616712c12 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/data/IT06363391001_00001.xml @@ -0,0 +1,111 @@ + + + + + + IT + 06363391001 + + 00001 + FPA12 + UFPQ1O + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 00146089990 + + 00146089990 + + Public Administration + + + + Via Roma, 1 + 10100 + Torino + AK + IT + + + + + + + TD01 + EUR + 2016-01-07 + INV/2016/00001 + 1.53 + SI + + + + + 1 + Mouse Optical + 1.000 + Unit(s) + 10.00000 + + SC + 50.00 + + + SC + 50.00 + + + SC + 50.00 + + 1.25 + 22.00 + + + 22.00 + 1.25 + 0.28 + + + + TP02 + + MP05 + 2016-02-29 + 1.53 + + + + diff --git a/l10n_it_fatturapa_out_triple_discount/tests/fatturapa_common.py b/l10n_it_fatturapa_out_triple_discount/tests/fatturapa_common.py new file mode 100644 index 000000000000..f29fa63acb2e --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/fatturapa_common.py @@ -0,0 +1,39 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon + + +class Common(FatturaPACommon): + def setUp(self): + super().setUp() + + # 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.zip = "00100" + self.env.company.partner_id.phone = "06543534343" + self.env.company.email = "info@yourcompany.example.com" + self.env.company.partner_id.country_id = self.env.ref("base.it").id + 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)" + + def getFile(self, filename, module_name=None): + if module_name is None: + module_name = "l10n_it_fatturapa_out_triple_discount" + return super().getFile(filename, module_name=module_name) diff --git a/l10n_it_fatturapa_out_triple_discount/tests/test_fatturapa_triple_discount.py b/l10n_it_fatturapa_out_triple_discount/tests/test_fatturapa_triple_discount.py new file mode 100644 index 000000000000..1ca84138c233 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/test_fatturapa_triple_discount.py @@ -0,0 +1,59 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import base64 + +from odoo.tests import Form, tagged + +from .fatturapa_common import Common + + +@tagged("post_install", "-at_install") +class TestEInvoiceTripleDiscount(Common): + def test_xml_export_triple_discount(self): + partner = self.res_partner_fatturapa_0 + partner.vat = "IT00146089990" + partner.fiscalcode = "00146089990" + invoice = self.init_invoice( + "out_invoice", + invoice_date="2016-01-07", + partner=partner, + products=self.product_product_10, + taxes=self.tax_22, + currency=self.env.user.company_id.currency_id, + ) + invoice_form = Form(invoice) + invoice_form.invoice_payment_term_id = self.account_payment_term + with invoice_form.invoice_line_ids.edit(0) as line: + line.name = "Mouse\nOptical" + line.price_unit = 10 + line.discount1 = 50 + line.discount2 = 50 + line.discount3 = 50 + invoice = invoice_form.save() + invoice.action_post() + res = self.run_wizard(invoice.id) + + self.assertTrue(res) + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00001.xml") + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + xml_tree = self.get_xml_tree_from_string(xml_content) + + # Remove first discount readonly fields computed into xml_tree + # because it is not present in the expected xml + for line in xml_tree.findall(".//DettaglioLinee"): + discounts = line.findall("ScontoMaggiorazione") + if discounts: + line.remove(discounts[0]) + + expected_xml = self.getFile("IT06363391001_00001.xml")[1] + expected_xml_content = base64.decodebytes(expected_xml) + expected_xml_tree = self.get_xml_tree_from_string(expected_xml_content) + self.assertXmlTreeEqual( + xml_tree, + expected_xml_tree, + ) diff --git a/l10n_it_fatturapa_out_triple_discount/wizards/__init__.py b/l10n_it_fatturapa_out_triple_discount/wizards/__init__.py new file mode 100644 index 000000000000..9c06eb6b370d --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_triple_discount/wizards/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_triple_discount/wizards/wizard_export_fatturapa.py new file mode 100644 index 000000000000..26d0ccc3b21c --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/wizards/wizard_export_fatturapa.py @@ -0,0 +1,56 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models +from odoo.tools import float_is_zero + + +class WizardExportFatturaPA(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + def _get_efattura_class(self): + efattura_class = super()._get_efattura_class() + + class EInvoiceOutTripleDiscount(efattura_class): + def get_template_values(self): + template_values = super().get_template_values() + + format_numbers_two = template_values["format_numbers_two"] + + def get_triple_ScontoMaggiorazione_values_list(line): + ScontoMaggiorazione_values_list = [] + + discount_fields = line._get_multiple_discount_field_names() + + discounts_digits = line.fields_get( + allfields=discount_fields, + attributes=[ + "digits", + ], + ) + for discount_field in discount_fields: + discount_perc = line[discount_field] + all_digits, precision_digits = discounts_digits[discount_field][ + "digits" + ] + is_discount_zero = float_is_zero( + discount_perc, + precision_digits=precision_digits, + ) + if not is_discount_zero: + ScontoMaggiorazione_values = { + "Tipo": "SC", + "Percentuale": format_numbers_two(discount_perc), + } + ScontoMaggiorazione_values_list.append( + ScontoMaggiorazione_values + ) + return ScontoMaggiorazione_values_list + + template_values[ + "get_triple_ScontoMaggiorazione_values_list" + ] = get_triple_ScontoMaggiorazione_values_list + return template_values + + return EInvoiceOutTripleDiscount