Merge pull request #2076 from anandpdoshi/anand-august-19

[fix] Error Reports
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 68a21d9..af7c85a 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -273,10 +273,10 @@
 	def make_gl_entries(self):
 		auto_accounting_for_stock = \
 			cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
-			
+
 		stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed")
 		expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
-		
+
 		gl_entries = []
 
 		# parent's gl entry
@@ -329,32 +329,31 @@
 						"cost_center": item.cost_center
 					})
 				)
-			
+
 			if auto_accounting_for_stock and item.item_code in stock_items and item.item_tax_amount:
 					# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
 					negative_expense_booked_in_pi = None
 					if item.purchase_receipt:
 						negative_expense_booked_in_pi = frappe.db.sql("""select name from `tabGL Entry`
-							where voucher_type='Purchase Receipt' and voucher_no=%s and account=%s""", 
+							where voucher_type='Purchase Receipt' and voucher_no=%s and account=%s""",
 							(item.purchase_receipt, expenses_included_in_valuation))
-					
+
 					if not negative_expense_booked_in_pi:
 						gl_entries.append(
 							self.get_gl_dict({
 								"account": stock_received_but_not_billed,
 								"against": self.credit_to,
-								"debit": flt(item.item_tax_amount),
+								"debit": flt(item.item_tax_amount, self.precision("item_tax_amount", item)),
 								"remarks": self.remarks or "Accounting Entry for Stock"
 							})
 						)
-						
-						negative_expense_to_be_booked += flt(item.item_tax_amount)
 
+						negative_expense_to_be_booked += flt(item.item_tax_amount, self.precision("item_tax_amount", item))
 
 		if negative_expense_to_be_booked and valuation_tax:
 			# credit valuation tax amount in "Expenses Included In Valuation"
 			# this will balance out valuation amount included in cost of goods sold
-			
+
 			total_valuation_amount = sum(valuation_tax.values())
 			amount_including_divisional_loss = negative_expense_to_be_booked
 			i = 1
@@ -364,7 +363,7 @@
 				else:
 					applicable_amount = negative_expense_to_be_booked * (amount / total_valuation_amount)
 					amount_including_divisional_loss -= applicable_amount
-				
+
 				gl_entries.append(
 					self.get_gl_dict({
 						"account": expenses_included_in_valuation,
@@ -374,7 +373,7 @@
 						"remarks": self.remarks or "Accounting Entry for Stock"
 					})
 				)
-				
+
 				i += 1
 
 		# writeoff account includes petty difference in the invoice amount
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 3df62e7..59a49af 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -209,7 +209,7 @@
 
 	def calculate_taxes(self):
 		# maintain actual tax rate based on idx
-		actual_tax_dict = dict([[tax.idx, tax.rate] for tax in self.tax_doclist
+		actual_tax_dict = dict([[tax.idx, flt(tax.rate, self.precision("tax_amount", tax))] for tax in self.tax_doclist
 			if tax.charge_type == "Actual"])
 
 		for n, item in enumerate(self.item_doclist):
diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js
index dd11fab..801ea57 100644
--- a/erpnext/public/js/transaction.js
+++ b/erpnext/public/js/transaction.js
@@ -647,7 +647,7 @@
 		// maintain actual tax rate based on idx
 		$.each(this.frm.tax_doclist, function(i, tax) {
 			if (tax.charge_type == "Actual") {
-				actual_tax_dict[tax.idx] = flt(tax.rate);
+				actual_tax_dict[tax.idx] = flt(tax.rate, precision("tax_amount", tax));
 			}
 		});