Skip to content

Commit

Permalink
feat: Toggle net values in Trial Balance report
Browse files Browse the repository at this point in the history
(cherry picked from commit 06a4589)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Sep 24, 2023
1 parent d3c9a6d commit 57c82c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions erpnext/accounts/report/trial_balance/trial_balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 57c82c1

Please sign in to comment.