From f076575b43f30740b30bc1026ad6a905e4926f2b Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Tue, 18 Jun 2024 16:56:53 +0200 Subject: [PATCH 1/2] [REF] l10n_it_fatturapa_in_rc: Allow to override RC line detection --- l10n_it_fatturapa_in_rc/wizard/wizard_import_fatturapa.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_in_rc/wizard/wizard_import_fatturapa.py b/l10n_it_fatturapa_in_rc/wizard/wizard_import_fatturapa.py index fd767ab72ea1..c63c907ddf4f 100644 --- a/l10n_it_fatturapa_in_rc/wizard/wizard_import_fatturapa.py +++ b/l10n_it_fatturapa_in_rc/wizard/wizard_import_fatturapa.py @@ -4,10 +4,14 @@ class WizardImportFatturapa(models.TransientModel): _inherit = "wizard.import.fatturapa" + def _is_in_reverse_charge_line(self, line): + """The e-invoice line `line` should be imported as reverse charge.""" + return float(line.AliquotaIVA) == 0.0 and line.Natura.startswith("N6") + def _prepare_generic_line_data(self, line): retLine = {} account_tax_model = self.env["account.tax"] - if float(line.AliquotaIVA) == 0.0 and line.Natura.startswith("N6"): + if self._is_in_reverse_charge_line(line): # search reversed tax account_rc_type_tax = self.env["account.rc.type.tax"].search( [("rc_type_id.e_invoice_suppliers", "=", True)] From e8eebf7032bbd205d0d545d46d1452b71dffb68a Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Tue, 18 Jun 2024 17:21:53 +0200 Subject: [PATCH 2/2] [ADD] l10n_it_fatturapa_import_zip_in_rc --- l10n_it_fatturapa_import_zip_in_rc/README.rst | 92 ++++ .../__init__.py | 3 + .../__manifest__.py | 21 + .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 2 + .../readme/DESCRIPTION.md | 7 + .../static/description/index.html | 428 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/data/IT01234567890_FPR04.zip | Bin 0 -> 1293 bytes .../tests/test_import_zip.py | 78 ++++ .../wizards/__init__.py | 3 + .../wizards/wizard_import_fatturapa.py | 15 + 12 files changed, 653 insertions(+) create mode 100644 l10n_it_fatturapa_import_zip_in_rc/README.rst create mode 100644 l10n_it_fatturapa_import_zip_in_rc/__init__.py create mode 100644 l10n_it_fatturapa_import_zip_in_rc/__manifest__.py create mode 100644 l10n_it_fatturapa_import_zip_in_rc/pyproject.toml create mode 100644 l10n_it_fatturapa_import_zip_in_rc/readme/CONTRIBUTORS.md create mode 100644 l10n_it_fatturapa_import_zip_in_rc/readme/DESCRIPTION.md create mode 100644 l10n_it_fatturapa_import_zip_in_rc/static/description/index.html create mode 100644 l10n_it_fatturapa_import_zip_in_rc/tests/__init__.py create mode 100644 l10n_it_fatturapa_import_zip_in_rc/tests/data/IT01234567890_FPR04.zip create mode 100644 l10n_it_fatturapa_import_zip_in_rc/tests/test_import_zip.py create mode 100644 l10n_it_fatturapa_import_zip_in_rc/wizards/__init__.py create mode 100644 l10n_it_fatturapa_import_zip_in_rc/wizards/wizard_import_fatturapa.py diff --git a/l10n_it_fatturapa_import_zip_in_rc/README.rst b/l10n_it_fatturapa_import_zip_in_rc/README.rst new file mode 100644 index 000000000000..d6f60d1df729 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/README.rst @@ -0,0 +1,92 @@ +============================================================= +ITA - Fattura elettronica - Import ZIP - Inversione contabile +============================================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4ee83522f680e9f10f6a2cf896975474912f91e12d5e1726b13fe9cca7be7961 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_import_zip_in_rc + :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_import_zip_in_rc + :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** + +Importare fatture elettroniche con inversione contabile da un file ZIP. + +**English** + +Import electronic invoices with reverse charge from a ZIP file. + +**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 +------- + +* Aion Tech + +Contributors +------------ + +- `Aion Tech `__: + + - 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. + +.. |maintainer-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px + :target: https://github.com/SirAionTech + :alt: SirAionTech + +Current `maintainer `__: + +|maintainer-SirAionTech| + +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_import_zip_in_rc/__init__.py b/l10n_it_fatturapa_import_zip_in_rc/__init__.py new file mode 100644 index 000000000000..a370c4dcb918 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/__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_import_zip_in_rc/__manifest__.py b/l10n_it_fatturapa_import_zip_in_rc/__manifest__.py new file mode 100644 index 000000000000..f9f757449edd --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "ITA - Fattura elettronica - Import ZIP - Inversione contabile", + "summary": "Importare fatture elettroniche con inversione contabile " + "da un file ZIP.", + "version": "16.0.1.0.0", + "category": "Localization/Italy", + "website": "https://github.com/OCA/l10n-italy", + "author": "Aion Tech, Odoo Community Association (OCA)", + "maintainers": [ + "SirAionTech", + ], + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa_import_zip", + "l10n_it_fatturapa_in_rc", + ], + "auto_install": True, +} diff --git a/l10n_it_fatturapa_import_zip_in_rc/pyproject.toml b/l10n_it_fatturapa_import_zip_in_rc/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_it_fatturapa_import_zip_in_rc/readme/CONTRIBUTORS.md b/l10n_it_fatturapa_import_zip_in_rc/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..9b6c1c6fd22b --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Aion Tech](https://aiontech.company/): + - Simone Rubino \<\> diff --git a/l10n_it_fatturapa_import_zip_in_rc/readme/DESCRIPTION.md b/l10n_it_fatturapa_import_zip_in_rc/readme/DESCRIPTION.md new file mode 100644 index 000000000000..57f9a49ded5b --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +**Italiano** + +Importare fatture elettroniche con inversione contabile da un file ZIP. + +**English** + +Import electronic invoices with reverse charge from a ZIP file. diff --git a/l10n_it_fatturapa_import_zip_in_rc/static/description/index.html b/l10n_it_fatturapa_import_zip_in_rc/static/description/index.html new file mode 100644 index 000000000000..7534ce4f0196 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +ITA - Fattura elettronica - Import ZIP - Inversione contabile + + + +
+

ITA - Fattura elettronica - Import ZIP - Inversione contabile

+ + +

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

+

Italiano

+

Importare fatture elettroniche con inversione contabile da un file ZIP.

+

English

+

Import electronic invoices with reverse charge from a ZIP file.

+

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

+
    +
  • Aion Tech
  • +
+
+
+

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.

+

Current maintainer:

+

SirAionTech

+

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_import_zip_in_rc/tests/__init__.py b/l10n_it_fatturapa_import_zip_in_rc/tests/__init__.py new file mode 100644 index 000000000000..d6ecc71be352 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/tests/__init__.py @@ -0,0 +1 @@ +from . import test_import_zip diff --git a/l10n_it_fatturapa_import_zip_in_rc/tests/data/IT01234567890_FPR04.zip b/l10n_it_fatturapa_import_zip_in_rc/tests/data/IT01234567890_FPR04.zip new file mode 100644 index 0000000000000000000000000000000000000000..f8c5281512e7350da6a541617a89a442e6d7429f GIT binary patch literal 1293 zcmWIWW@Zs#-~d8zziAN+P*B9nz#z_`z~C8TU}$7)Vrph?VQCQW77%1$qF0fd6B@$H zz`jpRE$#K@v@{T1TEWf0$nt`jfdNb`4fid6WFfHkdH9MMhvy~TRBKUrT5;-O^0CmC z4Q)QYZ(A?j;##aVA;ME}=AU1=C)sWvR8cwXnOC}c_x!bsJiGBe|U02t*J_sy_Zo$(AuRBbX3(j>Rfg9=JBd`KHt7Zknia$ zt>Eixj(sDw=nzZvyw5-RrvVdh^)LOzPIZ+VNGdA-7{u(c!om&SF#c8#wKp z<`SH)XvTNhLU`q&^IC`bx9N46&kH{NZ_SOyFLM7Xt!FLU|DtP-(K?fdnz~A&yMxM- zRe~1js?~=GtP+`U`{b+~4eWVv?fflud$$_YDM_++y?(RDa7o z5O6~D;-YI!SK}LIZ`+nwX<56<sk2J0C8!`8|^Wb(SxlX_wC%#X7j z{tD=%M7DBvSVVe!IuI1*TzDeHYnsVF!Ku%_A6S3zeYyUfcS~RIyj%ODm}yoJ%kCnN zw|DHGCb1SoVR)#8}E@ZpZU+nP%y zmn3kl2oroPIr+^~*B1Ln872-V@8-5xrRQdpY!9ybzR2@MneAya9c}5PuNhK3%Pwnl z_KLkJe#zi;$6%h3kl*sKX-9)!8tN$+i1fZLVA-)o>RjG6))z-l9p~V`^gecC^P-cM z_Z~gpX8pE|o#lezpv{=Eg~zMivU zUtxS?|Hm9y(adbmqzHQ))cBE|l**9emyXtJSpKQWgbsL>4|j+^TiWbQZrz zDZO+n~nCtSyV!@x}hFzV<_GXCe@1F2nj&tIF#*Uir5j}UD1#V_%zYDRj zEAKJ+)LzcW!m8G@?q-nAk@iYMY+jlB4u&?XPe8nUKIAVq_h4?Ava>eJtAR*ZdK` zl14@LL09o>PfF+Bc@kXG_iHlC-0in_aBpAo@`?GzbG_@;A}+r;zr4C( z_CKRm_5aKP-s~L49WU#2Sr`~VcIu%!{iBC~`F@MdKLX=en& MR3JSGXgLD|04B3U@&Et; literal 0 HcmV?d00001 diff --git a/l10n_it_fatturapa_import_zip_in_rc/tests/test_import_zip.py b/l10n_it_fatturapa_import_zip_in_rc/tests/test_import_zip.py new file mode 100644 index 000000000000..7d7edfa18b9e --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/tests/test_import_zip.py @@ -0,0 +1,78 @@ +# Copyright 2024 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.l10n_it_fatturapa_in.tests.fatturapa_common import FatturapaCommon + + +class TestImportZIP(FatturapaCommon): + def getFile(self, filename, module_name=None): + if module_name is None: + module_name = "l10n_it_fatturapa_import_zip_in_rc" + return super().getFile( + filename, + module_name=module_name, + ) + + @classmethod + def _setup_import_zip_in_rc_taxes(cls): + cls.sale_tax = cls.env["account.tax"].create( + { + "name": "Tax 22% Sale", + "type_tax_use": "sale", + "amount": 22, + } + ) + cls.sale_n6_1_tax = cls.env["account.tax"].create( + { + "name": "Tax 22% Sale N6.1", + "type_tax_use": "sale", + "amount": 0, + "kind_id": cls.n6_1_tax_kind.id, + } + ) + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env.company.vat = "IT02780790107" + cls.n6_1_tax_kind = cls.env.ref("l10n_it_account_tax_kind.n6_1") + cls._setup_import_zip_in_rc_taxes() + + def test_reverse_charge_out(self): + """Import a reverse charge electronic invoice created by current company, + it is not imported as reverse charge and it is a customer invoice. + """ + # Arrange + file_name = "IT01234567890_FPR04.zip" + file_path, file_content = self.getFile(file_name) + wizard_attachment_import = self.env["fatturapa.attachment.import.zip"].create( + { + "name": file_name, + "datas": file_content, + } + ) + # Act + wizard_attachment_import.action_import() + + # Assert + attachment_out = wizard_attachment_import.attachment_out_ids + self.assertEqual(len(attachment_out), 1) + self.assertFalse(wizard_attachment_import.invoice_in_ids) + + invoice = attachment_out.out_invoice_ids + self.assertEqual(invoice.move_type, "out_invoice") + self.assertRecordValues( + invoice.invoice_line_ids, + [ + { + "name": "LA DESCRIZIONE", + "tax_ids": self.sale_tax.ids, + "rc": False, + }, + { + "name": "BANCALI", + "tax_ids": self.sale_n6_1_tax.ids, + "rc": False, + }, + ], + ) diff --git a/l10n_it_fatturapa_import_zip_in_rc/wizards/__init__.py b/l10n_it_fatturapa_import_zip_in_rc/wizards/__init__.py new file mode 100644 index 000000000000..9ba144222cf0 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizard_import_fatturapa diff --git a/l10n_it_fatturapa_import_zip_in_rc/wizards/wizard_import_fatturapa.py b/l10n_it_fatturapa_import_zip_in_rc/wizards/wizard_import_fatturapa.py new file mode 100644 index 000000000000..cfe75ce4d485 --- /dev/null +++ b/l10n_it_fatturapa_import_zip_in_rc/wizards/wizard_import_fatturapa.py @@ -0,0 +1,15 @@ +# Copyright 2024 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class WizardImportFatturapa(models.TransientModel): + _inherit = "wizard.import.fatturapa" + + def _is_in_reverse_charge_line(self, line): + if self._is_import_attachment_out(): + result = False + else: + result = super()._is_in_reverse_charge_line(line) + return result