mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 02:26:33 +00:00
fix: avoid double-counting the total in accumulated Consolidated Financial Statement
This commit is contained in:
@@ -582,7 +582,12 @@ def prepare_data(accounts, start_date, end_date, balance_must_be, companies, com
|
|||||||
total += flt(row[company])
|
total += flt(row[company])
|
||||||
|
|
||||||
row["has_value"] = has_value
|
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)
|
data.append(row)
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ class TestConsolidatedFinancialStatement(ERPNextTestSuite):
|
|||||||
self.assertEqual(flt(sales_row.get(CHILD_COMPANY)), amount)
|
self.assertEqual(flt(sales_row.get(CHILD_COMPANY)), amount)
|
||||||
# parent column picks up the child value when accumulated
|
# parent column picks up the child value when accumulated
|
||||||
self.assertEqual(flt(sales_row.get(PARENT_COMPANY)), amount)
|
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):
|
def test_balance_sheet_executes_and_returns_rows(self):
|
||||||
# posting income leaves a balancing entry in the child's Cash (Asset) account
|
# posting income leaves a balancing entry in the child's Cash (Asset) account
|
||||||
|
|||||||
Reference in New Issue
Block a user