From d391e8150557004164a12666a5b5b251e7756042 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 29 Sep 2023 13:40:59 +0530 Subject: [PATCH] refactor: block Payment Entry as ref in JE from UI --- .../accounts/doctype/journal_entry/journal_entry.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index cdd1203d49..22b6880ad5 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -53,7 +53,15 @@ frappe.ui.form.on("Journal Entry", { erpnext.accounts.unreconcile_payments.add_unreconcile_btn(frm); }, - + before_save: function(frm) { + if ((frm.doc.docstatus == 0) && (!frm.doc.is_system_generated)) { + let payment_entry_references = frm.doc.accounts.filter(elem => (elem.reference_type == "Payment Entry")); + if (payment_entry_references.length > 0) { + let rows = payment_entry_references.map(x => "#"+x.idx); + frappe.throw(__("Rows: {0} have 'Payment Entry' as reference_type. This should not be set manually.", [frappe.utils.comma_and(rows)])); + } + } + }, make_inter_company_journal_entry: function(frm) { var d = new frappe.ui.Dialog({ title: __("Select Company"),