Merge pull request #3753 from nabinhait/return1

[fix] Actual tax amount should be negative while creating return entry
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/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 7cbc596..d1ec4b1 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -238,7 +238,7 @@
 	ret = {'total_leave_days' : 0.5}
 	if not leave_app.half_day:
 		tot_days = date_diff(leave_app.to_date, leave_app.from_date) + 1
-		if frappe.db.get_value("Leave Type", self.leave_type, "include_holiday"):
+		if frappe.db.get_value("Leave Type", leave_app.leave_type, "include_holiday"):
 			holidays = leave_app.get_holidays()
 			ret = {
 				'total_leave_days' : flt(tot_days)-flt(holidays)
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):