Skip to content

Commit

Permalink
Merge PR #4120 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by eLBati
  • Loading branch information
OCA-git-bot committed Jul 5, 2024
2 parents c684d7c + 231ddfd commit 6e54e87
Show file tree
Hide file tree
Showing 11 changed files with 731 additions and 0 deletions.
85 changes: 85 additions & 0 deletions l10n_it_withholding_tax_financial_report/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/l10n-italy/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 <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_withholding_tax_financial_report%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-eLBati|

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_withholding_tax_financial_report>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions l10n_it_withholding_tax_financial_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import report
23 changes: 23 additions & 0 deletions l10n_it_withholding_tax_financial_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
3 changes: 3 additions & 0 deletions l10n_it_withholding_tax_financial_report/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Lorenzo Battistini <https://www.innovyou.co/>
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions l10n_it_withholding_tax_financial_report/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import open_items
from . import open_items_xlsx
70 changes: 70 additions & 0 deletions l10n_it_withholding_tax_financial_report/report/open_items.py
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions l10n_it_withholding_tax_financial_report/report/open_items_xlsx.py
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="report_open_items_lines_header_wt"
inherit_id="account_financial_report.report_open_items_lines_header"
>
<xpath expr="//div[@style='width: 15.07%;']" position="attributes">
<attribute name="style">width:11.93%</attribute>
</xpath>
<xpath expr="//div[@style='width: 24.5%;']" position="attributes">
<attribute name="style">width:14.5%</attribute>
</xpath>
<xpath expr="//t[@t-if='foreign_currency']" position="after">
<div class="act_as_cell" style="width: 6.57%;">Net to pay</div>
<div class="act_as_cell" style="width: 6.57%;">Residual net to pay</div>
</xpath>
</template>
<template
id="report_open_items_lines_wt"
inherit_id="account_financial_report.report_open_items_lines"
>
<xpath expr="//t[@t-if='foreign_currency']" position="after">
<div class="act_as_cell amount">
<span
t-if="line.get('amount_net_pay', False)"
t-esc="line['amount_net_pay']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<div class="act_as_cell amount">
<span
t-if="line.get('amount_net_pay_residual', False)"
t-esc="line['amount_net_pay_residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</xpath>
</template>
<template
id="report_open_items_ending_cumul_wt"
inherit_id="account_financial_report.report_open_items_ending_cumul"
>
<xpath expr="//div[hasclass('act_as_row')]/t[1]/div[1]" position="attributes">
<attribute name="style">width:23.2%</attribute>
</xpath>
<xpath expr="//div[hasclass('act_as_row')]/t[2]/div[1]" position="attributes">
<attribute name="style">width:23.2%</attribute>
</xpath>
<xpath expr="//t[@t-if='foreign_currency']" position="after">
<div class="act_as_cell amount" style="width: 6.57%;" />
<div class="act_as_cell amount" style="width: 6.57%;">
<t t-if='type == "account_type"'>
<span
t-esc="total_amount[account_id]['amount_net_pay_residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
<t t-if='type == "partner_type"'>
<span
t-esc="total_amount[account_id][partner_id]['amount_net_pay_residual']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
</xpath>
</template>
</odoo>
Loading

0 comments on commit 6e54e87

Please sign in to comment.