Test case for landed cost voucher
diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py
index 3774629..bb9102f 100644
--- a/erpnext/accounts/doctype/account/test_account.py
+++ b/erpnext/accounts/doctype/account/test_account.py
@@ -14,6 +14,7 @@
 		["_Test Account Stock Expenses", "Direct Expenses", "Group", None],
 		["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"],
 		["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger", "Tax"],
+		["_Test Account Insurance Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"],
 		
 		
 		["_Test Account Tax Assets", "Current Assets", "Group", None],
diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
new file mode 100644
index 0000000..6abf2f5
--- /dev/null
+++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
@@ -0,0 +1,68 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+
+from __future__ import unicode_literals
+import unittest
+import frappe
+from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
+	import set_perpetual_inventory, get_gl_entries, test_records as pr_test_records
+
+
+class TestLandedCostVoucher(unittest.TestCase):
+	def test_landed_cost_voucher(self):
+		frappe.db.set_default("cost_center", "Main - _TC")
+		set_perpetual_inventory(1)
+		pr = self.submit_pr()
+		self.submit_landed_cost_voucher(pr)
+		
+		pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
+		self.assertEquals(pr_lc_value, 25.0)
+		
+		gl_entries = get_gl_entries("Purchase Receipt", pr.name)
+
+		self.assertTrue(gl_entries)
+
+		stock_in_hand_account = pr.get("purchase_receipt_details")[0].warehouse
+		fixed_asset_account = pr.get("purchase_receipt_details")[1].warehouse
+		
+
+		expected_values = {
+			stock_in_hand_account: [400.0, 0.0],
+			fixed_asset_account: [400.0, 0.0],
+			"Stock Received But Not Billed - _TC": [0.0, 750.0],
+			"Expenses Included In Valuation - _TC": [0.0, 50.0]
+		}
+
+		for gle in gl_entries:
+			self.assertEquals(expected_values[gle.account][0], gle.debit)
+			self.assertEquals(expected_values[gle.account][1], gle.credit)
+
+		set_perpetual_inventory(0)
+		
+	def submit_landed_cost_voucher(self, pr):
+		lcv = frappe.new_doc("Landed Cost Voucher")
+		lcv.company = "_Test Company"
+		lcv.set("landed_cost_purchase_receipts", [{
+			"purchase_receipt": pr.name,
+			"supplier": pr.supplier,
+			"posting_date": pr.posting_date,
+			"grand_total": pr.grand_total
+		}])
+		lcv.set("landed_cost_taxes_and_charges", [{
+			"description": "Insurance Charges",
+			"account": "_Test Account Insurance Charges - _TC",
+			"amount": 50.0
+		}])
+		
+		lcv.insert()
+		lcv.submit()
+		
+	def submit_pr(self):
+		pr = frappe.copy_doc(pr_test_records[0])
+		pr.submit()
+		return pr
+		
+	
+
+test_records = frappe.get_test_records('Landed Cost Voucher')
\ No newline at end of file
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 57075a9..0166de5 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -289,7 +289,6 @@
 		stock_rbnb = self.get_company_default("stock_received_but_not_billed")
 		expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
 		default_cost_center = self.get_company_default("cost_center")
-		against_expense_account = None
 		
 		gl_entries = []
 		warehouse_with_no_account = []
@@ -301,7 +300,7 @@
 					# warehouse account
 					gl_entries.append(self.get_gl_dict({
 						"account": warehouse_account[d.warehouse],
-						"against": against_expense_account,
+						"against": stock_rbnb,
 						"cost_center": d.cost_center,
 						"remarks": self.get("remarks") or "Accounting Entry for Stock",
 						"debit": flt(d.valuation_rate) * flt(d.qty) * flt(d.conversion_factor)
@@ -313,7 +312,7 @@
 						"against": warehouse_account[d.warehouse],
 						"cost_center": d.cost_center,
 						"remarks": self.get("remarks") or "Accounting Entry for Stock",
-						"credit": flt(d.base_amount, 2)
+						"credit": flt(d.base_amount + d.item_tax_amount, self.precision("base_amount", d))
 					}))
 					
 					# Amount added through landed-cost-voucher
@@ -339,35 +338,6 @@
 				elif d.warehouse not in warehouse_with_no_account or \
 					d.rejected_warehouse not in warehouse_with_no_account:
 						warehouse_with_no_account.append(d.warehouse)
-		
-		# Cost center-wise amount breakup for other charges included for valuation
-		valuation_tax = {}
-		for tax in self.get("other_charges"):
-			if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
-				if not tax.cost_center:
-					frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
-				valuation_tax.setdefault(tax.cost_center, 0)
-				valuation_tax[tax.cost_center] += \
-					(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
-					
-		# Backward compatibility:
-		# If PI exists and charges added via Landed Cost Voucher, 
-		# post valuation related charges on "Stock Received But Not Billed" 
-		# as that account has been debited in PI
-		if frappe.db.get_value("Purchase Invoice Item", {"purchase_receipt": self.name, "docstatus": 1}):
-			expenses_included_in_valuation = stock_rbnb
-			
-		# Expense included in valuation
-		for cost_center, amount in valuation_tax.items():
-			gl_entries.append(
-				self.get_gl_dict({
-					"account": expenses_included_in_valuation,
-					"cost_center": cost_center,
-					# "against": ,
-					"credit": amount,
-					"remarks": self.remarks or "Accounting Entry for Stock"
-				})
-			)
 
 		if warehouse_with_no_account:
 			msgprint(_("No accounting entries for the following warehouses") + ": \n" +