Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/account/account.txt b/accounts/doctype/account/account.txt
index 3d82261..aa3fd67 100644
--- a/accounts/doctype/account/account.txt
+++ b/accounts/doctype/account/account.txt
@@ -1,6 +1,6 @@
 [
 	{
-		'_last_update': None,
+		'_last_update': '1308811650',
 		'allow_attach': None,
 		'allow_copy': 1,
 		'allow_email': None,
@@ -29,7 +29,7 @@
 		'istable': None,
 		'max_attachments': None,
 		'menu_index': None,
-		'modified': '2011-03-18 14:30:09',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'module': 'Accounts',
 		'name': 'Account',
@@ -50,8 +50,10 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'smallicon': None,
+		'subject': None,
+		'tag_fields': None,
 		'use_template': None,
-		'version': 145
+		'version': 133
 	},
 	{
 		'amend': None,
@@ -63,7 +65,7 @@
 		'execute': None,
 		'idx': 1,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00042',
 		'owner': 'Administrator',
@@ -86,7 +88,7 @@
 		'execute': None,
 		'idx': 2,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00043',
 		'owner': 'Administrator',
@@ -109,7 +111,7 @@
 		'execute': None,
 		'idx': 3,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00044',
 		'owner': 'Administrator',
@@ -132,7 +134,7 @@
 		'execute': None,
 		'idx': 4,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00045',
 		'owner': 'Administrator',
@@ -155,7 +157,7 @@
 		'execute': None,
 		'idx': 5,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00046',
 		'owner': 'Administrator',
@@ -178,7 +180,7 @@
 		'execute': None,
 		'idx': 6,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00047',
 		'owner': 'Administrator',
@@ -201,7 +203,7 @@
 		'execute': None,
 		'idx': 7,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00048',
 		'owner': 'Administrator',
@@ -224,7 +226,7 @@
 		'execute': None,
 		'idx': 8,
 		'match': None,
-		'modified': '2010-08-08 17:08:51',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'PERM00049',
 		'owner': 'Administrator',
@@ -240,7 +242,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -253,9 +255,10 @@
 		'idx': 1,
 		'in_filter': None,
 		'label': 'Properties',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000166',
+		'name': '000013925',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': 'Section Break',
@@ -275,7 +278,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -288,9 +291,10 @@
 		'idx': 2,
 		'in_filter': None,
 		'label': None,
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000167',
+		'name': '000013926',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': None,
@@ -323,9 +327,10 @@
 		'idx': 3,
 		'in_filter': 1,
 		'label': 'Account Name',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00433',
+		'no_column': None,
 		'no_copy': 1,
 		'oldfieldname': 'account_name',
 		'oldfieldtype': 'Data',
@@ -358,9 +363,10 @@
 		'idx': 4,
 		'in_filter': None,
 		'label': 'Parent Account',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00434',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'parent_account',
 		'oldfieldtype': 'Link',
@@ -391,11 +397,12 @@
 		'hidden': 1,
 		'icon': None,
 		'idx': 5,
-		'in_filter': 0,
+		'in_filter': None,
 		'label': 'Level',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00435',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'level',
 		'oldfieldtype': 'Int',
@@ -408,7 +415,7 @@
 		'print_hide': 1,
 		'report_hide': None,
 		'reqd': None,
-		'search_index': 0,
+		'search_index': None,
 		'trigger': None,
 		'width': None
 	},
@@ -428,9 +435,10 @@
 		'idx': 6,
 		'in_filter': 1,
 		'label': 'Group or Ledger',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00436',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'group_or_ledger',
 		'oldfieldtype': 'Select',
@@ -450,7 +458,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -463,9 +471,10 @@
 		'idx': 7,
 		'in_filter': None,
 		'label': 'Convert to Group',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000163',
+		'name': '000013923',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': None,
@@ -485,7 +494,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -498,9 +507,10 @@
 		'idx': 8,
 		'in_filter': None,
 		'label': 'Convert to Ledger',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000164',
+		'name': '000013924',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': None,
@@ -533,9 +543,10 @@
 		'idx': 9,
 		'in_filter': 1,
 		'label': 'Debit or Credit',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00441',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'debit_or_credit',
 		'oldfieldtype': 'Data',
@@ -568,9 +579,10 @@
 		'idx': 10,
 		'in_filter': 1,
 		'label': 'Is PL Account',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00437',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'is_pl_account',
 		'oldfieldtype': 'Select',
@@ -603,9 +615,10 @@
 		'idx': 11,
 		'in_filter': 1,
 		'label': 'Account Type',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00439',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'account_type',
 		'oldfieldtype': 'Select',
@@ -638,9 +651,10 @@
 		'idx': 12,
 		'in_filter': None,
 		'label': 'Rate',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00440',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'tax_rate',
 		'oldfieldtype': 'Currency',
@@ -660,7 +674,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -673,9 +687,10 @@
 		'idx': 13,
 		'in_filter': None,
 		'label': None,
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000168',
+		'name': '000013927',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': None,
@@ -708,9 +723,10 @@
 		'idx': 14,
 		'in_filter': None,
 		'label': 'Freeze Account',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00438',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'freeze_account',
 		'oldfieldtype': 'Select',
@@ -743,9 +759,10 @@
 		'idx': 15,
 		'in_filter': 1,
 		'label': 'Company',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00442',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'company',
 		'oldfieldtype': 'Link',
@@ -778,9 +795,10 @@
 		'idx': 16,
 		'in_filter': None,
 		'label': 'Credit Days',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00443',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'credit_days',
 		'oldfieldtype': 'Int',
@@ -813,9 +831,10 @@
 		'idx': 17,
 		'in_filter': None,
 		'label': 'Credit Limit',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00444',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'credit_limit',
 		'oldfieldtype': 'Currency',
@@ -848,9 +867,10 @@
 		'idx': 18,
 		'in_filter': None,
 		'label': 'Master Type',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00453',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'master_type',
 		'oldfieldtype': 'Select',
@@ -883,9 +903,10 @@
 		'idx': 19,
 		'in_filter': None,
 		'label': 'Master Name',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00454',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'master_name',
 		'oldfieldtype': 'Link',
@@ -905,42 +926,7 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2010-08-08 17:08:51',
-		'default': None,
-		'depends_on': None,
-		'description': None,
-		'docstatus': 0,
-		'doctype': 'DocField',
-		'fieldname': 'address',
-		'fieldtype': 'Small Text',
-		'hidden': None,
-		'icon': None,
-		'idx': 20,
-		'in_filter': None,
-		'label': 'Address',
-		'modified': '2011-05-09 10:50:47',
-		'modified_by': 'Administrator',
-		'name': 'FL00455',
-		'no_copy': None,
-		'oldfieldname': 'address',
-		'oldfieldtype': 'Small Text',
-		'options': None,
-		'owner': 'Administrator',
-		'parent': 'Account',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 0,
-		'print_hide': None,
-		'report_hide': None,
-		'reqd': None,
-		'search_index': None,
-		'trigger': None,
-		'width': None
-	},
-	{
-		'allow_on_submit': None,
-		'colour': None,
-		'creation': '2011-05-09 10:50:47',
+		'creation': '2011-03-21 11:13:07',
 		'default': None,
 		'depends_on': None,
 		'description': None,
@@ -950,12 +936,13 @@
 		'fieldtype': 'Section Break',
 		'hidden': None,
 		'icon': None,
-		'idx': 21,
+		'idx': 20,
 		'in_filter': None,
 		'label': 'TDS',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
-		'name': '000000169',
+		'name': '000013928',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': None,
 		'oldfieldtype': 'Section Break',
@@ -985,12 +972,13 @@
 		'fieldtype': 'Data',
 		'hidden': None,
 		'icon': None,
-		'idx': 22,
+		'idx': 21,
 		'in_filter': None,
 		'label': 'PAN Number',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00451',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'pan_number',
 		'oldfieldtype': 'Data',
@@ -1020,12 +1008,13 @@
 		'fieldtype': 'Select',
 		'hidden': None,
 		'icon': None,
-		'idx': 23,
+		'idx': 22,
 		'in_filter': None,
 		'label': 'TDS Applicable',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00452',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'tds_applicable',
 		'oldfieldtype': 'Select',
@@ -1055,12 +1044,13 @@
 		'fieldtype': 'Table',
 		'hidden': None,
 		'icon': None,
-		'idx': 24,
+		'idx': 23,
 		'in_filter': None,
 		'label': 'TDS Details',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00456',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'tds_details',
 		'oldfieldtype': 'Table',
@@ -1080,76 +1070,6 @@
 	{
 		'allow_on_submit': None,
 		'colour': None,
-		'creation': '2011-05-09 10:50:47',
-		'default': None,
-		'depends_on': None,
-		'description': None,
-		'docstatus': 0,
-		'doctype': 'DocField',
-		'fieldname': None,
-		'fieldtype': 'Section Break',
-		'hidden': None,
-		'icon': None,
-		'idx': 25,
-		'in_filter': None,
-		'label': 'Balances',
-		'modified': '2011-05-09 10:50:47',
-		'modified_by': 'Administrator',
-		'name': '000000170',
-		'no_copy': None,
-		'oldfieldname': None,
-		'oldfieldtype': 'Section Break',
-		'options': None,
-		'owner': 'Administrator',
-		'parent': 'Account',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 0,
-		'print_hide': None,
-		'report_hide': None,
-		'reqd': None,
-		'search_index': None,
-		'trigger': None,
-		'width': None
-	},
-	{
-		'allow_on_submit': None,
-		'colour': None,
-		'creation': '2010-08-08 17:08:51',
-		'default': None,
-		'depends_on': None,
-		'description': None,
-		'docstatus': 0,
-		'doctype': 'DocField',
-		'fieldname': 'account_balances',
-		'fieldtype': 'Table',
-		'hidden': None,
-		'icon': None,
-		'idx': 26,
-		'in_filter': None,
-		'label': 'Account Balances',
-		'modified': '2011-05-09 10:50:47',
-		'modified_by': 'Administrator',
-		'name': 'FL00446',
-		'no_copy': None,
-		'oldfieldname': 'account_balances',
-		'oldfieldtype': 'Table',
-		'options': 'Account Balance',
-		'owner': 'Administrator',
-		'parent': 'Account',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 1,
-		'print_hide': None,
-		'report_hide': None,
-		'reqd': None,
-		'search_index': None,
-		'trigger': None,
-		'width': None
-	},
-	{
-		'allow_on_submit': None,
-		'colour': None,
 		'creation': '2010-08-08 17:08:51',
 		'default': None,
 		'depends_on': None,
@@ -1160,12 +1080,13 @@
 		'fieldtype': 'Data',
 		'hidden': 1,
 		'icon': None,
-		'idx': 27,
+		'idx': 24,
 		'in_filter': None,
 		'label': 'Old Parent',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00447',
+		'no_column': None,
 		'no_copy': 1,
 		'oldfieldname': 'old_parent',
 		'oldfieldtype': 'Data',
@@ -1195,12 +1116,13 @@
 		'fieldtype': 'Int',
 		'hidden': 1,
 		'icon': None,
-		'idx': 28,
+		'idx': 25,
 		'in_filter': 1,
 		'label': 'Lft',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00448',
+		'no_column': None,
 		'no_copy': 1,
 		'oldfieldname': 'lft',
 		'oldfieldtype': 'Int',
@@ -1230,12 +1152,13 @@
 		'fieldtype': 'Int',
 		'hidden': 1,
 		'icon': None,
-		'idx': 29,
+		'idx': 26,
 		'in_filter': 1,
 		'label': 'Rgt',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00449',
+		'no_column': None,
 		'no_copy': 1,
 		'oldfieldname': 'rgt',
 		'oldfieldtype': 'Int',
@@ -1265,12 +1188,13 @@
 		'fieldtype': 'Small Text',
 		'hidden': None,
 		'icon': None,
-		'idx': 30,
+		'idx': 27,
 		'in_filter': None,
 		'label': 'Trash Reason',
-		'modified': '2011-05-09 10:50:47',
+		'modified': '2011-06-23 12:36:56',
 		'modified_by': 'Administrator',
 		'name': 'FL00457',
+		'no_column': None,
 		'no_copy': None,
 		'oldfieldname': 'trash_reason',
 		'oldfieldtype': 'Small Text',
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/material_management/search_criteria/stock_report/stock_report.py b/material_management/search_criteria/stock_report/stock_report.py
index cb413ea..1868794 100644
--- a/material_management/search_criteria/stock_report/stock_report.py
+++ b/material_management/search_criteria/stock_report/stock_report.py
@@ -34,13 +34,13 @@
   if item_code and not warehouse:
     war_list = sql("select distinct warehouse from `tabStock Ledger Entry` where item_code = %s", item_code)
     for d in war_list:
-      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and posting_date <= %s Order by posting_date DESC, posting_time DESC, name DESC LIMIT 1", (item_code, d[0], posting_date))
+      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (item_code, d[0], posting_date, '23:55'))
       cl_bal += act and flt(act[0][0]) or 0.00
       stock_val += act and flt(act[0][1]) or 0.00
   elif warehouse and not item_code:
     item_list = sql("select distinct item_code from `tabStock Ledger Entry` where warehouse = %s", warehouse)
     for d in item_list:
-      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and posting_date <= %s Order by posting_date DESC, posting_time DESC, name DESC LIMIT 1", (d[0], warehouse, posting_date))
+      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (d[0], warehouse, posting_date, '23:55'))
       cl_bal += act and flt(act[0][0]) or 0.00
       stock_val += act and flt(act[0][1]) or 0.00
   return cl_bal, stock_val
@@ -55,7 +55,8 @@
     r.append(closing_balance)
     r.append(stock_value)
   else:
-    det = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and posting_date <= %s Order by posting_date DESC, posting_time DESC, name DESC LIMIT 1", (r[col_idx['Item Code']], r[col_idx['Warehouse']], posting_date))
+    det = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (r[col_idx['Item Code']], r[col_idx['Warehouse']], posting_date, '23:55'))
+    
     r.append(det and flt(det[0][0]) or 0.00)
     r.append(det and flt(det[0][1]) or 0.00)
   cl_bal += flt(r[col_idx['Closing Balance']])
@@ -70,4 +71,4 @@
   l_row[col_idx['Stock UOM']] = '<b>TOTALS</b>'
 l_row[col_idx['Closing Balance']] = cl_bal
 l_row[col_idx['Stock Value']] = tot_stock
-out.append(l_row)
\ No newline at end of file
+out.append(l_row)
diff --git a/patches/patch.py b/patches/patch.py
index 334b656..768f7cb 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,6 +1,6 @@
 # REMEMBER to update this
 # ========================
-last_patch = 291
+last_patch = 293
 
 #-------------------------------------------
 
@@ -1161,5 +1161,9 @@
 			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')
+	elif patch_no == 293:
+		sql("delete from tabDocField where parent='Account' and fieldname='address'")
+		reload_doc('accounts', 'doctype', 'account')