fix: add set query for payroll entry in JV

This commit is contained in:
Zlash65 2019-01-22 12:46:13 +05:30
parent 7bea25a23a
commit c8d632ddff
2 changed files with 21 additions and 0 deletions

View File

@ -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]

View File

@ -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
})