Merge branch 'hotfix'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 86d30e0..90ae743 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.2.12'
+__version__ = '7.2.13'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 2a07389..534f965 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2385,7 +2385,7 @@
    "in_standard_filter": 0, 
    "label": "Sales Invoice Payment", 
    "length": 0, 
-   "no_copy": 0, 
+   "no_copy": 1, 
    "options": "Sales Invoice Payment", 
    "permlevel": 0, 
    "precision": "", 
@@ -3188,6 +3188,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -4182,7 +4183,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-11-09 14:18:24.760263", 
+ "modified": "2017-01-17 11:07:25.814402", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 2369143..57bceee 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -455,10 +455,12 @@
 		
 	def calculate_paid_amount(self):
 		paid_amount = base_paid_amount = 0.0
-		for payment in self.doc.get('payments'):
-			payment.base_amount = flt(payment.amount * self.doc.conversion_rate)
-			paid_amount += payment.amount
-			base_paid_amount += payment.base_amount
+
+		if self.doc.is_pos:
+			for payment in self.doc.get('payments'):
+				payment.base_amount = flt(payment.amount * self.doc.conversion_rate)
+				paid_amount += payment.amount
+				base_paid_amount += payment.base_amount
 
 		self.doc.paid_amount = flt(paid_amount, self.doc.precision("paid_amount"))
 		self.doc.base_paid_amount = flt(base_paid_amount, self.doc.precision("base_paid_amount"))
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py
index 7741263..8448fa2 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.py
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.py
@@ -290,10 +290,8 @@
 @frappe.whitelist()
 def get_start_end_dates(payroll_frequency, start_date=None):
 	'''Returns dict of start and end dates for given payroll frequency based on start_date'''
-	if not payroll_frequency:
-		frappe.throw(_("Please set Payroll Frequency first"))
 
-	if payroll_frequency == "Monthly" or payroll_frequency == "Bimonthly":
+	if payroll_frequency == "Monthly" or payroll_frequency == "Bimonthly" or payroll_frequency == "":
 		fiscal_year = get_fiscal_year(start_date)[0]
 		month = "%02d" % getdate(start_date).month
 		m = get_month_details(fiscal_year, month)
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 388f43e..0922f07 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -8,6 +8,8 @@
 from frappe import _
 
 from frappe.model.document import Document
+from erpnext.controllers.queries import get_filters_cond
+from frappe.desk.reportview import get_match_cond
 
 class Project(Document):
 	def get_feed(self):
@@ -215,12 +217,29 @@
 	}
 
 def get_users_for_project(doctype, txt, searchfield, start, page_len, filters):
-	return frappe.db.sql("""select name, concat_ws(' ', first_name, middle_name, last_name)
+	conditions = []
+	return frappe.db.sql("""select name, concat_ws(' ', first_name, middle_name, last_name) 
 		from `tabUser`
 		where enabled=1
-		and name not in ("Guest", "Administrator")
+			and name not in ("Guest", "Administrator") 
+			and ({key} like %(txt)s
+				or full_name like %(txt)s)
+			{fcond} {mcond}
 		order by
-		name asc""")
+			if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
+			if(locate(%(_txt)s, full_name), locate(%(_txt)s, full_name), 99999),
+			idx desc,
+			name, full_name
+		limit %(start)s, %(page_len)s""".format(**{
+			'key': searchfield,
+			'fcond': get_filters_cond(doctype, filters, conditions),
+			'mcond': get_match_cond(doctype)
+		}), {
+			'txt': "%%%s%%" % txt,
+			'_txt': txt.replace("%", ""),
+			'start': start,
+			'page_len': page_len
+		})
 
 @frappe.whitelist()
 def get_cost_center_name(project):
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 4b14d08..6f55a44 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -588,11 +588,13 @@
 	calculate_paid_amount: function(){
 		var me = this;
 		var paid_amount = base_paid_amount = 0.0;
-		$.each(this.frm.doc['payments'] || [], function(index, data){
-			data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount"));
-			paid_amount += data.amount;
-			base_paid_amount += data.base_amount;
-		})
+		if(this.frm.doc.is_pos) {
+			$.each(this.frm.doc['payments'] || [], function(index, data){
+				data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount"));
+				paid_amount += data.amount;
+				base_paid_amount += data.base_amount;
+			})
+		}
 
 		this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount"));
 		this.frm.doc.base_paid_amount = flt(base_paid_amount, precision("base_paid_amount"));
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index c5a03e6..16ae3fc 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -219,9 +219,9 @@
 
 			# validate qty during submit
 			if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty:
-				frappe.throw(_("Row {0}: Qty not available for {4} in warehouse {1} at posting time of the entry ({2} {3})".format(d.idx,
+				frappe.throw(_("Row {0}: Qty not available for {4} in warehouse {1} at posting time of the entry ({2} {3})").format(d.idx,
 					frappe.bold(d.s_warehouse), formatdate(self.posting_date),
-					format_time(self.posting_time), frappe.bold(d.item_code)))
+					format_time(self.posting_time), frappe.bold(d.item_code))
 					+ '<br><br>' + _("Available qty is {0}, you need {1}").format(frappe.bold(d.actual_qty),
 						frappe.bold(d.transfer_qty)),
 					NegativeStockError, title=_('Insufficient Stock'))
@@ -867,4 +867,4 @@
 			"basic_rate" : get_incoming_rate(args)
 		}
 
-	return ret
\ No newline at end of file
+	return ret