mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 23:52:57 +00:00
Merge pull request #55697 from frappe/mergify/bp/version-16-hotfix/pr-54684
fix(profit-loss-report): handle zero base values and prevent null% display (backport #54684)
This commit is contained in:
@@ -737,6 +737,9 @@ def compute_growth_view_data(data, columns):
|
|||||||
data_copy = copy.deepcopy(data)
|
data_copy = copy.deepcopy(data)
|
||||||
|
|
||||||
for row_idx in range(len(data_copy)):
|
for row_idx in range(len(data_copy)):
|
||||||
|
if not data_copy[row_idx]:
|
||||||
|
continue
|
||||||
|
|
||||||
for column_idx in range(1, len(columns)):
|
for column_idx in range(1, len(columns)):
|
||||||
previous_period_key = columns[column_idx - 1].get("key")
|
previous_period_key = columns[column_idx - 1].get("key")
|
||||||
current_period_key = columns[column_idx].get("key")
|
current_period_key = columns[column_idx].get("key")
|
||||||
@@ -785,13 +788,21 @@ def compute_margin_view_data(data, columns, accumulated_values):
|
|||||||
|
|
||||||
for column in columns:
|
for column in columns:
|
||||||
curr_period = column.get("key")
|
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:
|
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] = None
|
data[row_idx][curr_period] = None
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if base_value == 0:
|
||||||
|
if curr_value == 0:
|
||||||
|
data[row_idx][curr_period] = 0
|
||||||
|
else:
|
||||||
|
data[row_idx][curr_period] = None
|
||||||
|
continue
|
||||||
|
|
||||||
margin_percent = round((curr_value / base_value) * 100, 2)
|
margin_percent = round((curr_value / base_value) * 100, 2)
|
||||||
|
|
||||||
data[row_idx][curr_period] = margin_percent
|
data[row_idx][curr_period] = margin_percent
|
||||||
|
|||||||
Reference in New Issue
Block a user