diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 60c974f262..a37e7a03e0 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -145,6 +145,13 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ }; } + // payroll entry + if(jvd.reference_type==="Payroll Entry") { + return { + query: "erpnext.hr.doctype.payroll_entry.payroll_entry.get_payroll_entries_for_jv", + }; + } + var out = { filters: [ [jvd.reference_type, "docstatus", "=", 1] diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py index c9d6290f26..0f2e5f4fa1 100644 --- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py @@ -525,3 +525,17 @@ def payroll_entry_has_bank_entries(name): response['submitted'] = 1 if bank_entries else 0 return response + +def get_payroll_entries_for_jv(doctype, txt, searchfield, start, page_len, filters): + print(doctype) + return frappe.db.sql(""" + select name from `tabPayroll Entry` + where `{key}` LIKE %(txt)s + and name not in + (select reference_name from `tabJournal Entry Account` + where reference_type="Payroll Entry") + order by name limit %(start)s, %(page_len)s""" + .format(key=searchfield), { + 'txt': "%%%s%%" % frappe.db.escape(txt), + 'start': start, 'page_len': page_len + })