mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 23:10:26 +00:00
Merge pull request #50103 from rehanrehman389/fix-overlap-validation
fix: fiscal year overlap validation for company-specific years
This commit is contained in:
@@ -99,7 +99,7 @@ class FiscalYear(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
overlap = False
|
overlap = False
|
||||||
if not self.get("companies") or not company_for_existing:
|
if not self.get("companies") and not company_for_existing:
|
||||||
overlap = True
|
overlap = True
|
||||||
|
|
||||||
for d in self.get("companies"):
|
for d in self.get("companies"):
|
||||||
|
|||||||
@@ -25,6 +25,27 @@ class TestFiscalYear(IntegrationTestCase):
|
|||||||
|
|
||||||
self.assertRaises(frappe.exceptions.InvalidDates, fy.insert)
|
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.new_doc("Fiscal Year")
|
||||||
|
global_fy.year = "_Test Global FY 2001"
|
||||||
|
global_fy.year_start_date = "2001-04-01"
|
||||||
|
global_fy.year_end_date = "2002-03-31"
|
||||||
|
global_fy.insert()
|
||||||
|
|
||||||
|
company_fy = frappe.new_doc("Fiscal Year")
|
||||||
|
company_fy.year = "_Test Company FY 2001"
|
||||||
|
company_fy.year_start_date = "2001-01-01"
|
||||||
|
company_fy.year_end_date = "2001-12-31"
|
||||||
|
company_fy.append("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():
|
def test_record_generator():
|
||||||
test_records = [
|
test_records = [
|
||||||
|
|||||||
Reference in New Issue
Block a user