From 84ed127e725399db92277352ef87377748ae81eb Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 26 Nov 2013 17:29:51 +0530 Subject: [PATCH] [fix] [minor] setup wizard - calculate year end date on change of year start date --- accounts/doctype/fiscal_year/fiscal_year.py | 7 ++++--- setup/page/setup_wizard/setup_wizard.js | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py index 6eb5afb973..d1f121765b 100644 --- a/accounts/doctype/fiscal_year/fiscal_year.py +++ b/accounts/doctype/fiscal_year/fiscal_year.py @@ -24,9 +24,10 @@ class DocType: year_start_end_dates = webnotes.conn.sql("""select year_start_date, year_end_date from `tabFiscal Year` where name=%s""", (self.doc.name)) - if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]: - webnotes.throw(_("Cannot change Year Start Date and Year End Date \ - once the Fiscal Year is saved.")) + if year_start_end_dates: + if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]: + webnotes.throw(_("Cannot change Year Start Date and Year End Date \ + once the Fiscal Year is saved.")) def on_update(self): # validate year start date and year end date diff --git a/setup/page/setup_wizard/setup_wizard.js b/setup/page/setup_wizard/setup_wizard.js index 9f775e0d6b..7b4253d510 100644 --- a/setup/page/setup_wizard/setup_wizard.js +++ b/setup/page/setup_wizard/setup_wizard.js @@ -102,6 +102,12 @@ wn.pages['setup-wizard'].onload = function(wrapper) { var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join(""); slide.get_input("company_abbr").val(abbr.toUpperCase()); }).val(wn.boot.control_panel.company_name || "").trigger("change"); + + slide.get_input("fy_start_date").on("change", function() { + var year_end_date = + wn.datetime.add_days(wn.datetime.add_months(slide.get_input("fy_start_date").val(), 12), -1); + slide.get_input("fy_end_date").val(year_end_date); + }); } },