Merge branch 'version-13-beta-pre-release' into version-13-beta
diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py
index 2b91c74..c26e14f 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py
+++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py
@@ -57,7 +57,11 @@
 		if not invalid_rows:
 			return
 
-		error_list = [_("Row #{}: {}").format(row.get('idx'), row.get('msg')) for row in invalid_rows]
+		error_list = []
+		for row in invalid_rows:
+			for msg in row.get('msg'):
+				error_list.append(_("Row #{}: {}").format(row.get('idx'), msg))
+
 		frappe.throw(error_list, title=_("Invalid POS Invoices"), as_list=True)
 
 	def on_submit(self):
diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
index add27e9..5e43cfe 100644
--- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
+++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
@@ -5,10 +5,10 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
-from frappe.utils import cint, flt, add_months, today, date_diff, getdate, add_days, cstr, nowdate
-from frappe.model.document import Document
-from frappe.model.mapper import map_doc
 from frappe.model import default_fields
+from frappe.model.document import Document
+from frappe.model.mapper import map_doc, map_child_doc
+from frappe.utils import cint, flt, add_months, today, date_diff, getdate, add_days, cstr, nowdate
 
 from six import iteritems
 
@@ -83,7 +83,7 @@
 
 		credit_note.is_consolidated = 1
 		# TODO: return could be against multiple sales invoice which could also have been consolidated?
-		credit_note.return_against = self.consolidated_invoice
+		# credit_note.return_against = self.consolidated_invoice
 		credit_note.save()
 		credit_note.submit()
 		self.consolidated_credit_note = credit_note.name
@@ -111,7 +111,8 @@
 						i.qty = i.qty + item.qty
 				if not found:
 					item.rate = item.net_rate
-					items.append(item)
+					si_item = map_child_doc(item, invoice, {"doctype": "Sales Invoice Item"})
+					items.append(si_item)
 			
 			for tax in doc.get('taxes'):
 				found = False
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index a048d6e..0e1829a 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -262,6 +262,7 @@
 
 		if doc.get("is_return"):
 			if doc.doctype == 'Sales Invoice' or doc.doctype == 'POS Invoice':
+				doc.consolidated_invoice = ""
 				doc.set('payments', [])
 				for data in source.payments:
 					paid_amount = 0.00
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 9e022da..6e28865 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -743,6 +743,7 @@
 erpnext.patches.v13_0.create_leave_policy_assignment_based_on_employee_current_leave_policy
 erpnext.patches.v13_0.add_po_to_global_search
 erpnext.patches.v13_0.update_returned_qty_in_pr_dn
+erpnext.patches.v13_0.create_uae_pos_invoice_fields
 erpnext.patches.v13_0.update_project_template_tasks
 erpnext.patches.v13_0.set_company_in_leave_ledger_entry
 erpnext.patches.v13_0.convert_qi_parameter_to_link_field
diff --git a/erpnext/patches/v13_0/create_uae_pos_invoice_fields.py b/erpnext/patches/v13_0/create_uae_pos_invoice_fields.py
new file mode 100644
index 0000000..48d5cb4
--- /dev/null
+++ b/erpnext/patches/v13_0/create_uae_pos_invoice_fields.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2019, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+from erpnext.regional.united_arab_emirates.setup import make_custom_fields
+
+def execute():
+	company = frappe.get_all('Company', filters = {'country': ['in', ['Saudi Arabia', 'United Arab Emirates']]})
+	if not company:
+		return
+
+	make_custom_fields()
\ No newline at end of file