From 94ae0988549ff0e411d9157acbe84795e59708b0 Mon Sep 17 00:00:00 2001 From: Rehan Ansari Date: Wed, 15 Oct 2025 23:33:02 +0530 Subject: [PATCH] test: fiscal year overlap validation for company-specific years --- .../doctype/fiscal_year/test_fiscal_year.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py index 0f0a6837cba..999924a60eb 100644 --- a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py @@ -25,6 +25,35 @@ class TestFiscalYear(IntegrationTestCase): self.assertRaises(frappe.exceptions.InvalidDates, fy.insert) + def test_company_fiscal_year_overlap(self): + for name in ["_Test Global FY 2001", "_Test Company FY 2001"]: + if frappe.db.exists("Fiscal Year", name): + frappe.delete_doc("Fiscal Year", name) + + global_fy = frappe.get_doc( + { + "doctype": "Fiscal Year", + "year": "_Test Global FY 2001", + "year_start_date": "2001-04-01", + "year_end_date": "2002-03-31", + } + ) + global_fy.insert() + + company_fy = frappe.get_doc( + { + "doctype": "Fiscal Year", + "year": "_Test Company FY 2001", + "year_start_date": "2001-01-01", + "year_end_date": "2001-12-31", + "companies": [{"company": "_Test Company"}], + } + ) + + company_fy.insert() + self.assertTrue(frappe.db.exists("Fiscal Year", global_fy.name)) + self.assertTrue(frappe.db.exists("Fiscal Year", company_fy.name)) + def test_record_generator(): test_records = [