From a8e743e3c42b3d48ab443384c76279c30a2324a1 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 28 Jan 2019 11:27:35 +0530 Subject: [PATCH 1/2] fix: fiscal year always be for 12 months --- erpnext/accounts/doctype/fiscal_year/fiscal_year.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index a00aebe5a23..d749c89f34d 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -37,9 +37,10 @@ class FiscalYear(Document): if getdate(self.year_start_date) > getdate(self.year_end_date): frappe.throw(_("Fiscal Year Start Date should not be greater than Fiscal Year End Date")) - if (getdate(self.year_end_date) - getdate(self.year_start_date)).days > 366: - date = getdate(self.year_start_date) + relativedelta(years=1) - relativedelta(days=1) - self.year_end_date = date.strftime("%Y-%m-%d") + date = getdate(self.year_start_date) + relativedelta(years=1) - relativedelta(days=1) + + if getdate(self.year_end_date) != date: + frappe.throw(_("The difference between the year start date and year end date must be 12 months.")) def on_update(self): check_duplicate_fiscal_year(self) From 9520e345bd1f61e242c3f8d3e2a1c2b4d1cded17 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Tue, 29 Jan 2019 13:03:46 +0530 Subject: [PATCH 2/2] fix: better error messages --- erpnext/accounts/doctype/fiscal_year/fiscal_year.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index d749c89f34d..6bb71b667f1 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -35,12 +35,12 @@ class FiscalYear(Document): def validate_dates(self): if getdate(self.year_start_date) > getdate(self.year_end_date): - frappe.throw(_("Fiscal Year Start Date should not be greater than Fiscal Year End Date")) + frappe.throw(_("Fiscal Year Start Date should be one year earlier than Fiscal Year End Date")) date = getdate(self.year_start_date) + relativedelta(years=1) - relativedelta(days=1) if getdate(self.year_end_date) != date: - frappe.throw(_("The difference between the year start date and year end date must be 12 months.")) + frappe.throw(_("Fiscal Year End Date should be one year after Fiscal Year Start Date")) def on_update(self): check_duplicate_fiscal_year(self)