From 73456ac81ac2b1662123b17e767e1d8ecb6ead8d Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 16 May 2017 11:29:57 +0530 Subject: [PATCH] [fix] Payments on the invoice is showing even if IS POS option is disabled (#8802) --- erpnext/controllers/taxes_and_totals.py | 2 ++ erpnext/patches.txt | 3 ++- ...ke_payments_table_blank_for_non_pos_invoice.py | 15 +++++++++++++++ erpnext/public/js/controllers/taxes_and_totals.js | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v8_0/make_payments_table_blank_for_non_pos_invoice.py diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 7889ead0574..c1c1fd7cda4 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -465,6 +465,8 @@ class calculate_taxes_and_totals(object): 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 8907cf3e162..81367937a58 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -393,4 +393,5 @@ erpnext.patches.v7_2.stock_uom_in_selling 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 00000000000..9750fb72222 --- /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 c925f4577b1..849275f02cd 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -594,6 +594,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ 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"));