From 590f2ffe284ba46860de3106f4b7c5fb16241b72 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Tue, 28 Apr 2026 16:45:26 +0530 Subject: [PATCH] test: include both accounts to test sum = 0 --- .../test_financial_report_engine.py | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/financial_report_template/test_financial_report_engine.py b/erpnext/accounts/doctype/financial_report_template/test_financial_report_engine.py index a63b4385472..fd26f275871 100644 --- a/erpnext/accounts/doctype/financial_report_template/test_financial_report_engine.py +++ b/erpnext/accounts/doctype/financial_report_template/test_financial_report_engine.py @@ -2050,23 +2050,41 @@ class TestFinancialQueryBuilder(FinancialReportTemplateTestCase): query_builder = FinancialQueryBuilder(filters, periods) accounts = [ frappe._dict({"name": cash_account, "account_name": "Cash", "account_number": "1001"}), + frappe._dict( + { + "name": opening_offset_account, + "account_name": "Temporary Opening", + "account_number": "1900", + } + ), ] balances_data = query_builder.fetch_account_balances(accounts) cash_data = balances_data.get(cash_account) + offset_data = balances_data.get(opening_offset_account) self.assertIsNotNone(cash_data, "Cash account should exist in results") + self.assertIsNotNone(offset_data, "Offset account should exist in results") - year_2024 = cash_data.get_period("2024") - self.assertIsNotNone(year_2024, "FY 2024 period should exist") + year_2024_cash = cash_data.get_period("2024") + year_2024_offset = offset_data.get_period("2024") + self.assertIsNotNone(year_2024_cash, "FY 2024 period should exist for cash") + self.assertIsNotNone(year_2024_offset, "FY 2024 period should exist for offset") - # All is_opening JVs (current + next year) roll into FY 2024 opening = 8000 + # All is_opening JVs (current + next year) roll into FY 2024 opening self.assertEqual( - year_2024.opening, + year_2024_cash.opening, 8000.0, - "FY 2024 opening must combine is_opening JVs from current and next year", + "FY 2024 cash opening must combine is_opening JVs from current and next year", ) - self.assertEqual(year_2024.movement, 0.0, "Opening JVs must not be counted as period movement") - self.assertEqual(year_2024.closing, 8000.0, "Closing = opening when no non-opening movement") + self.assertEqual( + year_2024_offset.opening, + -8000.0, + "FY 2024 offset opening must combine is_opening JVs from current and next year", + ) + self.assertEqual( + year_2024_cash.movement, 0.0, "Opening JVs must not be counted as period movement" + ) + self.assertEqual(year_2024_cash.closing, 8000.0, "Closing = opening when no non-opening movement") finally: frappe.db.set_single_value(