diff --git a/l10n_it_withholding_tax_financial_report/README.rst b/l10n_it_withholding_tax_financial_report/README.rst new file mode 100644 index 000000000000..8fa9f0086aff --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/README.rst @@ -0,0 +1,85 @@ +============================================ +ITA - Ritenute d'acconto - Financial Reports +============================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b9ade84407d018ed04f5877cc036c0256d31d37c6e4e5d77ee66347ab4e23bf4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_withholding_tax_financial_report + :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_withholding_tax_financial_report + :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| + +Make l10n_it_withholding_tax and account_financial_report work together, +showing the correct amount (Net To Pay) in financial reports. + +**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 +------- + +* Innovyou + +Contributors +------------ + +- Lorenzo Battistini https://www.innovyou.co/ + +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-eLBati| image:: https://github.com/eLBati.png?size=40px + :target: https://github.com/eLBati + :alt: eLBati + +Current `maintainer `__: + +|maintainer-eLBati| + +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_withholding_tax_financial_report/__init__.py b/l10n_it_withholding_tax_financial_report/__init__.py new file mode 100644 index 000000000000..4c4f242fa03b --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/l10n_it_withholding_tax_financial_report/__manifest__.py b/l10n_it_withholding_tax_financial_report/__manifest__.py new file mode 100644 index 000000000000..95f3fb9cb055 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Lorenzo Battistini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "ITA - Ritenute d'acconto - Financial Reports", + "summary": "Integrazione Ritenute d'acconto e Rendiconti contabili", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Hidden", + "website": "https://github.com/OCA/l10n-italy", + "author": "Innovyou, Odoo Community Association (OCA)", + "maintainers": ["eLBati"], + "license": "AGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "depends": [ + "l10n_it_withholding_tax", + "account_financial_report", + ], + "data": [ + "report/templates/open_items.xml", + ], +} diff --git a/l10n_it_withholding_tax_financial_report/pyproject.toml b/l10n_it_withholding_tax_financial_report/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_it_withholding_tax_financial_report/readme/CONTRIBUTORS.md b/l10n_it_withholding_tax_financial_report/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..2a204463b689 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Lorenzo Battistini diff --git a/l10n_it_withholding_tax_financial_report/readme/DESCRIPTION.md b/l10n_it_withholding_tax_financial_report/readme/DESCRIPTION.md new file mode 100644 index 000000000000..77eec9886747 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Make l10n_it_withholding_tax and account_financial_report work together, +showing the correct amount (Net To Pay) in financial reports. diff --git a/l10n_it_withholding_tax_financial_report/report/__init__.py b/l10n_it_withholding_tax_financial_report/report/__init__.py new file mode 100644 index 000000000000..594ba6153132 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/report/__init__.py @@ -0,0 +1,2 @@ +from . import open_items +from . import open_items_xlsx diff --git a/l10n_it_withholding_tax_financial_report/report/open_items.py b/l10n_it_withholding_tax_financial_report/report/open_items.py new file mode 100644 index 000000000000..bf9dcd96b33a --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/report/open_items.py @@ -0,0 +1,70 @@ +from odoo import models + + +class OpenItemsReport(models.AbstractModel): + _inherit = "report.account_financial_report.open_items" + + def _get_net_pay_amounts(self, move_line, original): + amount_net_pay = original + move_line.withholding_tax_amount + amount_net_pay_residual = amount_net_pay + reconciled_amls = move_line.mapped("matched_debit_ids.debit_move_id") + for line in reconciled_amls: + if not line.withholding_tax_generated_by_move_id: + amount_net_pay_residual += line.debit or line.credit + amount_net_pay_residual = amount_net_pay_residual + return amount_net_pay, amount_net_pay_residual + + def _get_data( + self, + account_ids, + partner_ids, + date_at_object, + only_posted_moves, + company_id, + date_from, + ): + res = super()._get_data( + account_ids, + partner_ids, + date_at_object, + only_posted_moves, + company_id, + date_from, + ) + for move_line_vals in res[0]: + move_line = self.env["account.move.line"].browse(move_line_vals["id"]) + if move_line.move_id.withholding_tax: + amount_net_pay, amount_net_pay_residual = self._get_net_pay_amounts( + move_line, move_line_vals["original"] + ) + move_line_vals["amount_net_pay"] = amount_net_pay + move_line_vals["amount_net_pay_residual"] = amount_net_pay_residual + else: + move_line_vals["amount_net_pay"] = move_line_vals.get("original") + move_line_vals["amount_net_pay_residual"] = move_line_vals.get( + "amount_residual" + ) + return res + + def _calculate_amounts(self, open_items_move_lines_data): + total_amount = super()._calculate_amounts(open_items_move_lines_data) + for account_id in total_amount: + total_amount[account_id]["amount_net_pay_residual"] = 0.0 + for partner_id in open_items_move_lines_data[account_id].keys(): + total_amount[account_id][partner_id]["amount_net_pay_residual"] = 0.0 + for move_line_vals in open_items_move_lines_data[account_id][ + partner_id + ]: + move_line = self.env["account.move.line"].browse( + move_line_vals["id"] + ) + _, amount_net_pay_residual = self._get_net_pay_amounts( + move_line, move_line_vals["original"] + ) + total_amount[account_id][partner_id][ + "amount_net_pay_residual" + ] += amount_net_pay_residual + total_amount[account_id][ + "amount_net_pay_residual" + ] += amount_net_pay_residual + return total_amount diff --git a/l10n_it_withholding_tax_financial_report/report/open_items_xlsx.py b/l10n_it_withholding_tax_financial_report/report/open_items_xlsx.py new file mode 100644 index 000000000000..4645803f8125 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/report/open_items_xlsx.py @@ -0,0 +1,54 @@ +from odoo import _, models + + +class OpenItemsXslx(models.AbstractModel): + _inherit = "report.a_f_r.report_open_items_xlsx" + + def _get_report_columns(self, report): + res = super()._get_report_columns(report) + last_index = list(res.keys())[-1] + net_pay_index = last_index + 1 + residual_net_pay_index = net_pay_index + 1 + net_to_pay = { + net_pay_index: { + "header": _("Net to pay"), + "field": "amount_net_pay", + "type": "amount", + "width": 14, + }, + residual_net_pay_index: { + "header": _("Residual net to pay"), + "field": "amount_net_pay_residual", + "field_final_balance": "amount_net_pay_residual", + "type": "amount", + "width": 14, + }, + } + res.update(net_to_pay) + return res + + def write_ending_balance_from_dict( + self, + my_object, + type_object, + total_amount, + report_data, + account_id=False, + partner_id=False, + ): + if type_object == "partner": + my_object["amount_net_pay_residual"] = total_amount[account_id][partner_id][ + "amount_net_pay_residual" + ] + elif type_object == "account": + my_object["amount_net_pay_residual"] = total_amount[account_id][ + "amount_net_pay_residual" + ] + return super().write_ending_balance_from_dict( + my_object, + type_object, + total_amount, + report_data, + account_id=account_id, + partner_id=partner_id, + ) diff --git a/l10n_it_withholding_tax_financial_report/report/templates/open_items.xml b/l10n_it_withholding_tax_financial_report/report/templates/open_items.xml new file mode 100644 index 000000000000..89fa8e35f57a --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/report/templates/open_items.xml @@ -0,0 +1,67 @@ + + + + + + diff --git a/l10n_it_withholding_tax_financial_report/static/description/index.html b/l10n_it_withholding_tax_financial_report/static/description/index.html new file mode 100644 index 000000000000..edf947171565 --- /dev/null +++ b/l10n_it_withholding_tax_financial_report/static/description/index.html @@ -0,0 +1,423 @@ + + + + + +ITA - Ritenute d'acconto - Financial Reports + + + +
+

ITA - Ritenute d’acconto - Financial Reports

+ + +

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

+

Make l10n_it_withholding_tax and account_financial_report work together, +showing the correct amount (Net To Pay) in financial reports.

+

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

+
    +
  • Innovyou
  • +
+
+
+

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:

+

eLBati

+

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.

+
+
+
+ +