fix: fixed test and resolved conflicts

This commit is contained in:
Anurag Mishra
2021-07-08 14:07:40 +05:30
parent 5683857f9f
commit b96165883e
4 changed files with 10 additions and 8 deletions

View File

@@ -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,

View File

@@ -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)

View File

@@ -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.

View File

@@ -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