fix: avoid double-counting the total in accumulated Consolidated Financial Statement

This commit is contained in:
Nabin Hait
2026-07-01 21:26:04 +05:30
parent 2c3285286c
commit 0e8b152c68
2 changed files with 8 additions and 1 deletions

View File

@@ -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)

View File

@@ -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