fix: allow addition and removal of employee in payroll Entry

This commit is contained in:
Anurag Mishra 2020-12-17 15:17:25 +05:30
parent 0411a43c6e
commit d556847fca
3 changed files with 24 additions and 24 deletions

View File

@ -17,8 +17,7 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "Employee", "label": "Employee",
"options": "Employee", "options": "Employee"
"read_only": 1
}, },
{ {
"fetch_from": "employee.employee_name", "fetch_from": "employee.employee_name",
@ -52,7 +51,7 @@
], ],
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2020-09-30 12:40:07.999878", "modified": "2020-12-17 15:43:29.542977",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Payroll Employee Detail", "name": "Payroll Employee Detail",

View File

@ -31,7 +31,7 @@ frappe.ui.form.on('Payroll Entry', {
refresh: function(frm) { refresh: function(frm) {
if (frm.doc.docstatus == 0) { if (frm.doc.docstatus == 0) {
if(!frm.is_new()) { if (!frm.is_new()) {
frm.page.clear_primary_action(); frm.page.clear_primary_action();
frm.add_custom_button(__("Get Employees"), frm.add_custom_button(__("Get Employees"),
function() { function() {
@ -61,33 +61,33 @@ frappe.ui.form.on('Payroll Entry', {
doc: frm.doc, doc: frm.doc,
method: 'fill_employee_details', method: 'fill_employee_details',
}).then(r => { }).then(r => {
if (r.docs && r.docs[0].employees){ if (r.docs && r.docs[0].employees) {
frm.employees = r.docs[0].employees; frm.employees = r.docs[0].employees;
frm.dirty(); frm.dirty();
frm.save(); frm.save();
frm.refresh(); frm.refresh();
if(r.docs[0].validate_attendance){ if (r.docs[0].validate_attendance) {
render_employee_attendance(frm, r.message); render_employee_attendance(frm, r.message);
} }
} }
}) });
}, },
create_salary_slips: function(frm) { create_salary_slips: function(frm) {
frm.call({ frm.call({
doc: frm.doc, doc: frm.doc,
method: "create_salary_slips", method: "create_salary_slips",
callback: function(r) { callback: function() {
frm.refresh(); frm.refresh();
frm.toolbar.refresh(); frm.toolbar.refresh();
} }
}) });
}, },
add_context_buttons: function(frm) { add_context_buttons: function(frm) {
if(frm.doc.salary_slips_submitted || (frm.doc.__onload && frm.doc.__onload.submitted_ss)) { if (frm.doc.salary_slips_submitted || (frm.doc.__onload && frm.doc.__onload.submitted_ss)) {
frm.events.add_bank_entry_button(frm); frm.events.add_bank_entry_button(frm);
} else if(frm.doc.salary_slips_created) { } else if (frm.doc.salary_slips_created) {
frm.add_custom_button(__("Submit Salary Slip"), function() { frm.add_custom_button(__("Submit Salary Slip"), function() {
submit_salary_slip(frm); submit_salary_slip(frm);
}).addClass("btn-primary"); }).addClass("btn-primary");
@ -192,9 +192,9 @@ frappe.ui.form.on('Payroll Entry', {
}, },
start_date: function (frm) { start_date: function (frm) {
if(!in_progress && frm.doc.start_date){ if (!in_progress && frm.doc.start_date) {
frm.trigger("set_end_date"); frm.trigger("set_end_date");
}else{ } else {
// reset flag // reset flag
in_progress = false; in_progress = false;
} }
@ -228,7 +228,7 @@ frappe.ui.form.on('Payroll Entry', {
} }
}, },
set_end_date: function(frm){ set_end_date: function(frm) {
frappe.call({ frappe.call({
method: 'erpnext.payroll.doctype.payroll_entry.payroll_entry.get_end_date', method: 'erpnext.payroll.doctype.payroll_entry.payroll_entry.get_end_date',
args: { args: {
@ -243,9 +243,9 @@ frappe.ui.form.on('Payroll Entry', {
}); });
}, },
validate_attendance: function(frm){ validate_attendance: function(frm) {
if(frm.doc.validate_attendance && frm.doc.employees){ if (frm.doc.validate_attendance && frm.doc.employees) {
frappe.call({ frappe.call ({
method: 'validate_employee_attendance', method: 'validate_employee_attendance',
args: {}, args: {},
callback: function(r) { callback: function(r) {
@ -255,7 +255,7 @@ frappe.ui.form.on('Payroll Entry', {
freeze: true, freeze: true,
freeze_message: __('Validating Employee Attendance...') freeze_message: __('Validating Employee Attendance...')
}); });
}else{ } else {
frm.fields_dict.attendance_detail_html.html(""); frm.fields_dict.attendance_detail_html.html("");
} }
}, },
@ -274,14 +274,16 @@ const submit_salary_slip = function (frm) {
frappe.call({ frappe.call({
method: 'submit_salary_slips', method: 'submit_salary_slips',
args: {}, args: {},
callback: function() {frm.events.refresh(frm);}, callback: function() {
frm.events.refresh(frm);
},
doc: frm.doc, doc: frm.doc,
freeze: true, freeze: true,
freeze_message: __('Submitting Salary Slips and creating Journal Entry...') freeze_message: __('Submitting Salary Slips and creating Journal Entry...')
}); });
}, },
function() { function() {
if(frappe.dom.freeze_count) { if (frappe.dom.freeze_count) {
frappe.dom.unfreeze(); frappe.dom.unfreeze();
frm.events.refresh(frm); frm.events.refresh(frm);
} }
@ -316,4 +318,4 @@ let render_employee_attendance = function(frm, data) {
data: data data: data
}) })
); );
} };

View File

@ -129,8 +129,7 @@
"fieldname": "employees", "fieldname": "employees",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Employee Details", "label": "Employee Details",
"options": "Payroll Employee Detail", "options": "Payroll Employee Detail"
"read_only": 1
}, },
{ {
"fieldname": "section_break_13", "fieldname": "section_break_13",
@ -290,7 +289,7 @@
"icon": "fa fa-cog", "icon": "fa fa-cog",
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-23 13:00:33.753228", "modified": "2020-12-17 15:13:17.766210",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Payroll Entry", "name": "Payroll Entry",