fix: Salary Structure Fixes (#19923)

This commit is contained in:
Anurag Mishra
2019-12-23 18:01:41 +05:30
committed by Nabin Hait
parent 2b3482d5dd
commit bd5f5dabbd

View File

@@ -119,47 +119,52 @@ frappe.ui.form.on('Salary Structure', {
}, },
callback: function(r) { callback: function(r) {
var employees = r.message; var employees = r.message;
var d = new frappe.ui.Dialog({ if(!employees) return;
title: __("Preview Salary Slip"), if (employees.length == 1){
fields: [ frm.events.open_salary_slip(frm, employees[0]);
{ } else {
"label":__("Employee"), var d = new frappe.ui.Dialog({
"fieldname":"employee", title: __("Preview Salary Slip"),
"fieldtype":"Select", fields: [
"reqd": true, {
options: employees "label":__("Employee"),
}, { "fieldname":"employee",
fieldname:"fetch", "fieldtype":"Select",
"label":__("Show Salary Slip"), "reqd": true,
"fieldtype":"Button" options: employees
} }, {
] fieldname:"fetch",
}); "label":__("Show Salary Slip"),
d.get_input("fetch").on("click", function() { "fieldtype":"Button"
var values = d.get_values(); }
if(!values) return; ]
var print_format;
frm.doc.salary_slip_based_on_timesheet ?
print_format="Salary Slip based on Timesheet" :
print_format="Salary Slip Standard";
frappe.call({
method: "erpnext.hr.doctype.salary_structure.salary_structure.make_salary_slip",
args: {
source_name: frm.doc.name,
employee: values.employee,
as_print: 1,
print_format: print_format,
for_preview: 1
},
callback: function(r) {
var new_window = window.open();
new_window.document.write(r.message);
// frappe.msgprint(r.message);
}
}); });
}); d.get_input("fetch").on("click", function() {
d.show(); var values = d.get_values();
if(!values) return;
frm.events.open_salary_slip(frm, values.employee)
});
d.show();
}
}
});
},
open_salary_slip: function(frm, employee){
var print_format = frm.doc.salary_slip_based_on_timesheet ? "Salary Slip based on Timesheet" : "Salary Slip Standard";
frappe.call({
method: "erpnext.hr.doctype.salary_structure.salary_structure.make_salary_slip",
args: {
source_name: frm.doc.name,
employee: employee,
as_print: 1,
print_format: print_format,
for_preview: 1
},
callback: function(r) {
var new_window = window.open();
new_window.document.write(r.message);
} }
}); });
}, },