[HotFix] Taxes not adding in POS sales invoice (#13776)

diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index bb2d071..2fcca75 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -319,6 +319,7 @@
 	},
 
 	pos_profile: function() {
+		this.frm.doc.taxes = []
 		this.set_pos_data();
 	},
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index d822052..b174d9b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -344,8 +344,8 @@
 				self.terms = frappe.db.get_value("Terms and Conditions", self.tc_name, "terms")
 
 			# fetch charges
-			if self.taxes_and_charges:
-				self.set_other_charges()
+			if self.taxes_and_charges and not len(self.get("taxes")):
+				self.set_taxes()
 
 		return pos
 
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index d690241..4cca720 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -232,7 +232,7 @@
 
 		tax_master_doctype = self.meta.get_field("taxes_and_charges").options
 
-		if self.is_new() and not self.get("taxes"):
+		if (self.is_new() or self.is_pos_profile_changed()) and not self.get("taxes"):
 			if self.company and not self.get("taxes_and_charges"):
 				# get the default tax master
 				self.taxes_and_charges = frappe.db.get_value(tax_master_doctype,
@@ -240,6 +240,11 @@
 
 			self.append_taxes_from_master(tax_master_doctype)
 
+	def is_pos_profile_changed(self):
+		if (self.doctype == 'Sales Invoice' and self.is_pos and
+			self.pos_profile != frappe.db.get_value('Sales Invoice', self.name, 'pos_profile')):
+			return True
+
 	def append_taxes_from_master(self, tax_master_doctype=None):
 		if self.get("taxes_and_charges"):
 			if not tax_master_doctype:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 410636f..3e035b1 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -498,4 +498,5 @@
 erpnext.patches.v10_0.update_hub_connector_domain
 erpnext.patches.v10_0.set_student_party_type
 erpnext.patches.v10_0.update_project_in_sle
-erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
\ No newline at end of file
+erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
+erpnext.patches.v10_0.taxes_issue_with_pos
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/taxes_issue_with_pos.py b/erpnext/patches/v10_0/taxes_issue_with_pos.py
new file mode 100644
index 0000000..5d6b786
--- /dev/null
+++ b/erpnext/patches/v10_0/taxes_issue_with_pos.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	for d in frappe.get_all('Sales Invoice', fields=["name"],
+		filters = {'is_pos':1, 'docstatus': 1, 'creation': ('>', '2018-04-23')}):
+		doc = frappe.get_doc('Sales Invoice', d.name)
+		if (not doc.taxes and doc.taxes_and_charges and doc.pos_profile and
+			frappe.db.get_value('POS Profile', doc.pos_profile, 'taxes_and_charges', cache=True) == doc.taxes_and_charges):
+
+			doc.append_taxes_from_master()
+			doc.calculate_taxes_and_totals()
+			for d in doc.taxes:
+				d.db_update()
+
+			doc.db_update()
+
+			delete_gle_for_voucher(doc.name)
+			doc.make_gl_entries()
+
+def delete_gle_for_voucher(voucher_no):
+	frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
+		{'voucher_no': voucher_no})
\ No newline at end of file