Merge pull request #37211 from deepeshgarg007/trial_balance_net_values

feat: Toggle net values in Trial Balance report
This commit is contained in:
Deepesh Garg 2023-09-24 17:45:11 +05:30 committed by GitHub
commit 9dbb9e7515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -99,6 +99,12 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"label": __("Include Default Book Entries"),
"fieldtype": "Check",
"default": 1
},
{
"fieldname": "show_net_values",
"label": __("Show net values in opening and closing columns"),
"fieldtype": "Check",
"default": 1
}
],
"formatter": erpnext.financial_statements.formatter,

View File

@ -120,7 +120,9 @@ def get_data(filters):
ignore_opening_entries=True,
)
calculate_values(accounts, gl_entries_by_account, opening_balances)
calculate_values(
accounts, gl_entries_by_account, opening_balances, filters.get("show_net_values")
)
accumulate_values_into_parents(accounts, accounts_by_name)
data = prepare_data(accounts, filters, parent_children_map, company_currency)
@ -310,7 +312,7 @@ def get_opening_balance(
return gle
def calculate_values(accounts, gl_entries_by_account, opening_balances):
def calculate_values(accounts, gl_entries_by_account, opening_balances, show_net_values):
init = {
"opening_debit": 0.0,
"opening_credit": 0.0,
@ -335,7 +337,8 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances):
d["closing_debit"] = d["opening_debit"] + d["debit"]
d["closing_credit"] = d["opening_credit"] + d["credit"]
prepare_opening_closing(d)
if show_net_values:
prepare_opening_closing(d)
def calculate_total_row(accounts, company_currency):
@ -375,7 +378,7 @@ def prepare_data(accounts, filters, parent_children_map, company_currency):
for d in accounts:
# Prepare opening closing for group account
if parent_children_map.get(d.account):
if parent_children_map.get(d.account) and filters.get("show_net_values"):
prepare_opening_closing(d)
has_value = False