From df6fd782b749480153fd28415e8fe877af12d272 Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 19:47:19 +0300 Subject: [PATCH 1/3] fix(profit-and-loss-statement-report): margin calculation the report showing null% for empty cell --- 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 469726a1b785..f03d35dbb5a2 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 671555edbc55989b30bc2c9c45c079e650aa9ce2 Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 20:02:00 +0300 Subject: [PATCH 2/3] fix(profit-and-loss-statement): margin calculation the report showing null% for empty cell --- 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 f03d35dbb5a2..7a8cadc128ec 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 73350118144dfd38c2646620d13658f78f7ddcf1 Mon Sep 17 00:00:00 2001 From: Ahmed Reda Abukhatwa Date: Thu, 30 Apr 2026 20:16:21 +0300 Subject: [PATCH 3/3] fix(profit-loss-report): handle zero base values and prevent null% display --- 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 7a8cadc128ec..a628febd2c1e 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)