Merge pull request #3725 from neilLasrado/test

Fixed test cases related to Time Logs
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index 05c1bc4..ecbf78c 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -190,8 +190,9 @@
 				if flt(p.allocated_amount) > flt(p.amount):
 					frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to JV amount {2}")
 						.format(p.idx, p.allocated_amount, p.amount))
-
-				if flt(p.allocated_amount) > unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number):
+				
+				invoice_outstanding = unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number)
+				if abs(flt(p.allocated_amount) - invoice_outstanding) > 0.009:
 					frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to invoice outstanding amount {2}")
 						.format(p.idx, p.allocated_amount, unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number)))
 
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index de4d280..6e88bfb 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -109,8 +109,13 @@
 		doc.ignore_pricing_rule = 1
 		if doctype == "Sales Invoice":
 			doc.is_pos = 0
+			
+		for tax in doc.get("taxes"):
+			if tax.charge_type == "Actual":
+				tax.tax_amount = -1 * tax.tax_amount
+					
 		doc.run_method("calculate_taxes_and_totals")
-
+		
 	def update_item(source_doc, target_doc, source_parent):
 		target_doc.qty = -1* source_doc.qty
 		if doctype == "Purchase Receipt":
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index f22b624..6b59cea 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -77,9 +77,6 @@
 			if not self.discount_amount_applied:
 				validate_taxes_and_charges(tax)
 				validate_inclusive_tax(tax, self.doc)
-				
-			if self.doc.meta.get_field("is_return") and self.doc.is_return and tax.charge_type == "Actual":
-				tax.tax_amount = -1 * tax.tax_amount
 
 			tax.item_wise_tax_detail = {}
 			tax_fields = ["total", "tax_amount_after_discount_amount",
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 07c2d56..1e238d6 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -94,10 +94,6 @@
 			tax_fields = ["total", "tax_amount_after_discount_amount",
 				"tax_amount_for_current_item", "grand_total_for_current_item",
 				"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
-			
-			if (frappe.meta.get_docfield(me.frm.doc.doctype, "is_return") && me.frm.doc.is_return 
-					&& tax.charge_type == "Actual")
-				tax.tax_amount = -1 * tax.tax_amount;
 
 			if (cstr(tax.charge_type) != "Actual" &&
 				!(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total"))
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 82446ed..faf3d98 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -300,7 +300,7 @@
 		order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", {
 			"item_code": args.item_code,
 			"warehouse": args.warehouse,
-			"qty": cint(args.qty)
+			"qty": abs(cint(args.qty))
 		}))
 
 def get_actual_batch_qty(batch_no,warehouse,item_code):