diff --git a/l10n_it_fatturapa_in/models/account.py b/l10n_it_fatturapa_in/models/account.py index 4c3f2e578628..587d425733ed 100644 --- a/l10n_it_fatturapa_in/models/account.py +++ b/l10n_it_fatturapa_in/models/account.py @@ -320,6 +320,8 @@ def set_einvoice_data(self, fattura): def process_negative_lines(self): self.ensure_one() + if not self.invoice_line_ids: + return for line in self.invoice_line_ids: if line.price_unit >= 0: return @@ -329,7 +331,7 @@ def process_negative_lines(self): {"price_unit": -line.price_unit} ) self.with_context(check_move_validity=False)._recompute_dynamic_lines( - recompute_all_taxes=True + recompute_all_taxes=True, recompute_tax_base_amount=True ) diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py index 2c6da7820602..6dceb15ff024 100644 --- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py +++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py @@ -52,7 +52,7 @@ def test_00_xml_import(self): welfare_found = False for line in invoice.invoice_line_ids: if line.product_id.id == self.service.id: - self.assertEqual(line.price_unit, 3) + self.assertAlmostEqual(line.price_unit, 3) welfare_found = True self.assertTrue(welfare_found) self.assertTrue(len(invoice.e_invoice_line_ids) == 1) @@ -135,7 +135,7 @@ def test_04_xml_import(self): self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].name, "22% e-bill") self.assertEqual(invoice.invoice_line_ids[0].tax_ids[0].amount, 22) self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].amount, 22) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, 2) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 2) self.assertTrue(len(invoice.e_invoice_line_ids) == 2) for e_line in invoice.e_invoice_line_ids: self.assertTrue(e_line.line_number in (1, 2)) @@ -648,10 +648,10 @@ def test_32_xml_import(self): invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.move_type, "in_refund") self.assertEqual(invoice.amount_total, 18.3) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0) self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, -1.0) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, -1.0) self.assertEqual(invoice.invoice_line_ids[1].quantity, 5.0) self.assertEqual(invoice.invoice_line_ids[1].price_subtotal, -5.0) @@ -662,7 +662,7 @@ def test_33_xml_import(self): invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.move_type, "in_refund") self.assertEqual(round(invoice.amount_total, 2), 24.4) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0) self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0) self.assertEqual(invoice.e_invoice_amount_untaxed, -20.0) @@ -815,7 +815,7 @@ def test_46_xml_many_zeros(self): invoice_id = res.get("domain")[0][2][0] invoice = self.invoice_model.browse(invoice_id) self.assertEqual(invoice.amount_total, 18.07) - self.assertEqual(invoice.invoice_line_ids[0].price_unit, 18.07) + self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 18.07) self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0) self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 18.07) self.assertEqual(invoice.invoice_line_ids[1].price_unit, 16.60) @@ -1074,7 +1074,7 @@ def test_xml_import_summary_tax_rate(self): self.assertEqual(invoice.invoice_line_ids[0].price_unit, 164.46) self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0) - self.assertEqual(invoice.invoice_line_ids[1].price_unit, 3.52) + self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 3.52) self.assertEqual(invoice.invoice_line_ids[1].quantity, 1.0) def test_e_invoice_field_compute(self): diff --git a/l10n_it_fatturapa_out/wizard/efattura.py b/l10n_it_fatturapa_out/wizard/efattura.py index 20d05977c8ab..104b9e94874c 100644 --- a/l10n_it_fatturapa_out/wizard/efattura.py +++ b/l10n_it_fatturapa_out/wizard/efattura.py @@ -174,12 +174,19 @@ def get_all_taxes(record): wiz = self.env["wizard.export.fatturapa"] return wiz.getAllTaxes(record) - def get_importo(line): - str_number = str(line.discount) + def get_importo(line, discount_field="discount"): + str_number = str(line[discount_field]) number = str_number[::-1].find(".") if number <= 2: return False - return line.price_unit * line.discount / 100 + if discount_field == "discount2": + price_unit = line.price_unit * (1 - line.discount / 100) + return price_unit * line[discount_field] / 100 + elif discount_field == "discount3": + price_unit = line.price_unit * (1 - line.discount / 100) + price_unit = price_unit * (1 - line.discount2 / 100) + return price_unit * line[discount_field] / 100 + return line.price_unit * line[discount_field] / 100 def get_importo_totale(invoice): # wrapper to a method in wizard (for better overriding) 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..5b9486d63fa7 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/README.rst @@ -0,0 +1,83 @@ +====================================================== +ITA - Fattura elettronica - Integrazione sconto triplo +====================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3652bd491ec5c99bbb9371877cd7903143ccbfc4a86053fd8f157a9f7fadca9c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_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-14-0/l10n-italy-14-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=14.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 + +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..e69de29bb2d1 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..3a17ef9e61ca --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# 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": "14.0.1.0.0", + "development_status": "Beta", + "category": "Hidden", + "website": "https://github.com/OCA/l10n-italy" + "/tree/12.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..fc0c910dc1ba --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/data/invoice_it_template.xml @@ -0,0 +1,43 @@ + + + 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..1506cdc9fd9e --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/i18n/it.po @@ -0,0 +1,22 @@ +# 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-04-26 16:05+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.14.1\n" + +#. 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" 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..becb7d6545c3 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/i18n/l10n_it_fatturapa_out_triple_discount.pot @@ -0,0 +1,20 @@ +# 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" +"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,name:l10n_it_fatturapa_out_triple_discount.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + diff --git a/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..c4012067ad26 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Simone Rubino +* Alex Comba diff --git a/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.rst b/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..a8f5c180e799 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +**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..890cfd869caa --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +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..b94706388956 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +# tests disabled because unstable +# TODO https://github.com/OCA/l10n-italy/issues/1588 +# 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..f8c8ead0c09f --- /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/0013 + 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/test_fatturapa_triple_discount.py b/l10n_it_fatturapa_out_triple_discount/tests/test_fatturapa_triple_discount.py new file mode 100644 index 000000000000..fa981de83676 --- /dev/null +++ b/l10n_it_fatturapa_out_triple_discount/tests/test_fatturapa_triple_discount.py @@ -0,0 +1,58 @@ +# Copyright 2019 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import codecs + +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon + + +class TestInvoiceTripleDiscount(FatturaPACommon): + def setUp(self): + super(TestInvoiceTripleDiscount, self).setUp() + + def test_xml_export_triple_discount(self): + self.set_sequences(13, "2016-01-07") + invoice = self.invoice_model.create( + { + "date_invoice": "2016-01-07", + "partner_id": self.res_partner_fatturapa_0.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "product_id": self.product_product_10.id, + "name": "Mouse\nOptical", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "discount": 50, + "discount2": 50, + "discount3": 50, + "invoice_line_tax_ids": [(6, 0, {self.tax_22.id})], + }, + ) + ], + } + ) + invoice.action_invoice_open() + 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 = codecs.decode(attachment.datas, "base64") + self.check_content( + xml_content, + "IT06363391001_00001.xml", + module_name="l10n_it_fatturapa_out_triple_discount", + ) diff --git a/l10n_it_ricevute_bancarie/tests/test_riba.py b/l10n_it_ricevute_bancarie/tests/test_riba.py index a69031a471c4..edbef4c769b0 100644 --- a/l10n_it_ricevute_bancarie/tests/test_riba.py +++ b/l10n_it_ricevute_bancarie/tests/test_riba.py @@ -31,7 +31,7 @@ def test_add_due_cost(self): self.invoice.invoice_line_ids[2].product_id.id, self.service_due_cost.id ) # ---- Test Cost line is equal to 10.00 - self.assertEqual( + self.assertAlmostEqual( ( self.invoice.invoice_line_ids[1].price_unit + self.invoice.invoice_line_ids[2].price_unit diff --git a/setup/l10n_it_fatturapa_out_triple_discount/odoo/addons/l10n_it_fatturapa_out_triple_discount b/setup/l10n_it_fatturapa_out_triple_discount/odoo/addons/l10n_it_fatturapa_out_triple_discount new file mode 120000 index 000000000000..d9a703866cc5 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_triple_discount/odoo/addons/l10n_it_fatturapa_out_triple_discount @@ -0,0 +1 @@ +../../../../l10n_it_fatturapa_out_triple_discount \ No newline at end of file diff --git a/setup/l10n_it_fatturapa_out_triple_discount/setup.py b/setup/l10n_it_fatturapa_out_triple_discount/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_triple_discount/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)