merge
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
index 708c015..06c014c 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js
@@ -35,16 +35,23 @@
 cur_frm.fields_dict.voucher_no.get_query = function(doc) {
 	if (!doc.account) msgprint("Please select Account first");
 	else {
-		return repl("select gle.voucher_no, gle.posting_date \
-			from `tabGL Entry` gle where gle.account = '%(acc)s' \
-			and gle.voucher_type = '%(dt)s' \
-			and gle.voucher_no LIKE '%s' \
-			and ifnull(gle.is_cancelled, 'No') = 'No'\
-			and (select sum(debit) - sum(credit) from `tabGL Entry` \
-				where against_voucher_type = '%(dt)s' and against_voucher = gle.voucher_no \
-				and ifnull(is_cancelled, 'No') = 'No') != 0 \
-			ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50 \
-		", {dt:doc.voucher_type, acc:doc.account});
+		return repl("select gle.voucher_no, gle.posting_date, gle.%(account_type)s \
+		    from `tabGL Entry` gle \
+		    where gle.account = '%(acc)s' \
+		    and gle.voucher_type = '%(dt)s' \
+			and gle.voucher_no like '%s' \
+		    and ifnull(gle.is_cancelled, 'No') = 'No' \
+		    and (ifnull(gle.against_voucher, '') = '' \
+		        or ifnull(gle.against_voucher, '') = gle.voucher_no ) \
+			and ifnull(gle.%(account_type)s, 0) > 0 \
+		    and (select ifnull(abs(sum(debit) - sum(credit)), 0) from `tabGL Entry` \
+		        where against_voucher_type = '%(dt)s' \
+		        and against_voucher = gle.voucher_no \
+		        and voucher_no != gle.voucher_no \
+		        and ifnull(is_cancelled, 'No') = 'No') != \
+		        abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \
+		    ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50", 
+			{dt:doc.voucher_type, acc:doc.account, account_type: doc.account_type});
 	}
 }
 
@@ -52,3 +59,12 @@
 	get_server_fields('get_voucher_details', '', '', doc, cdt, cdn, 1)
 }
 
+cur_frm.cscript.account = function(doc, cdt, cdn) {
+	wn.call({
+		doc: this.frm.doc,
+		method: "set_account_type",
+		callback: function(r) {
+			if(!r.exc) refresh_field("account_type");
+		}
+	});
+}
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
index ee33c3a..3978688 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
@@ -27,32 +27,32 @@
 	def __init__(self, doc, doclist):
 		self.doc = doc
 		self.doclist = doclist
-		self.acc_type = self.doc.account and webnotes.conn.sql("""select debit_or_credit 
-			from `tabAccount` where name = %s""", self.doc.account)[0][0].lower() or ''
-		self.dt = {
-			'Sales Invoice': 'Sales Invoice',
-			'Purchase Invoice': 'Purchase Invoice',
-			'Journal Voucher': 'Journal Voucher'
-		}
+	
+	def set_account_type(self):
+		self.doc.account_type = self.doc.account and \
+			webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
 		
 	def get_voucher_details(self):
-		tot_amt = webnotes.conn.sql("""
-			select sum(%s) from `tabGL Entry` where 
-			voucher_type = %s and voucher_no = %s 
+		total_amount = webnotes.conn.sql("""select %s from `tabGL Entry` 
+			where voucher_type = %s and voucher_no = %s 
 			and account = %s and ifnull(is_cancelled, 'No') = 'No'""" % 
-			(self.acc_type, '%s', '%s', '%s'), 
-			(self.dt[self.doc.voucher_type], self.doc.voucher_no, self.doc.account))
+			(self.doc.account_type, '%s', '%s', '%s'), 
+			(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
+			
+		total_amount = total_amount and flt(total_amount[0][0]) or 0
 		
-		outstanding = webnotes.conn.sql("""
+		reconciled_payment = webnotes.conn.sql("""
 			select sum(%s) - sum(%s) from `tabGL Entry` where 
 			against_voucher = %s and voucher_no != %s
 			and account = %s and ifnull(is_cancelled, 'No') = 'No'""" % 
-			((self.acc_type == 'debit' and 'credit' or 'debit'), self.acc_type, '%s', '%s', '%s'),
-			(self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
+			((self.doc.account_type == 'debit' and 'credit' or 'debit'), self.doc.account_type, 
+			 	'%s', '%s', '%s'), (self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
+			
+		reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0
 		
 		ret = {
-			'total_amount': flt(tot_amt[0][0]) or 0,	
-			'pending_amt_to_reconcile': flt(tot_amt[0][0]) - flt(outstanding[0][0]) or 0
+			'total_amount': total_amount,	
+			'pending_amt_to_reconcile': total_amount - reconciled_payment
 		}
 		
 		return ret
@@ -69,7 +69,7 @@
 
 	def get_gl_entries(self):
 		self.validate_mandatory()
-		dc = self.acc_type == 'debit' and 'credit' or 'debit'
+		dc = self.doc.account_type == 'debit' and 'credit' or 'debit'
 		
 		cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
 		cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
@@ -97,7 +97,7 @@
 				'Payment to Invoice Matching Tool Detail', self.doclist)
 			ch.voucher_no = d.get('voucher_no')
 			ch.posting_date = d.get('posting_date')
-			ch.amt_due =  self.acc_type == 'debit' and flt(d.get('amt_due')) \
+			ch.amt_due =  self.doc.account_type == 'debit' and flt(d.get('amt_due')) \
 				or -1*flt(d.get('amt_due'))
 			ch.total_amt = flt(d.get('total_amt'))
 			ch.against_account = d.get('against_account')
@@ -116,7 +116,7 @@
 			3. submit payment voucher
 		"""
 		if not self.doc.voucher_no or not webnotes.conn.sql("""select name from `tab%s` 
-				where name = %s""" % (self.dt[self.doc.voucher_type], '%s'), self.doc.voucher_no):
+				where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no):
 			msgprint("Please select valid Voucher No to proceed", raise_exception=1)
 		
 		lst = []
@@ -125,11 +125,11 @@
 				args = {
 					'voucher_no' : d.voucher_no,
 					'voucher_detail_no' : d.voucher_detail_no, 
-					'against_voucher_type' : self.dt[self.doc.voucher_type], 
+					'against_voucher_type' : self.doc.voucher_type, 
 					'against_voucher'  : self.doc.voucher_no,
 					'account' : self.doc.account, 
 					'is_advance' : 'No', 
-					'dr_or_cr' :  self.acc_type=='debit' and 'credit' or 'debit', 
+					'dr_or_cr' :  self.doc.account_type=='debit' and 'credit' or 'debit', 
 					'unadjusted_amt' : flt(d.amt_due),
 					'allocated_amt' : flt(d.amt_to_be_reconciled)
 				}
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
index ec3fa5b..10d946b 100644
--- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
+++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt
@@ -1,6 +1,6 @@
 [
  {
-  "creation": "2013-01-21 18:19:17", 
+  "creation": "2013-01-23 15:27:14", 
   "docstatus": 0, 
   "modified": "2013-01-23 17:11:27", 
   "modified_by": "Administrator", 
@@ -56,6 +56,13 @@
   "label": "Company", 
   "options": "Company", 
   "print_hide": 1
+ {
+  "doctype": "DocField", 
+  "fieldname": "account_type", 
+  "fieldtype": "Data", 
+  "hidden": 1, 
+  "label": "Account Type", 
+  "read_only": 1
  }, 
  {
   "doctype": "DocField", 
diff --git a/patches/january_2013/remove_landed_cost_master.py b/patches/january_2013/remove_landed_cost_master.py
new file mode 100644
index 0000000..01eefb4
--- /dev/null
+++ b/patches/january_2013/remove_landed_cost_master.py
@@ -0,0 +1,4 @@
+def execute():
+	import webnotes
+	webnotes.delete_doc("DocType", "Landed Cost Master")
+	webnotes.delete_doc("DocType", "Landed Cost Master Detail")
\ No newline at end of file
diff --git a/patches/january_2013/remove_unwanted_permission.py b/patches/january_2013/remove_unwanted_permission.py
new file mode 100644
index 0000000..deeb1b3
--- /dev/null
+++ b/patches/january_2013/remove_unwanted_permission.py
@@ -0,0 +1,13 @@
+def execute():
+	import webnotes
+	for dt in webnotes.conn.sql("""select name, issingle from tabDocType"""):
+		if dt[1]:
+			webnotes.conn.sql("""update tabDocPerm set report = 0 where parent = %s""", dt[0])
+		
+		
+		doctype = webnotes.model_wrapper("DocType", dt[0])
+		for pl in [1, 2, 3]:
+			if not doctype.doclist.get({"doctype": "DocField", "permlevel": pl}):
+				if doctype.doclist.get({"doctype":"DocPerm", "permlevel":pl}):
+					webnotes.conn.sql("""delete from `tabDocPerm` 
+						where parent = %s and permlevel = %s""", (dt[0], pl))
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 8d40839..3b013e4 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -156,4 +156,6 @@
 	"execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')",
 	"patches.january_2013.update_fraction_for_usd",
 	"patches.january_2013.enable_currencies",
+	"patches.january_2013.remove_unwanted_permission",
+	"patches.january_2013.remove_landed_cost_master",
 ]
\ No newline at end of file
diff --git a/patches/september_2012/all_permissions_patch.py b/patches/september_2012/all_permissions_patch.py
index ab06b71..8373d8a 100644
--- a/patches/september_2012/all_permissions_patch.py
+++ b/patches/september_2012/all_permissions_patch.py
@@ -16,7 +16,7 @@
 
 def stock_perms():
 	webnotes.conn.sql("""delete from `tabDocPerm`
-		where parent in ('Landed Cost Master', 'Landed Cost Wizard', 
+		where parent in ('Landed Cost Wizard', 
 		'Sales and Purchase Return Tool') and role='All' and permlevel=0""")
 		
 def account_perms():
diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js
index 124b02a..5ebe65f 100644
--- a/public/js/stock_analytics.js
+++ b/public/js/stock_analytics.js
@@ -53,6 +53,7 @@
 				formatter: this.check_formatter},
 			{id: "name", name: "Item", field: "name", width: 300,
 				formatter: this.tree_formatter},
+			{id: "stock_uom", name: "UOM", field: "stock_uom", width: 100},
 			{id: "brand", name: "Brand", field: "brand", width: 100},
 			{id: "opening", name: "Opening", field: "opening", hidden: true,
 				formatter: this.currency_formatter}
diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt
index 9f3ce75..a43ec93 100644
--- a/setup/doctype/company/company.txt
+++ b/setup/doctype/company/company.txt
@@ -1,6 +1,6 @@
 [
  {
-  "creation": "2013-01-10 16:34:22", 
+  "creation": "2013-01-22 16:50:36", 
   "docstatus": 0, 
   "modified": "2013-01-23 16:51:54", 
   "modified_by": "Administrator", 
diff --git a/stock/doctype/landed_cost_master/__init__.py b/stock/doctype/landed_cost_master/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/doctype/landed_cost_master/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/doctype/landed_cost_master/landed_cost_master.js b/stock/doctype/landed_cost_master/landed_cost_master.js
deleted file mode 100644
index 03e8a39..0000000
--- a/stock/doctype/landed_cost_master/landed_cost_master.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-// 
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
- 
-
-//--------- ONLOAD -------------
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-   
-}
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-   
-}
-
-cur_frm.fields_dict.landed_cost.grid.get_field('account_head').get_query = function(doc, cdt, cdn) {
-	return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable" or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND  tabAccount.name LIKE "%s"';
-}
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master/landed_cost_master.py b/stock/doctype/landed_cost_master/landed_cost_master.py
deleted file mode 100644
index 7f48feb..0000000
--- a/stock/doctype/landed_cost_master/landed_cost_master.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master/landed_cost_master.txt b/stock/doctype/landed_cost_master/landed_cost_master.txt
deleted file mode 100644
index 63b102c..0000000
--- a/stock/doctype/landed_cost_master/landed_cost_master.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-[
- {
-  "creation": "2013-01-10 16:34:27", 
-  "docstatus": 0, 
-  "modified": "2013-01-22 14:56:03", 
-  "modified_by": "Administrator", 
-  "owner": "Administrator"
- }, 
- {
-  "autoname": "field:title", 
-  "doctype": "DocType", 
-  "document_type": "Master", 
-  "module": "Stock", 
-  "name": "__common__"
- }, 
- {
-  "doctype": "DocField", 
-  "name": "__common__", 
-  "parent": "Landed Cost Master", 
-  "parentfield": "fields", 
-  "parenttype": "DocType", 
-  "permlevel": 0
- }, 
- {
-  "create": 1, 
-  "doctype": "DocPerm", 
-  "name": "__common__", 
-  "parent": "Landed Cost Master", 
-  "parentfield": "permissions", 
-  "parenttype": "DocType", 
-  "permlevel": 0, 
-  "read": 1, 
-  "report": 1, 
-  "submit": 0, 
-  "write": 1
- }, 
- {
-  "doctype": "DocType", 
-  "name": "Landed Cost Master"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "trash_reason", 
-  "fieldtype": "Small Text", 
-  "label": "Trash Reason", 
-  "oldfieldname": "trash_reason", 
-  "oldfieldtype": "Small Text", 
-  "read_only": 1
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "title", 
-  "fieldtype": "Data", 
-  "label": "Title", 
-  "oldfieldname": "title", 
-  "oldfieldtype": "Data"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "landed_cost_details", 
-  "fieldtype": "Section Break", 
-  "label": "Landed Cost Items", 
-  "oldfieldtype": "Section Break"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "landed_cost", 
-  "fieldtype": "Table", 
-  "label": "Landed Cost", 
-  "oldfieldname": "landed_cost", 
-  "oldfieldtype": "Table", 
-  "options": "Landed Cost Master Detail"
- }, 
- {
-  "doctype": "DocPerm", 
-  "role": "Purchase Manager"
- }, 
- {
-  "doctype": "DocPerm", 
-  "role": "System Manager"
- }, 
- {
-  "doctype": "DocPerm", 
-  "role": "Purchase User"
- }
-]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master/locale/_messages_doc.json b/stock/doctype/landed_cost_master/locale/_messages_doc.json
deleted file mode 100644
index 4f1ad63..0000000
--- a/stock/doctype/landed_cost_master/locale/_messages_doc.json
+++ /dev/null
@@ -1,8 +0,0 @@
-[
- "Trash Reason", 
- "Title", 
- "Landed Cost Master", 
- "Landed Cost", 
- "Landed Cost Items", 
- "Stock"
-]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master/locale/hi-doc.json b/stock/doctype/landed_cost_master/locale/hi-doc.json
deleted file mode 100644
index 41f3344..0000000
--- a/stock/doctype/landed_cost_master/locale/hi-doc.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "Landed Cost": "\u0906\u092f\u093e\u0924\u093f\u0924 \u092e\u093e\u0932 \u0915\u0940 \u0932\u093e\u0917\u0924", 
- "Landed Cost Items": "\u0906\u092f\u093e\u0924\u093f\u0924 \u092e\u093e\u0932 \u0915\u0940 \u0932\u093e\u0917\u0924 \u0906\u0907\u091f\u092e", 
- "Landed Cost Master": "\u0906\u092f\u093e\u0924\u093f\u0924 \u092e\u093e\u0932 \u0915\u0940 \u0932\u093e\u0917\u0924 \u092e\u093e\u0938\u094d\u091f\u0930", 
- "Stock": "\u0938\u094d\u091f\u0949\u0915", 
- "Title": "\u0936\u0940\u0930\u094d\u0937\u0915", 
- "Trash Reason": "\u091f\u094d\u0930\u0948\u0936 \u0915\u093e\u0930\u0923"
-}
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master_detail/__init__.py b/stock/doctype/landed_cost_master_detail/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/doctype/landed_cost_master_detail/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.py b/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.py
deleted file mode 100644
index 7f48feb..0000000
--- a/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt b/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt
deleted file mode 100644
index b1db6a3..0000000
--- a/stock/doctype/landed_cost_master_detail/landed_cost_master_detail.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2012-05-03 11:00:55", 
-  "modified_by": "Administrator", 
-  "modified": "2012-05-04 13:02:35"
- }, 
- {
-  "section_style": "Simple", 
-  "istable": 1, 
-  "name": "__common__", 
-  "colour": "White:FFF", 
-  "module": "Stock", 
-  "doctype": "DocType", 
-  "version": 1, 
-  "server_code_error": " "
- }, 
- {
-  "name": "__common__", 
-  "parent": "Landed Cost Master Detail", 
-  "oldfieldtype": "Data", 
-  "doctype": "DocField", 
-  "parenttype": "DocType", 
-  "permlevel": 0, 
-  "parentfield": "fields"
- }, 
- {
-  "name": "Landed Cost Master Detail", 
-  "doctype": "DocType"
- }, 
- {
-  "doctype": "DocField", 
-  "label": "Account Head", 
-  "oldfieldname": "account_head", 
-  "fieldname": "account_head", 
-  "fieldtype": "Link", 
-  "options": "Account"
- }, 
- {
-  "doctype": "DocField", 
-  "label": "Description", 
-  "oldfieldname": "description", 
-  "width": "300px", 
-  "fieldname": "description", 
-  "fieldtype": "Data"
- }
-]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master_detail/locale/_messages_doc.json b/stock/doctype/landed_cost_master_detail/locale/_messages_doc.json
deleted file mode 100644
index a8a7ba1..0000000
--- a/stock/doctype/landed_cost_master_detail/locale/_messages_doc.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- "Description", 
- "Landed Cost Master Detail", 
- "Account Head", 
- "Stock"
-]
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_master_detail/locale/hi-doc.json b/stock/doctype/landed_cost_master_detail/locale/hi-doc.json
deleted file mode 100644
index ee50455..0000000
--- a/stock/doctype/landed_cost_master_detail/locale/hi-doc.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "Account Head": "\u0932\u0947\u0916\u093e\u0936\u0940\u0930\u094d\u0937", 
- "Description": "\u0935\u093f\u0935\u0930\u0923", 
- "Landed Cost Master Detail": "\u0909\u0924\u0930\u093e \u0932\u093e\u0917\u0924 \u092e\u093e\u0938\u094d\u091f\u0930 \u0935\u093f\u0938\u094d\u0924\u093e\u0930", 
- "Stock": "\u0938\u094d\u091f\u0949\u0915"
-}
\ No newline at end of file
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
index 7067e52..f2bc799 100644
--- a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
@@ -56,19 +56,6 @@
 			ch.purchase_receipt = i and i['name'] or ''
 			ch.save()
 
-
-	def get_landed_cost_master_details(self):
-		""" pull details from landed cost master"""
-		self.doclist = self.doc.clear_table(self.doclist, 'landed_cost_details')
-		idx = 0
-		landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
-		for cost in landed_cost:
-			lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item', 
-				self.doclist)
-			lct.account_head = cost['account_head']
-			lct.description = cost['description']
-
-
 	def get_selected_pr(self):
 		""" Get selected purchase receipt no """
 		self.selected_pr = [d.purchase_receipt for d in getlist(self.doclist, 'lc_pr_details') if d.select_pr]
@@ -199,9 +186,6 @@
 		ocd[oc].total_tax_amount = flt(prev_total)
 		ocd[oc].tax_amount += flt(tax_amount)
 		
-		total_amount = flt(ocd[oc].tax_amount)
-		total_tax_amount = flt(ocd[oc].total_tax_amount) + (add_ded * flt(total_amount))
-		
 		if ocd[oc].category != "Valuation":	
 			prev_total += add_ded * flt(ocd[oc].total_amount)
 			total += add_ded * flt(ocd[oc].tax_amount)
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt b/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt
index 4e820a8..d27fa83 100644
--- a/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt
@@ -1,6 +1,6 @@
 [
  {
-  "creation": "2013-01-10 16:34:28", 
+  "creation": "2013-01-22 16:50:39", 
   "docstatus": 0, 
   "modified": "2013-01-22 16:54:49", 
   "modified_by": "Administrator", 
@@ -29,7 +29,7 @@
   "parenttype": "DocType", 
   "permlevel": 0, 
   "read": 1, 
-  "report": 1, 
+  "report": 0, 
   "submit": 0, 
   "write": 1
  }, 
@@ -94,20 +94,6 @@
  }, 
  {
   "doctype": "DocField", 
-  "fieldname": "landed_cost", 
-  "fieldtype": "Link", 
-  "label": "Select Landed Cost Items Master", 
-  "options": "Landed Cost Master"
- }, 
- {
-  "doctype": "DocField", 
-  "fieldname": "get_details", 
-  "fieldtype": "Button", 
-  "label": "Get Details", 
-  "options": "get_landed_cost_master_details"
- }, 
- {
-  "doctype": "DocField", 
   "fieldname": "landed_cost_details", 
   "fieldtype": "Table", 
   "label": "Landed Cost Items", 
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 9017843..32fcf89 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -141,11 +141,18 @@
 				"posting_time": self.doc.posting_time
 			})
 			
+			# check valuation rate mandatory
+			if row.qty != "" and not row.valuation_rate and \
+					flt(previous_sle.get("qty_after_transaction")) <= 0:
+				webnotes.msgprint(_("As existing qty for item: ") + row.item_code + 
+					_(" is less than equals to zero in the system, \
+						valuation rate is mandatory for this item"), raise_exception=1)
+			
 			change_in_qty = row.qty != "" and \
 				(flt(row.qty) - flt(previous_sle.get("qty_after_transaction")))
-		
+			
 			change_in_rate = row.valuation_rate != "" and \
-				(flt(row.valuation_rate) != flt(previous_sle.get("valuation_rate")))
+				(flt(row.valuation_rate) - flt(previous_sle.get("valuation_rate")))
 			
 			if get_valuation_method(row.item_code) == "Moving Average":
 				self.sle_for_moving_avg(row, previous_sle, change_in_qty, change_in_rate)
@@ -162,7 +169,6 @@
 			else:
 				if valuation_rate == "":
 					valuation_rate = previous_valuation_rate
-				
 				return (qty * valuation_rate - previous_qty * previous_valuation_rate) \
 					/ flt(qty - previous_qty)
 		
@@ -175,7 +181,7 @@
 			self.insert_entries({"actual_qty": change_in_qty, 
 				"incoming_rate": incoming_rate}, row)
 			
-		elif change_in_rate and flt(previous_sle.get("qty_after_transaction")) >= 0:
+		elif change_in_rate and flt(previous_sle.get("qty_after_transaction")) > 0:
 			# if no change in qty, but change in rate 
 			# and positive actual stock before this reconciliation
 			incoming_rate = _get_incoming_rate(
@@ -241,7 +247,6 @@
 			"is_cancelled": "No",
 		}
 		args.update(opts)
-
 		# create stock ledger entry
 		sle_wrapper = webnotes.model_wrapper([args])
 		sle_wrapper.ignore_permissions = 1
diff --git a/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
index b3501ce..7030c1b 100644
--- a/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
@@ -21,7 +21,6 @@
 from webnotes.tests import insert_test_data
 from webnotes.utils import flt
 import json
-from pprint import pprint
 
 company = webnotes.conn.get_default("company")
 
diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js
index 780fb86..1684726 100644
--- a/stock/page/stock_ageing/stock_ageing.js
+++ b/stock/page/stock_ageing/stock_ageing.js
@@ -48,13 +48,14 @@
 					open_btn: true,
 					doctype: '"Item"'
 				}},
-			{id: "brand", name: "Brand", field: "brand", width: 100},
 			{id: "average_age", name: "Average Age", field: "average_age",
 				formatter: this.currency_formatter},
 			{id: "earliest", name: "Earliest", field: "earliest",
 				formatter: this.currency_formatter},
 			{id: "latest", name: "Latest", field: "latest",
 				formatter: this.currency_formatter},
+			{id: "stock_uom", name: "UOM", field: "stock_uom", width: 100},
+			{id: "brand", name: "Brand", field: "brand", width: 100},
 			{id: "item_name", name: "Item Name", field: "item_name", 
 				width: 100, formatter: this.text_formatter},
 			{id: "description", name: "Description", field: "description", 
diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js
index 536d435..bec1337 100644
--- a/stock/page/stock_balance/stock_balance.js
+++ b/stock/page/stock_balance/stock_balance.js
@@ -60,7 +60,7 @@
 				formatter: this.currency_formatter},
 			{id: "closing_value", name: "Closing Value", field: "closing_value", width: 100, 
 				formatter: this.currency_formatter},
-				
+			{id: "stock_uom", name: "UOM", field: "stock_uom", width: 100},
 			{id: "brand", name: "Brand", field: "brand", width: 100},
 			{id: "item_name", name: "Item Name", field: "item_name", width: 100},
 			{id: "description", name: "Description", field: "description", width: 200, 
diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js
index 7ea62de..ec03999 100644
--- a/stock/page/stock_home/stock_home.js
+++ b/stock/page/stock_home/stock_home.js
@@ -79,11 +79,6 @@
 				description: wn._("Incoming quality inspection.")
 			},
 			{
-				"doctype":"Landed Cost Master",
-				"label":"Landed Cost Master",
-				description: wn._("Transportatoin cost distribution template.")
-			},
-			{
 				"route":"Form/Landed Cost Wizard/Landed Cost Wizard",
 				"label": wn._("Landed Cost Wizard"),
 				description: wn._("Distribute transport overhead across items."),
diff --git a/utilities/cleanup_data.py b/utilities/cleanup_data.py
index 6f790da..92c41a3 100644
--- a/utilities/cleanup_data.py
+++ b/utilities/cleanup_data.py
@@ -64,7 +64,6 @@
 		'Letter Head':'',
 		'Leave Type':['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP', 
 			'Compensatory Off', 'Sick Leave'],
-		'Landed Cost Master':'',
 		'Appraisal Template':'',
 		'Item Group':['All Item Groups', 'Default'], 
 		'Item':'',