Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from odoo import _, api, models
from odoo.exceptions import ValidationError
from odoo.tools.float_utils import float_compare
from odoo.tools import float_is_zero


def get_xmlid(id_str):
Expand Down Expand Up @@ -158,11 +158,11 @@ def compute_data_for_report(self, wizard_data):
digits = curr.decimal_places
if not digits:
digits = self.env["decimal.precision"].precision_get("Account")
total_balance = 0
if float_compare(total_credit, total_debit, digits) == 1:
total_balance = total_credit - total_debit
elif float_compare(total_credit, total_debit, digits) == -1:
total_balance = total_debit - total_credit
total_balance = abs(total_credit - total_debit)
if float_is_zero(total_balance, digits):
# backward compatibility: this was a side effect of previous code
# total_balance is rounded only if zero
total_balance = 0

# Preserve generic data like accounts_data and similar
report_data = trial_balance_data
Expand All @@ -173,6 +173,8 @@ def compute_data_for_report(self, wizard_data):
"section_credit_ids": section_credit_vals,
"section_debit_ids": section_debit_vals,
"title": cols["title"],
"surplus": cols["surplus"],
"deficit": cols["deficit"],
"total_balance": total_balance,
"total_credit": total_credit,
"total_debit": total_debit,
Expand All @@ -196,6 +198,8 @@ def get_column_data(self):
"name": _("LIABILITIES"),
},
"title": _("BALANCE SHEET"),
"surplus": _("SURPLUS"),
"deficit": _("DEFICT"),
Comment on lines +201 to +202
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qui deve fare il contrario.
Nel balance sheet
se credit>debit il saldo è un deficit (nella colonna sinistra)
se credit>debit il saldo è un surplus (nella colonna di destra)

Basta che modifico così?
"surplus": _("DEFICIT"),
"deficit": _("SURPLUS"),

},
"profit_loss": {
"left": {
Expand All @@ -207,6 +211,8 @@ def get_column_data(self):
"name": _("REVENUES"),
},
"title": _("PROFIT & LOSS"),
"surplus": _("PROFIT"),
"deficit": _("LOSS"),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,12 @@ def write_sections_balance(self, report, data, report_data, report_result):

def write_total_balance(self, report, data, report_data, report_result):
"""Writes total balance row"""
rep_type = data.get("financial_statements_report_type")
cols = (
self.env["report.l10n_it_financial_statements_report.report"]
.get_column_data()
.get(rep_type)
)
lang_code = data["account_financial_report_lang"]
lang = get_lang(self.env, lang_code=lang_code)
currency = report_data["financial_statements_report_currency"]
Expand All @@ -665,12 +671,17 @@ def write_total_balance(self, report, data, report_data, report_result):
)
total_credit = report_result["total_credit"]
total_debit = report_result["total_debit"]
surplus = float_compare(total_credit, total_debit, decimals) == 1
deficit = float_compare(total_credit, total_debit, decimals) == -1
if surplus or deficit:
title = _("SURPLUS") if surplus else _("DEFICIT")

_cmp = float_compare(total_credit, total_debit, decimals)
if _cmp != 0:
bal_data = order_currency_amount(currency, balance)
balance_str = f"{title}: {bal_data[0]} {bal_data[1]}"
balance_str_left = (
f"{cols['surplus']}: {bal_data[0]} {bal_data[1]}" if _cmp == 1 else ""
)
balance_str_right = (
f"{cols['deficit']}: {bal_data[0]} {bal_data[1]}" if _cmp == -1 else ""
)

left_columns = _extract_financial_statements_report_columns(
report_data["columns"], "left"
)
Expand All @@ -679,7 +690,7 @@ def write_total_balance(self, report, data, report_data, report_result):
min(left_columns.keys()),
report_data["row_pos"],
max(left_columns.keys()),
balance_str if surplus else "",
balance_str_left,
report_data["formats"]["format_header_amount_right"],
)
right_columns = _extract_financial_statements_report_columns(
Expand All @@ -690,7 +701,7 @@ def write_total_balance(self, report, data, report_data, report_result):
min(right_columns.keys()),
report_data["row_pos"],
max(right_columns.keys()),
balance_str if deficit else "",
balance_str_right,
report_data["formats"]["format_header_amount_right"],
)
report_data["row_pos"] += 1
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@
<span
style="font-size: 14px; margin-right: 4px; text-align: right; font-weight: bold;"
>
SURPLUS: <t
<t t-out="surplus" /> <t
t-out="total_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
Expand All @@ -546,7 +546,7 @@
<span
style="font-size: 14px; margin-right: 4px; text-align: right; font-weight: bold;"
>
DEFICIT: <t
<t t-out="deficit" /> <t
t-out="total_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
Expand Down
Loading