Trial Balance : with/without closing entry
diff --git a/accounts/page/trial_balance/trial_balance.js b/accounts/page/trial_balance/trial_balance.js
index 9ea7666..e5cfe5e 100644
--- a/accounts/page/trial_balance/trial_balance.js
+++ b/accounts/page/trial_balance/trial_balance.js
@@ -23,6 +23,20 @@
 		single_column: true
 	});
 	var TrialBalance = erpnext.AccountTreeGrid.extend({
+		init: function(wrapper, title) {
+			var me = this;
+			this._super(wrapper, title);
+			
+			// period closing entry checkbox
+			this.wrapper.bind("make", function() {
+				$('<div style="margin: 10px 0px; "\
+				 	class="with_period_closing_entry"><input type="checkbox" checked="checked">\
+					With period closing entry</div>')
+					.appendTo(me.wrapper)
+					.find("input").click(function() { me.refresh(); });
+			});
+		},
+		
 		export: function() {
 			var msgbox = msgprint('<p>Select To Download:</p>\
 				<p><input type="checkbox" name="with_groups" checked> Account Groups</p>\
@@ -53,6 +67,25 @@
 
 			return false;
 		},
+		
+		prepare_balances: function() {
+			// store value of with closing entry
+			this.with_period_closing_entry = this.wrapper
+				.find(".with_period_closing_entry input:checked").length;
+			this._super();
+		},
+		
+		update_balances: function(account, posting_date, v) {
+			// for period closing voucher, 
+			// only consider them when adding "With Closing Entry is checked"
+			if(v.voucher_type === "Period Closing Voucher") {
+				if(this.with_period_closing_entry) {
+					this._super(account, posting_date, v);
+				}
+			} else {
+				this._super(account, posting_date, v);
+			}
+		},
 	})
 	erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance');
 	
diff --git a/public/js/account_tree_grid.js b/public/js/account_tree_grid.js
index 4c669a9..a893a52 100644
--- a/public/js/account_tree_grid.js
+++ b/public/js/account_tree_grid.js
@@ -51,20 +51,21 @@
 
 	},
 	filters: [
-		{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
+		{fieldtype: "Select", label: "Company", link:"Company", default_value: "Select Company...",
 			filter: function(val, item, opts, me) {
 				if (item.company == val || val == opts.default_value) {
 					return me.apply_zero_filter(val, item, opts, me);
 				}
 				return false;
 			}},
-		{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year", 
+		{fieldtype: "Select", label: "Fiscal Year", link:"Fiscal Year", 
 			default_value: "Select Fiscal Year..."},
-		{fieldtype:"Date", label: "From Date"},
-		{fieldtype:"Label", label: "To"},
-		{fieldtype:"Date", label: "To Date"},
-		{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
-		{fieldtype:"Button", label: "Reset Filters"}
+		{fieldtype: "Date", label: "From Date"},
+		{fieldtype: "Label", label: "To"},
+		{fieldtype: "Date", label: "To Date"},
+		{fieldtype: "Button", label: "Refresh", icon:"icon-refresh icon-white",
+		 	cssClass:"btn-info"},
+		{fieldtype: "Button", label: "Reset Filters"},
 	],
 	setup_filters: function() {
 		this._super();
@@ -81,6 +82,7 @@
 			me.set_route();
 		});
 		me.show_zero_check()
+		if(me.ignore_closing_entry) me.ignore_closing_entry();
 	},
 	prepare_data: function() {
 		var me = this;