Server Script for fetching working hours of employee in salary slip

Client Script

totalHours = frappe.call({
					method: "attendance_total_working_hours",
					args: {
						init_date: frm.doc.start_date,
                        end_date: frm.doc.end_date
					},
					callback: function(r) {
						frm.doc.custom_total_working_hours = totalHours.responseJSON.total_hours[0][0]
					}
				});

Server Script

init_date = frappe.form_dict.init_date
end_date = frappe.form_dict.end_date

filters = {
    "init_date": init_date,
    "end_date": end_date
}

query_str = """select sum(working_hours) 
    from tabAttendance 
    where attendance_date between %(init_date)s and %(end_date)s"""


total_hours = frappe.db.sql(query_str, values=filters)
frappe.response['total_hours'] = total_hours