diff --git a/l10n_it_fatturapa_out/wizard/efattura.py b/l10n_it_fatturapa_out/wizard/efattura.py index 7da0768df501..8fefffa132d8 100644 --- a/l10n_it_fatturapa_out/wizard/efattura.py +++ b/l10n_it_fatturapa_out/wizard/efattura.py @@ -177,11 +177,9 @@ def get_all_taxes(record): return wiz.getAllTaxes(record) def get_importo(line): - str_number = str(line.discount) - number = str_number[::-1].find(".") - if number <= 2: - return False - return line.price_unit * line.discount / 100 + # wrapper to a method in wizard (for better overriding) + wiz = self.env["wizard.export.fatturapa"] + return wiz.getImporto(line) def get_importo_totale(invoice): # wrapper to a method in wizard (for better overriding) diff --git a/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py index a66be30be421..d33c09852001 100644 --- a/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py @@ -105,6 +105,14 @@ def __init__(self, date_maturity, amount_currency, debit): ) return payments + @api.model + def getImporto(self, line): + str_number = str(line.discount) + number = str_number[::-1].find(".") + if number <= 2: + return False + return line.price_unit * line.discount / 100 + @api.model def getImportoTotale(self, invoice): """Entry point for other modules to override computation of diff --git a/l10n_it_fatturapa_out_fd/README.rst b/l10n_it_fatturapa_out_fd/README.rst new file mode 100644 index 000000000000..a12cf5f13293 --- /dev/null +++ b/l10n_it_fatturapa_out_fd/README.rst @@ -0,0 +1,84 @@ +==================================================== +ITA - Fattura elettronica - Emissione - Sconto fisso +==================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7fec8e7baf6822cef32b57f070a3692bc15eaebb8df93ab1f7b212799c0bd350 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/l10n_it_fatturapa_out_fd + :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-14-0/l10n-italy-14-0-l10n_it_fatturapa_out_fd + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Modulo tecnico di integrazione tra account_invoice_fixed_discount e l10n_it_fatturapa_out. + +**English** + +Technical module for integrating account_invoice_fixed_discount and l10n_it_fatturapa_out. + +**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 +~~~~~~~ + +* TAKOBI + +Contributors +~~~~~~~~~~~~ + +* `TAKOBI `_: + + * Simone Rubino + +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_fd/__init__.py b/l10n_it_fatturapa_out_fd/__init__.py new file mode 100644 index 000000000000..a370c4dcb918 --- /dev/null +++ b/l10n_it_fatturapa_out_fd/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizards diff --git a/l10n_it_fatturapa_out_fd/__manifest__.py b/l10n_it_fatturapa_out_fd/__manifest__.py new file mode 100644 index 000000000000..9ad6e0f140e9 --- /dev/null +++ b/l10n_it_fatturapa_out_fd/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 Simone Rubino - TAKOBI +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "ITA - Fattura elettronica - Emissione - Sconto fisso", + "version": "14.0.1.0.0", + "category": "Localization/Italy", + "summary": "Emissione di fattura elettronica con sconto fisso", + "author": "TAKOBI, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-italy" + "/tree/12.0/l10n_it_fatturapa_out_fd", + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa_out", + "account_invoice_fixed_discount", + ], + "auto_install": True, +} diff --git a/l10n_it_fatturapa_out_fd/i18n/it.po b/l10n_it_fatturapa_out_fd/i18n/it.po new file mode 100644 index 000000000000..2db3bbb247bf --- /dev/null +++ b/l10n_it_fatturapa_out_fd/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_fd +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-29 12:22+0000\n" +"Last-Translator: mymage \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_fd +#: model:ir.model,name:l10n_it_fatturapa_out_fd.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "Esporta e-fattura" diff --git a/l10n_it_fatturapa_out_fd/i18n/l10n_it_fatturapa_out_fd.pot b/l10n_it_fatturapa_out_fd/i18n/l10n_it_fatturapa_out_fd.pot new file mode 100644 index 000000000000..b5261c0c10ee --- /dev/null +++ b/l10n_it_fatturapa_out_fd/i18n/l10n_it_fatturapa_out_fd.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_fd +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_fd +#: model:ir.model,name:l10n_it_fatturapa_out_fd.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + diff --git a/l10n_it_fatturapa_out_fd/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_fd/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..37ec1fc1ea73 --- /dev/null +++ b/l10n_it_fatturapa_out_fd/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `TAKOBI `_: + + * Simone Rubino diff --git a/l10n_it_fatturapa_out_fd/readme/DESCRIPTION.rst b/l10n_it_fatturapa_out_fd/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..d97fcb7d42ce --- /dev/null +++ b/l10n_it_fatturapa_out_fd/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +**Italiano** + +Modulo tecnico di integrazione tra account_invoice_fixed_discount e l10n_it_fatturapa_out. + +**English** + +Technical module for integrating account_invoice_fixed_discount and l10n_it_fatturapa_out. diff --git a/l10n_it_fatturapa_out_fd/static/description/icon.png b/l10n_it_fatturapa_out_fd/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_fatturapa_out_fd/static/description/icon.png differ diff --git a/l10n_it_fatturapa_out_fd/static/description/index.html b/l10n_it_fatturapa_out_fd/static/description/index.html new file mode 100644 index 000000000000..c68f1b49b42f --- /dev/null +++ b/l10n_it_fatturapa_out_fd/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +ITA - Fattura elettronica - Emissione - Sconto fisso + + + +
+

ITA - Fattura elettronica - Emissione - Sconto fisso

+ + +

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

+

Italiano

+

Modulo tecnico di integrazione tra account_invoice_fixed_discount e l10n_it_fatturapa_out.

+

English

+

Technical module for integrating account_invoice_fixed_discount and l10n_it_fatturapa_out.

+

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

+
    +
  • TAKOBI
  • +
+
+
+

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_fd/tests/__init__.py b/l10n_it_fatturapa_out_fd/tests/__init__.py new file mode 100644 index 000000000000..9d250ab0268f --- /dev/null +++ b/l10n_it_fatturapa_out_fd/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_xml_generation diff --git a/l10n_it_fatturapa_out_fd/tests/data/IT06363391001_00001.xml b/l10n_it_fatturapa_out_fd/tests/data/IT06363391001_00001.xml new file mode 100644 index 000000000000..638b57363d4c --- /dev/null +++ b/l10n_it_fatturapa_out_fd/tests/data/IT06363391001_00001.xml @@ -0,0 +1,94 @@ + + + + + IT + 06363391001 + + 00001 + 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 + 2020-01-01 + INV/2020/01/0001 + 1195.60 + SI + + + + + 1 + Test fixed discount + 1.000 + 1000.00000 + + SC + 20.00 + + 980.00 + 22.00 + + + 22.00 + 980.00 + 215.60 + + + + diff --git a/l10n_it_fatturapa_out_fd/tests/test_xml_generation.py b/l10n_it_fatturapa_out_fd/tests/test_xml_generation.py new file mode 100644 index 000000000000..f11c700889ab --- /dev/null +++ b/l10n_it_fatturapa_out_fd/tests/test_xml_generation.py @@ -0,0 +1,80 @@ +# Copyright 2023 Simone Rubino - TAKOBI +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import base64 + +from odoo.tests import Form, tagged + +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon + + +@tagged("post_install", "-at_install") +class TestXMLGeneration(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 test_fixed_discount(self): + """Generate an e-invoice for an invoice having a fixed discount. + Check that the ScontoMaggiorazione is present in the generated e-invoice. + """ + # Setup for fixing date and sequence of new invoices + date_invoice = "2020-01-01" + self.set_sequences(1, date_invoice) + + # Arrange: Create an invoice with one line costing 100 + # and fixed discount of 20 + invoice_form = Form( + self.env["account.move"].with_context(default_move_type="out_invoice") + ) + invoice_form.partner_id = self.res_partner_fatturapa_2 + invoice_form.invoice_date = date_invoice + with invoice_form.invoice_line_ids.new() as line: + line.name = "Test fixed discount" + line.price_unit = 1000 + line.quantity = 1 + line.discount_fixed = 20 + line.account_id = self.a_sale + line.tax_ids.clear() + line.tax_ids.add(self.tax_22) + invoice = invoice_form.save() + invoice._post() + # pre-condition: Check invoice totals + self.assertEqual(invoice.amount_untaxed, 980) + self.assertEqual(invoice.amount_tax, 215.6) + self.assertAlmostEqual(invoice.amount_total, 1195.6, 2) + + # Act: Generate the e-invoice + action = self.run_wizard(invoice.id) + e_invoice = self.env[action["res_model"]].browse(action["res_id"]) + + # Assert: The E-invoice matches the XML in tests data + file_name = "IT06363391001_00001.xml" + self.set_e_invoice_file_id(e_invoice, file_name) + xml_content = base64.decodebytes(e_invoice.datas) + self.check_content( + xml_content, + file_name, + module_name="l10n_it_fatturapa_out_fd", + ) diff --git a/l10n_it_fatturapa_out_fd/wizards/__init__.py b/l10n_it_fatturapa_out_fd/wizards/__init__.py new file mode 100644 index 000000000000..9c06eb6b370d --- /dev/null +++ b/l10n_it_fatturapa_out_fd/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_fd/wizards/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_fd/wizards/wizard_export_fatturapa.py new file mode 100644 index 000000000000..57dd51d40649 --- /dev/null +++ b/l10n_it_fatturapa_out_fd/wizards/wizard_export_fatturapa.py @@ -0,0 +1,16 @@ +# Copyright 2023 Simone Rubino - TAKOBI +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + @api.model + def getImporto(self, line): + res = super().getImporto(line) + discount_fixed = line.discount_fixed + if discount_fixed: + return discount_fixed + return res diff --git a/setup/l10n_it_fatturapa_out_fd/odoo/addons/l10n_it_fatturapa_out_fd b/setup/l10n_it_fatturapa_out_fd/odoo/addons/l10n_it_fatturapa_out_fd new file mode 120000 index 000000000000..2298f2a47c34 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_fd/odoo/addons/l10n_it_fatturapa_out_fd @@ -0,0 +1 @@ +../../../../l10n_it_fatturapa_out_fd \ No newline at end of file diff --git a/setup/l10n_it_fatturapa_out_fd/setup.py b/setup/l10n_it_fatturapa_out_fd/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_fd/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)