fix in get_balance_on for a date which does not fall within any fiscal year
diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js
index fe407f5..d60dba6 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/accounts/doctype/journal_voucher/journal_voucher.js
@@ -150,7 +150,7 @@
 		args: {account: d.account, date: doc.posting_date},
 		callback: function(r) {
 			d.balance = fmt_money(r.message);
-			refresh_field('balance',d.name,'entries');
+			refresh_field('balance', d.name, 'entries');
 		}
 	});
 } 
diff --git a/accounts/search_criteria/general_ledger/general_ledger.py b/accounts/search_criteria/general_ledger/general_ledger.py
index 2533238..11ab7c3 100644
--- a/accounts/search_criteria/general_ledger/general_ledger.py
+++ b/accounts/search_criteria/general_ledger/general_ledger.py
@@ -30,14 +30,6 @@
 	from_date = filter_values['posting_date']
 	to_date = filter_values['posting_date1']
 
-from_date_year = sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",from_date)
-if not from_date_year:
-	msgprint("From Date is out of range. Please check.", raise_exception=1)
-else:
-	from_date_year = from_date_year[0][0]
-#to_date_year = sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",to_date)[0][0]
-
-
 # define columns
 #---------------------------------------------------------------------
 col = []
diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py
index ac13e47..c4a0042 100644
--- a/accounts/utils/__init__.py
+++ b/accounts/utils/__init__.py
@@ -19,7 +19,9 @@
 import webnotes
 from webnotes.utils import nowdate
 
-def get_fiscal_year(date):
+class FiscalYearError(webnotes.ValidationError): pass
+
+def get_fiscal_year(date, verbose=1):
 	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, 
@@ -30,8 +32,9 @@
 		(date, date))
 	
 	if not fy:
-		webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date),
-			raise_exception=1)
+		error_msg = """%s not in any Fiscal Year""" % formatdate(date)
+		if verbose: webnotes.msgprint(error_msg)
+		raise FiscalYearError, error_msg
 	
 	return fy[0]
 
@@ -40,18 +43,34 @@
 	if not account and webnotes.form_dict.get("account"):
 		account = webnotes.form_dict.get("account")
 		date = webnotes.form_dict.get("date")
-		
+	
 	cond = []
 	if date:
 		cond.append("posting_date <= '%s'" % date)
-	
+	else:
+		# get balance of all entries that exist
+		date = nowdate()
+		
+	try:
+		year_start_date = get_fiscal_year(date, verbose=0)[1]
+	except FiscalYearError, e:
+		from webnotes.utils import getdate
+		if getdate(date) > getdate(nowdate()):
+			# if fiscal year not found and the date is greater than today
+			# get fiscal year for today's date and its corresponding year start date
+			year_start_date = get_fiscal_year(nowdate(), verbose=1)[1]
+		else:
+			# this indicates that it is a date older than any existing fiscal year.
+			# hence, assuming balance as 0.0
+			return 0.0
+		
 	acc = webnotes.conn.get_value('Account', account, \
 		['lft', 'rgt', 'debit_or_credit', 'is_pl_account', 'group_or_ledger'], as_dict=1)
 	
 	# for pl accounts, get balance within a fiscal year
 	if acc.is_pl_account == 'Yes':
-		cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" % \
-			get_fiscal_year(date or nowdate())[1])
+		cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \
+			% year_start_date)
 	
 	# different filter for group and ledger - improved performance
 	if acc.group_or_ledger=="Group":