From c32ad9711fe5e49e1c078ffa27568d226ea911cd Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Wed, 24 Sep 2025 13:18:25 +0530 Subject: [PATCH] feat: add show zero value filter in profit and loss and balance sheet (cherry picked from commit 33ab24943caf5ab3079047e03fa1c5803f594dfa) # Conflicts: # erpnext/accounts/report/balance_sheet/balance_sheet.js # erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js --- .../report/balance_sheet/balance_sheet.js | 55 ++++++++++-------- .../accounts/report/financial_statements.py | 2 +- .../profit_and_loss_statement.js | 57 ++++++++++--------- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js index 0863c68009a..1bc16992479 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.js +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js @@ -5,28 +5,33 @@ frappe.query_reports["Balance Sheet"] = $.extend({}, erpnext.financial_statement erpnext.utils.add_dimensions("Balance Sheet", 10); -frappe.query_reports["Balance Sheet"]["filters"].push({ - fieldname: "selected_view", - label: __("Select View"), - fieldtype: "Select", - options: [ - { value: "Report", label: __("Report View") }, - { value: "Growth", label: __("Growth View") }, - ], - default: "Report", - reqd: 1, -}); - -frappe.query_reports["Balance Sheet"]["filters"].push({ - fieldname: "accumulated_values", - label: __("Accumulated Values"), - fieldtype: "Check", - default: 1, -}); - -frappe.query_reports["Balance Sheet"]["filters"].push({ - fieldname: "include_default_book_entries", - label: __("Include Default FB Entries"), - fieldtype: "Check", - default: 1, -}); +frappe.query_reports["Balance Sheet"]["filters"].push( + { + fieldname: "selected_view", + label: __("Select View"), + fieldtype: "Select", + options: [ + { value: "Report", label: __("Report View") }, + { value: "Growth", label: __("Growth View") }, + ], + default: "Report", + reqd: 1, + }, + { + fieldname: "accumulated_values", + label: __("Accumulated Values"), + fieldtype: "Check", + default: 1, + }, + { + fieldname: "include_default_book_entries", + label: __("Include Default FB Entries"), + fieldtype: "Check", + default: 1, + }, + { + fieldname: "show_zero_values", + label: __("Show zero values"), + fieldtype: "Check", + } +); diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index bf46c9b07c6..89f36364826 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -212,7 +212,7 @@ def get_data( company_currency, accumulated_values=filters.accumulated_values, ) - out = filter_out_zero_value_rows(out, parent_children_map) + out = filter_out_zero_value_rows(out, parent_children_map, filters.show_zero_values) if out and total: add_total_row(out, root_type, balance_must_be, period_list, company_currency) diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js index 98c6656ca3f..84ffcaf4a36 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js @@ -5,29 +5,34 @@ frappe.query_reports["Profit and Loss Statement"] = $.extend({}, erpnext.financi erpnext.utils.add_dimensions("Profit and Loss Statement", 10); -frappe.query_reports["Profit and Loss Statement"]["filters"].push({ - fieldname: "selected_view", - label: __("Select View"), - fieldtype: "Select", - options: [ - { value: "Report", label: __("Report View") }, - { value: "Growth", label: __("Growth View") }, - { value: "Margin", label: __("Margin View") }, - ], - default: "Report", - reqd: 1, -}); - -frappe.query_reports["Profit and Loss Statement"]["filters"].push({ - fieldname: "accumulated_values", - label: __("Accumulated Values"), - fieldtype: "Check", - default: 1, -}); - -frappe.query_reports["Profit and Loss Statement"]["filters"].push({ - fieldname: "include_default_book_entries", - label: __("Include Default FB Entries"), - fieldtype: "Check", - default: 1, -}); +frappe.query_reports["Profit and Loss Statement"]["filters"].push( + { + fieldname: "selected_view", + label: __("Select View"), + fieldtype: "Select", + options: [ + { value: "Report", label: __("Report View") }, + { value: "Growth", label: __("Growth View") }, + { value: "Margin", label: __("Margin View") }, + ], + default: "Report", + reqd: 1, + }, + { + fieldname: "accumulated_values", + label: __("Accumulated Values"), + fieldtype: "Check", + default: 1, + }, + { + fieldname: "include_default_book_entries", + label: __("Include Default FB Entries"), + fieldtype: "Check", + default: 1, + }, + { + fieldname: "show_zero_values", + label: __("Show zero values"), + fieldtype: "Check", + } +);