From c8620a442f6f3efcb785df71d1f9ddca84c884f5 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Mon, 18 Nov 2024 16:42:15 +0100 Subject: [PATCH] [14.0][FIX] l10n_it_financial_statements_report P&L balance for period --- .../report/__init__.py | 1 + .../report/trial_balance.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 l10n_it_financial_statements_report/report/trial_balance.py diff --git a/l10n_it_financial_statements_report/report/__init__.py b/l10n_it_financial_statements_report/report/__init__.py index bbf1b4015a88..9e818a6394d5 100644 --- a/l10n_it_financial_statements_report/report/__init__.py +++ b/l10n_it_financial_statements_report/report/__init__.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import trial_balance from . import financial_statements_report from . import financial_statements_report_xlsx diff --git a/l10n_it_financial_statements_report/report/trial_balance.py b/l10n_it_financial_statements_report/report/trial_balance.py new file mode 100644 index 000000000000..f2237dbcf46b --- /dev/null +++ b/l10n_it_financial_statements_report/report/trial_balance.py @@ -0,0 +1,34 @@ +from odoo import api, models + + +class TrialBalanceReport(models.AbstractModel): + _inherit = "report.account_financial_report.trial_balance" + + @api.model + def _compute_account_amount( + self, total_amount, tb_initial_acc, tb_period_acc, foreign_currency + ): + for tb in tb_period_acc: + acc_id = tb["account_id"][0] + total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency) + total_amount[acc_id]["credit"] = tb["credit"] + total_amount[acc_id]["debit"] = tb["debit"] + total_amount[acc_id]["balance"] = tb["balance"] + total_amount[acc_id]["initial_balance"] = 0.0 + for tb in tb_initial_acc: + acc_id = tb["account_id"] + if tb["account_internal_group"] in ["expense", "income"]: + continue + if acc_id not in total_amount.keys(): + total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency) + else: + total_amount[acc_id]["initial_balance"] = tb["balance"] + total_amount[acc_id]["ending_balance"] += tb["balance"] + if foreign_currency: + total_amount[acc_id]["initial_currency_balance"] = round( + tb["amount_currency"], 2 + ) + total_amount[acc_id]["ending_currency_balance"] += round( + tb["amount_currency"], 2 + ) + return total_amount