From 04fe76bf832a4217dc408da762a6aee9a9fcc4d4 Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 19:47:19 +0300 Subject: [PATCH 1/4] fix(profit-and-loss-statement-report): margin calculation the report showing null% for empty cell (cherry picked from commit df6fd782b749480153fd28415e8fe877af12d272) --- erpnext/accounts/report/financial_statements.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 469726a1b78..f03d35dbb5a 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -785,11 +785,19 @@ def compute_margin_view_data(data, columns, accumulated_values): for column in columns: curr_period = column.get("key") - base_value = base_row[curr_period] - curr_value = row[curr_period] - if curr_value is None or base_value <= 0: - data[row_idx][curr_period] = None + base_value = base_row.get(curr_period) + curr_value = row.get(curr_period) + + if base_value is None or curr_value is None: + data[row_idx][curr_period] = "N/A" + continue + + if base_value == 0: + if curr_value == 0: + data[row_idx][curr_period] = "" + else: + data[row_idx][curr_period] = "N/A" continue margin_percent = round((curr_value / base_value) * 100, 2) From b3d3f13fc5c74804c2c7d53d8b37a800c533d34b Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 20:02:00 +0300 Subject: [PATCH 2/4] fix(profit-and-loss-statement): margin calculation the report showing null% for empty cell (cherry picked from commit 671555edbc55989b30bc2c9c45c079e650aa9ce2) --- erpnext/accounts/report/financial_statements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index f03d35dbb5a..7a8cadc128e 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -795,7 +795,7 @@ def compute_margin_view_data(data, columns, accumulated_values): if base_value == 0: if curr_value == 0: - data[row_idx][curr_period] = "" + data[row_idx][curr_period] = 0 else: data[row_idx][curr_period] = "N/A" continue From 90ac065930ea0b4d432be53e6fef4798314ae96c Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 20:16:21 +0300 Subject: [PATCH 3/4] fix(profit-loss-report): handle zero base values and prevent null% display (cherry picked from commit 73350118144dfd38c2646620d13658f78f7ddcf1) --- erpnext/accounts/report/financial_statements.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 7a8cadc128e..a628febd2c1 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -790,14 +790,14 @@ def compute_margin_view_data(data, columns, accumulated_values): curr_value = row.get(curr_period) if base_value is None or curr_value is None: - data[row_idx][curr_period] = "N/A" + data[row_idx][curr_period] = None continue if base_value == 0: if curr_value == 0: data[row_idx][curr_period] = 0 else: - data[row_idx][curr_period] = "N/A" + data[row_idx][curr_period] = None continue margin_percent = round((curr_value / base_value) * 100, 2) From 18afcf0c01f8a849a0419506b45c42fb5f1bace1 Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 14 May 2026 14:40:03 +0300 Subject: [PATCH 4/4] fix: skip empty spacer rows in compute_growth_view_data (P&L growth view) (cherry picked from commit 3592c3086d6cc87df997518cedae62624bc09b58) --- erpnext/accounts/report/financial_statements.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index a628febd2c1..478c603dbf5 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -737,6 +737,9 @@ def compute_growth_view_data(data, columns): data_copy = copy.deepcopy(data) for row_idx in range(len(data_copy)): + if not data_copy[row_idx]: + continue + for column_idx in range(1, len(columns)): previous_period_key = columns[column_idx - 1].get("key") current_period_key = columns[column_idx].get("key")