fix: employee selection not working in payroll entry
This commit is contained in:
parent
2a1d1e1cb1
commit
a856624ccb
@ -135,10 +135,26 @@ frappe.ui.form.on('Payroll Entry', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query('employee', 'employees', () => {
|
frm.set_query('employee', 'employees', () => {
|
||||||
if (!frm.doc.company) {
|
let error_fields = [];
|
||||||
frappe.msgprint(__("Please set a Company"));
|
let mandatory_fields = ['company', 'payroll_frequency', 'start_date', 'end_date'];
|
||||||
return [];
|
|
||||||
|
let message = __('Mandatory fields required in {0}', [__(frm.doc.doctype)]);
|
||||||
|
|
||||||
|
mandatory_fields.forEach(field => {
|
||||||
|
if (!frm.doc[field]) {
|
||||||
|
error_fields.push(frappe.unscrub(field));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error_fields && error_fields.length) {
|
||||||
|
message = message + '<br><br><ul><li>' + error_fields.join('</li><li>') + "</ul>";
|
||||||
|
frappe.throw({
|
||||||
|
message: message,
|
||||||
|
indicator: 'red',
|
||||||
|
title: __('Missing Fields')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: "erpnext.payroll.doctype.payroll_entry.payroll_entry.employee_query",
|
query: "erpnext.payroll.doctype.payroll_entry.payroll_entry.employee_query",
|
||||||
filters: frm.events.get_employee_filters(frm)
|
filters: frm.events.get_employee_filters(frm)
|
||||||
@ -148,25 +164,22 @@ frappe.ui.form.on('Payroll Entry', {
|
|||||||
|
|
||||||
get_employee_filters: function (frm) {
|
get_employee_filters: function (frm) {
|
||||||
let filters = {};
|
let filters = {};
|
||||||
filters['company'] = frm.doc.company;
|
|
||||||
filters['start_date'] = frm.doc.start_date;
|
|
||||||
filters['end_date'] = frm.doc.end_date;
|
|
||||||
filters['salary_slip_based_on_timesheet'] = frm.doc.salary_slip_based_on_timesheet;
|
filters['salary_slip_based_on_timesheet'] = frm.doc.salary_slip_based_on_timesheet;
|
||||||
filters['payroll_frequency'] = frm.doc.payroll_frequency;
|
|
||||||
filters['payroll_payable_account'] = frm.doc.payroll_payable_account;
|
|
||||||
filters['currency'] = frm.doc.currency;
|
|
||||||
|
|
||||||
if (frm.doc.department) {
|
let fields = ['company', 'start_date', 'end_date', 'payroll_frequency', 'payroll_payable_account',
|
||||||
filters['department'] = frm.doc.department;
|
'currency', 'department', 'branch', 'designation'];
|
||||||
}
|
|
||||||
if (frm.doc.branch) {
|
fields.forEach(field => {
|
||||||
filters['branch'] = frm.doc.branch;
|
if (frm.doc[field]) {
|
||||||
}
|
filters[field] = frm.doc[field];
|
||||||
if (frm.doc.designation) {
|
}
|
||||||
filters['designation'] = frm.doc.designation;
|
});
|
||||||
}
|
|
||||||
if (frm.doc.employees) {
|
if (frm.doc.employees) {
|
||||||
filters['employees'] = frm.doc.employees.filter(d => d.employee).map(d => d.employee);
|
let employees = frm.doc.employees.filter(d => d.employee).map(d => d.employee);
|
||||||
|
if (employees && employees.length) {
|
||||||
|
filters['employees'] = employees;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return filters;
|
return filters;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user