From b96165883ef6e23613479b8f92268fcef20557ad Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Thu, 8 Jul 2021 14:07:40 +0530 Subject: [PATCH] fix: fixed test and resolved conflicts --- erpnext/hr/doctype/employee_checkin/employee_checkin.py | 9 +++++---- .../hr/doctype/employee_checkin/test_employee_checkin.py | 3 ++- erpnext/hr/doctype/shift_assignment/shift_assignment.py | 2 +- erpnext/payroll/doctype/salary_slip/salary_slip.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.py b/erpnext/hr/doctype/employee_checkin/employee_checkin.py index fbcc191887a..58d166ffe66 100644 --- a/erpnext/hr/doctype/employee_checkin/employee_checkin.py +++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.py @@ -31,7 +31,10 @@ class EmployeeCheckin(Document): def fetch_shift(self): shift_actual_timings = get_actual_start_end_datetime_of_shift(self.employee, get_datetime(self.time), True) - if not frappe.db.get_value("Shift Type", shift_actual_timings[2].shift_type.name, "allow_overtime"): + allow_overtime = False + if shift_actual_timings[2]: + allow_overtime = frappe.db.get_value("Shift Type", shift_actual_timings[2].shift_type.name, "allow_overtime") + if not allow_overtime: if shift_actual_timings[0] and shift_actual_timings[1]: if shift_actual_timings[2].shift_type.determine_check_in_and_check_out == 'Strictly based on Log Type in Employee Checkin' and not self.log_type and not self.skip_auto_attendance: frappe.throw(_('Log Type is required for check-ins falling in the shift: {0}.').format(shift_actual_timings[2].shift_type.name)) @@ -41,7 +44,7 @@ class EmployeeCheckin(Document): self.shift_actual_end = shift_actual_timings[1] self.shift_start = shift_actual_timings[2].start_datetime self.shift_end = shift_actual_timings[2].end_datetime - elif frappe.db.get_value("Shift Type", shift_actual_timings[2].shift_type.name, "allow_overtime"): + elif allow_overtime: #because after Actual time it takes check-in/out invalid #if employee checkout late or check-in before before shift timing adding time buffer. self.shift = shift_actual_timings[2].shift_type.name @@ -81,7 +84,6 @@ def add_log_based_on_employee_field(employee_field_value, timestamp, device_id=N return doc - def mark_attendance_and_link_log(logs, attendance_status, attendance_date, working_hours=None, late_entry=False, early_exit=False, in_time=None, out_time=None, shift=None): """Creates an attendance and links the attendance to the Employee Checkin. Note: If attendance is already present for the given date, the logs are marked as skipped and no exception is thrown. @@ -109,7 +111,6 @@ def mark_attendance_and_link_log(logs, attendance_status, attendance_date, worki working_timedelta = timedelta(hours =int(working_time[1]), minutes = int(working_time[0] * 60)) from erpnext.hr.doctype.shift_type.shift_type import convert_time_into_duration working_time = convert_time_into_duration(working_timedelta) - doc_dict = { 'doctype': 'Attendance', 'employee': employee, diff --git a/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py b/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py index a1d52a22723..9cdba811df9 100644 --- a/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py +++ b/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py @@ -40,7 +40,8 @@ class TestEmployeeCheckin(unittest.TestCase): log_names = [log.name for log in logs] logs_count = frappe.db.count('Employee Checkin', {'name':['in', log_names], 'attendance':attendance.name}) self.assertEqual(logs_count, 4) - attendance_count = frappe.db.count('Attendance', {'status':'Present', 'working_hours':8.2, + + attendance_count = frappe.db.count('Attendance', {'status':'Present', 'working_time': 29460, 'employee':employee, 'attendance_date':now_date}) self.assertEqual(attendance_count, 1) diff --git a/erpnext/hr/doctype/shift_assignment/shift_assignment.py b/erpnext/hr/doctype/shift_assignment/shift_assignment.py index 5047076fc14..792b3044b48 100644 --- a/erpnext/hr/doctype/shift_assignment/shift_assignment.py +++ b/erpnext/hr/doctype/shift_assignment/shift_assignment.py @@ -257,7 +257,7 @@ def get_actual_start_end_datetime_of_shift(employee, for_datetime, consider_defa actual_shift_start = actual_shift_end = shift_details = None shift_timings_as_per_timestamp = get_employee_shift_timings(employee, for_datetime, consider_default_shift) - if not shift_timings_as_per_timestamp[0].allow_overtime: + if shift_timings_as_per_timestamp[0] and not shift_timings_as_per_timestamp[0].allow_overtime: # If Shift is not allowed for automatic calculation of overtime, then previous, current and next # shift will also should be considered for valid and invalid checkins. # if checkin time is not in current shift thenit will check prev and next shift for checkin validation. diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.py b/erpnext/payroll/doctype/salary_slip/salary_slip.py index 4ffa60c8c9a..1277053097c 100644 --- a/erpnext/payroll/doctype/salary_slip/salary_slip.py +++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py @@ -569,8 +569,8 @@ class SalarySlip(TransactionBase): frappe.bold(detail.overtime_type))) if "applicable_amount" not in overtime_types_details[detail.overtime_type].keys(): - component_amount = sum([data.default_amount for data in self.earnings if data.salary_component in \ - overtime_types_details[detail.overtime_type]["components"] and not data.get('additional_salary', None)]) + component_amount = sum([data.default_amount for data in self.earnings if data.salary_component in + overtime_types_details[detail.overtime_type]["components"] and not data.get('additional_salary', None)]) overtime_types_details[detail.overtime_type]["applicable_daily_amount"] = component_amount/self.total_working_days