last update
diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py
index fe0f205..7db63b2 100644
--- a/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/accounts/doctype/fiscal_year/fiscal_year.py
@@ -22,6 +22,9 @@
 		self.doc, self.doclist = d,dl
 		
 	def repost(self):
+		if not self.doc.company:
+			msgprint("Please select company", raise_exception=1)
+			
 		if not in_transaction:
 			sql("start transaction")
 				
@@ -100,9 +103,7 @@
 	def post_entries(self):
 		sql("LOCK TABLE `tabGL Entry` WRITE")
 		# post each gl entry (batch or complete)
-		gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s
-		
-		", (self.doc.name, self.doc.company))
+		gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s", (self.doc.name, self.doc.company))
 		account_details = {}
 
 		cnt = 0
diff --git a/accounts/search_criteria/trial_balance/trial_balance.js b/accounts/search_criteria/trial_balance/trial_balance.js
index 5fd6049..7cfe459 100644
--- a/accounts/search_criteria/trial_balance/trial_balance.js
+++ b/accounts/search_criteria/trial_balance/trial_balance.js
@@ -1,31 +1,45 @@
 report.customize_filters = function() {
-  this.hide_all_filters();
+	this.hide_all_filters();
 
-  this.add_filter({fieldname:'show_group_balance', label:'Show Group Balance', fieldtype:'Select', options:'Yes'+NEWLINE+'No',ignore : 1, parent:'Account', 'report_default':'No','in_first_page':1});
-  this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'Account', 'in_first_page':1});
+	this.add_filter({fieldname:'show_group_ledger', label:'Show Group/Ledger', fieldtype:'Select', options:'Only Groups'+NEWLINE+'Only Ledgers'+NEWLINE+'Both But Without Group Balance'+NEWLINE+'Both With Balance',ignore : 1, parent:'Account', 'report_default':'Both With Balance','in_first_page':1,single_select:1});
+	
+	this.add_filter({fieldname:'show_zero_balance', label:'Show Zero Balance', fieldtype:'Select', options:'Yes'+NEWLINE+'No',ignore : 1, parent:'Account', 'report_default':'Yes','in_first_page':1,single_select:1});
+	
+	this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'Account', 'in_first_page':1});
 
-  this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.filter_hide = 0;
-  this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.filter_hide = 0;
-  this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.filter_hide = 0;
+	this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.filter_hide = 0;
+	this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.filter_hide = 0;
+	this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.filter_hide = 0;
 
-  this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df['report_default'] = sys_defaults.year_start_date;
-  this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df['report_default'] = dateutil.obj_to_str(new Date());
-  this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
+	this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df['report_default'] = sys_defaults.year_start_date;
+	this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+	this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
 
-  this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.in_first_page = 1;
-  this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.in_first_page = 1;
-  this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.in_first_page = 1;
+	this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.in_first_page = 1;
+	this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.in_first_page = 1;
+	this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.in_first_page = 1;
 
-  this.dt.set_no_limit(1);
+	this.dt.set_no_limit(1);
 }
 
 report.aftertableprint = function(t) {
-   $yt(t,'*',1,{whiteSpace:'pre'});
+	 $yt(t,'*',1,{whiteSpace:'pre'});
 }
-if(window.location.href.search('/v170/') != -1) {
-  this.mytabs.items['More Filters'].hide();
-  this.mytabs.items['Select Columns'].hide();
-} else {
-  $dh(this.mytabs.tabs['More Filters']);
-  $dh(this.mytabs.tabs['Select Columns']);
+
+$dh(this.mytabs.tabs['More Filters']);
+$dh(this.mytabs.tabs['Select Columns']);
+
+report.get_query = function() {
+	var g_or_l = this.get_filter('Account', 'Show Group/Ledger').get_value();
+	var comp = this.get_filter('Account', 'Company').get_value();
+	
+	if (g_or_l == 'Only Ledgers') {
+		var q = "SELECT name FROM tabAccount WHERE group_or_ledger = 'Ledger' and company = '" + comp + "' and docstatus != 2 ORDER BY lft";
+	} else if (g_or_l == 'Only Groups') {
+		var q = "SELECT CONCAT( REPEAT('   ', COUNT(parent.name) - 1), node.name) AS name FROM tabAccount AS node,tabAccount AS parent WHERE (node.lft BETWEEN parent.lft AND parent.rgt) and node.group_or_ledger = 'Group' and node.company = '" + comp + "' and node.docstatus != 2 GROUP BY node.name ORDER BY node.lft";
+	} else {
+		var q = "SELECT CONCAT( REPEAT('   ', COUNT(parent.name) - 1), node.name) AS name FROM tabAccount AS node,tabAccount AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt and node.company = '" + comp + "' and node.docstatus != 2 GROUP BY node.name ORDER BY node.lft";
+	}
+	
+	return q;
 }
diff --git a/accounts/search_criteria/trial_balance/trial_balance.py b/accounts/search_criteria/trial_balance/trial_balance.py
index a4c3f82..fb168e5 100644
--- a/accounts/search_criteria/trial_balance/trial_balance.py
+++ b/accounts/search_criteria/trial_balance/trial_balance.py
@@ -1,4 +1,3 @@
-
 # Columns
 #----------
 cl = [['Account','Data', '200px'],['Debit/Credit', 'Data', '100px'], ['Group/Ledger', 'Data', '100px'], ['Is PL Account', 'Data', '100px'], ['Opening','Data', '100px'],['Debit', 'Data', '100px'],['Credit', 'Data', '100px'],['Closing', 'Data', '100px']]
@@ -42,7 +41,7 @@
 glc = get_obj('GL Control')
 
 # Main logic
-# ----------------
+# ----------
 for r in res:
 	# Fetch account details
 	acc = r[col_idx['Account']].strip()
@@ -51,11 +50,11 @@
 	r.append(acc_det[0][4])
 	r.append(acc_det[0][1])
 	
-	# if group, check user input
-	if acc_det[0][4] == 'Group' and filter_values.get('show_group_balance') == 'No':
+	#if shows group and ledger both but without group balance
+	if filter_values.get('show_group_ledger') == 'Both But Without Group Balance' and acc_det[0][4] == 'Group':
 		for i in range(4):
 			r.append('')
-		continue	
+		continue
 
 	# opening balance
 	if from_date_year:
@@ -70,7 +69,7 @@
 	if from_date_year == to_date_year:
 		debit = flt(debit_on_todate) - flt(debit_on_fromdate)
 		credit = flt(credit_on_todate) - flt(credit_on_fromdate)
-	else: # may be wrong
+	else: # if from date is start date of the year
 		debit = flt(debit_on_todate)
 		credit = flt(credit_on_todate)
 		
@@ -89,20 +88,18 @@
 	r.append(flt(closing))
 
 
-# Remove accounts if closing bal = debit = credit = 0
-# -----------------------------------------------------
-
 out =[]
 for r in res:
-	if r[col_idx['Opening']] or r[col_idx['Debit']] or r[col_idx['Credit']] or r[col_idx['Closing']]:
+	# Remove accounts if opening bal = debit = credit = closing bal = 0
+	# ------------------------------------------------------------------
+	if filter_values.get('show_zero_balance') != 'No':
 		out.append(r)
-
-	if r[col_idx['Group/Ledger']] == 'Group' and filter_values.get('show_group_balance') == 'No':
+	elif r[col_idx['Opening']] or r[col_idx['Debit']] or r[col_idx['Credit']] or r[col_idx['Closing']] or (r[col_idx['Group/Ledger']] == 'Group' and filter_values.get('show_group_ledger') == 'Both But Without Group Balance'):
 		out.append(r)
 		
 # Total Debit / Credit
 # --------------------------
-if filter_values.get('show_group_balance') == 'No':
+if filter_values.get('show_group_ledger') in ['Only Ledgers', 'Both But Without Group Balance']:
 	t_row = ['' for i in range(len(colnames))]
 	t_row[col_idx['Account']] = 'Total'
 	t_row[col_idx['Debit']] = total_debit
diff --git a/accounts/search_criteria/trial_balance/trial_balance.txt b/accounts/search_criteria/trial_balance/trial_balance.txt
index 308d24f..a29c5a2 100644
--- a/accounts/search_criteria/trial_balance/trial_balance.txt
+++ b/accounts/search_criteria/trial_balance/trial_balance.txt
@@ -1,24 +1,24 @@
 [
 	{
 		'add_col': None,
-		'add_cond': '',
+		'add_cond': None,
 		'add_tab': None,
 		'columns': 'Account\x01ID',
-		'creation': '2010-12-14 10:33:08',
+		'creation': '2010-12-14 10:23:28',
 		'criteria_name': 'Trial Balance',
-		'custom_query': None,
+		'custom_query': '',
 		'description': 'Trial Balance',
 		'dis_filters': 'transaction_date',
 		'disabled': None,
 		'doc_type': 'Account',
 		'docstatus': 0,
 		'doctype': 'Search Criteria',
-		'filters': "{'Account\x01Group or Ledger':'Ledger','Account\x01Is PL Account':'','Account\x01Account Type':'','Account\x01Show Group Balance':''}",
+		'filters': "{'Account\x01Is PL Account':'','Account\x01Account Type':''}",
 		'graph_series': None,
 		'graph_values': None,
 		'group_by': None,
 		'idx': None,
-		'modified': '2010-11-25 12:25:28',
+		'modified': '2011-06-22 12:29:43',
 		'modified_by': 'Administrator',
 		'module': 'Accounts',
 		'name': 'trial_balance',
@@ -34,4 +34,4 @@
 		'sort_order': 'DESC',
 		'standard': 'Yes'
 	}
-]
\ No newline at end of file
+]
diff --git a/material_management/doctype/bin/bin.py b/material_management/doctype/bin/bin.py
index ba8398a..7034264 100644
--- a/material_management/doctype/bin/bin.py
+++ b/material_management/doctype/bin/bin.py
@@ -259,18 +259,7 @@
 		if sll:
 			sql("update `tabBin` set valuation_rate=%s, actual_qty=%s, stock_value = %s where name=%s", \
 				(flt(val_rate), cqty, flt(stock_val), self.doc.name))
-		
-	# item re-order
-	# -------------
-	def reorder_item(self):
-		projected_qty = flt(self.doc.actual_qty) + flt(self.doc.indented_qty) + flt(self.doc.ordered_qty)
-		item_reorder_level = sql("select reorder_level from `%sItem` where name = '%s'" % (self.prefix, self.doc.item_code))[0][0] or 0
-		if flt(item_reorder_level) > flt(projected_qty):
-			msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent raised (Not Implemented).")
-	
-	# validate
-	def validate(self):
-		self.validate_mandatory()
+
 
 	# item re-order
 	# -------------
diff --git a/patches/patch.py b/patches/patch.py
index 334b656..2e01cf8 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,6 +1,6 @@
 # REMEMBER to update this
 # ========================
-last_patch = 291
+last_patch = 292
 
 #-------------------------------------------
 
@@ -1161,5 +1161,6 @@
 			md.module_label = 'Home'
 			md.save(1)
 	elif patch_no == 291:
-		relaod_doc('tools','doctype','rename_tool')
-		
\ No newline at end of file
+		reload_doc('tools','doctype','rename_tool')
+	elif patch_no == 292:
+		reload_doc('accounts', 'search_criteria', 'trial_balance')