Merge branch 'develop' of github.com:frappe/erpnext into employee-leave-balance-summary

This commit is contained in:
Suraj Shetty
2019-09-07 22:02:02 +05:30
48 changed files with 962 additions and 3401 deletions

View File

@@ -7,6 +7,7 @@
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"basic_information",
"employee",
@@ -54,6 +55,7 @@
"column_break_44",
"holiday_list",
"default_shift",
"leave_approver",
"salary_information",
"salary_mode",
"bank_name",
@@ -767,12 +769,18 @@
"fieldtype": "Link",
"label": "Default Shift",
"options": "Shift Type"
},
{
"fieldname": "leave_approver",
"fieldtype": "Link",
"label": "Leave Approver",
"options": "User"
}
],
"icon": "fa fa-user",
"idx": 24,
"image_field": "image",
"modified": "2019-06-01 16:05:55.132180",
"modified": "2019-09-06 15:54:36.735147",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",

View File

@@ -142,8 +142,10 @@ def calculate_working_hours(logs, check_in_out_type, working_hours_calc_type):
elif check_in_out_type == 'Strictly based on Log Type in Employee Checkin':
if working_hours_calc_type == 'First Check-in and Last Check-out':
first_in_log = logs[find_index_in_dict(logs, 'log_type', 'IN')]
last_out_log = logs[len(logs)-1-find_index_in_dict(reversed(logs), 'log_type', 'OUT')]
first_in_log_index = find_index_in_dict(logs, 'log_type', 'IN')
first_in_log = logs[first_in_log_index] if first_in_log_index or first_in_log_index == 0 else None
last_out_log_index = find_index_in_dict(reversed(logs), 'log_type', 'OUT')
last_out_log = logs[len(logs)-1-last_out_log_index] if last_out_log_index or last_out_log_index == 0 else None
if first_in_log and last_out_log:
in_time, out_time = first_in_log.time, last_out_log.time
total_hours = time_diff_in_hours(in_time, out_time)

View File

@@ -745,10 +745,12 @@ def get_approved_leaves_for_period(employee, leave_type, from_date, to_date):
return leave_days
@frappe.whitelist()
def get_leave_approver(employee, department=None):
if not department:
department = frappe.db.get_value('Employee', employee, 'department')
def get_leave_approver(employee):
leave_approver, department = frappe.db.get_value("Employee",
employee, ["leave_approver", "department"])
if department:
return frappe.db.get_value('Department Approver', {'parent': department,
'parentfield': 'leave_approvers', 'idx': 1}, 'approver')
if not leave_approver and department:
leave_approver = frappe.db.get_value('Department Approver', {'parent': department,
'parentfield': 'leave_approvers', 'idx': 1}, 'approver')
return leave_approver