[fix] Payments on the invoice is showing even if IS POS option is disabled (#8802)

diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 7889ead..c1c1fd7 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -465,6 +465,8 @@
 				payment.base_amount = flt(payment.amount * self.doc.conversion_rate)
 				paid_amount += payment.amount
 				base_paid_amount += payment.base_amount
+		elif not self.doc.is_return:
+			self.doc.set('payments', [])
 
 		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/patches.txt b/erpnext/patches.txt
index 8907cf3..8136793 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -393,4 +393,5 @@
 erpnext.patches.v8_0.revert_manufacturers_table_from_item
 erpnext.patches.v8_0.disable_instructor_role
 erpnext.patches.v8_0.merge_student_batch_and_student_group
-erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017
\ No newline at end of file
+erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017
+erpnext.patches.v8_0.make_payments_table_blank_for_non_pos_invoice
\ No newline at end of file
diff --git a/erpnext/patches/v8_0/make_payments_table_blank_for_non_pos_invoice.py b/erpnext/patches/v8_0/make_payments_table_blank_for_non_pos_invoice.py
new file mode 100644
index 0000000..9750fb7
--- /dev/null
+++ b/erpnext/patches/v8_0/make_payments_table_blank_for_non_pos_invoice.py
@@ -0,0 +1,15 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doctype('Sales Invoice')
+
+	frappe.db.sql("""
+		delete from 
+			`tabSales Invoice Payment` 
+		where 
+			parent in (select name from `tabSales Invoice` where is_pos = 0)
+	""")
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index c925f45..849275f 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -594,6 +594,8 @@
 				paid_amount += data.amount;
 				base_paid_amount += data.base_amount;
 			})
+		} else if(!this.frm.doc.is_return){
+			this.frm.doc.payments = [];
 		}
 
 		this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount"));