From 0e8b152c680fd9db0663f60057ecb5af59c30bef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 Jul 2026 21:26:04 +0530 Subject: [PATCH] fix: avoid double-counting the total in accumulated Consolidated Financial Statement --- .../consolidated_financial_statement.py | 7 ++++++- .../test_consolidated_financial_statement.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index fba7054e0a7..237f37e767f 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -582,7 +582,12 @@ def prepare_data(accounts, start_date, end_date, balance_must_be, companies, com total += flt(row[company]) row["has_value"] = has_value - row["total"] = total + # when accumulating into the group company, that company's column already consolidates its + # descendants, so summing every company column would double-count; use the group total directly. + if filters.get("accumulated_in_group_company"): + row["total"] = flt(row.get(filters.company, 0.0), 3) + else: + row["total"] = total data.append(row) diff --git a/erpnext/accounts/report/consolidated_financial_statement/test_consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/test_consolidated_financial_statement.py index c928a82887e..202c495d378 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/test_consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/test_consolidated_financial_statement.py @@ -102,6 +102,8 @@ class TestConsolidatedFinancialStatement(ERPNextTestSuite): self.assertEqual(flt(sales_row.get(CHILD_COMPANY)), amount) # parent column picks up the child value when accumulated self.assertEqual(flt(sales_row.get(PARENT_COMPANY)), amount) + # the total must equal the consolidated (group) value, not the sum of parent + child columns + self.assertEqual(flt(sales_row.get("total")), amount) def test_balance_sheet_executes_and_returns_rows(self): # posting income leaves a balancing entry in the child's Cash (Asset) account