blob: 3dbc728ad96b4e8dd8a11bb91f58e0824ca573d2 [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Anand Doshi486f9df2012-07-19 13:40:31 +053017from __future__ import unicode_literals
Brahma Kd7db2ea2011-07-26 19:04:13 +053018
Rushabh Mehta55fd5f32012-09-26 19:00:02 +053019import webnotes
Brahma Kd7db2ea2011-07-26 19:04:13 +053020
Rushabh Mehta55fd5f32012-09-26 19:00:02 +053021def get_fiscal_year_from_date(date):
22 from webnotes.utils import formatdate
23 fy = webnotes.conn.sql("""select name from `tabFiscal Year`
24 where %s between year_start_date and adddate(year_start_date,
25 interval 1 year)""", date)
26
27 if not fy:
28 webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), raise_exception=1)
29
30 return fy[0][0]