From bbe240349191dd8877297d6825e3a1055661a1e5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 5 Oct 2012 19:29:11 +0530 Subject: [PATCH] fix in get_fiscal_year --- accounts/utils/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py index 60f70fe0b6..ac13e47ad5 100644 --- a/accounts/utils/__init__.py +++ b/accounts/utils/__init__.py @@ -21,14 +21,17 @@ from webnotes.utils import nowdate def get_fiscal_year(date): from webnotes.utils import formatdate + # if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate) fy = webnotes.conn.sql("""select name, year_start_date, - adddate(year_start_date, interval 1 year) + subdate(adddate(year_start_date, interval 1 year), interval 1 day) + as year_end_date from `tabFiscal Year` - where %s between year_start_date and adddate(year_start_date, - interval 1 year)""", date) + where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)""", + (date, date)) if not fy: - webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), raise_exception=1) + webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), + raise_exception=1) return fy[0]