-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #488 from frappe/mergify/bp/version-14-hotfix/pr-463
- Loading branch information
Showing
5 changed files
with
116 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,36 +258,6 @@ def test_fetch_shift_spanning_over_two_days(self): | |
self.assertEqual(log.shift_actual_start, datetime.combine(prev_day, get_time("22:00:00"))) | ||
self.assertEqual(log.shift_actual_end, datetime.combine(date, get_time("02:00:00"))) | ||
|
||
def test_no_shift_fetched_on_holiday_as_per_shift_holiday_list(self): | ||
date = getdate() | ||
from_date = get_year_start(date) | ||
to_date = get_year_ending(date) | ||
holiday_list = make_holiday_list(from_date=from_date, to_date=to_date) | ||
|
||
employee = make_employee("[email protected]", company="_Test Company") | ||
setup_shift_type(shift_type="Test Holiday Shift", holiday_list=holiday_list) | ||
|
||
first_sunday = get_first_sunday(holiday_list, for_date=date) | ||
timestamp = datetime.combine(first_sunday, get_time("08:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
|
||
self.assertIsNone(log.shift) | ||
|
||
@set_holiday_list("Salary Slip Test Holiday List", "_Test Company") | ||
def test_no_shift_fetched_on_holiday_as_per_employee_holiday_list(self): | ||
employee = make_employee("[email protected]", company="_Test Company") | ||
shift_type = setup_shift_type(shift_type="Test Holiday Shift") | ||
shift_type.holiday_list = None | ||
shift_type.save() | ||
|
||
date = getdate() | ||
|
||
first_sunday = get_first_sunday(self.holiday_list, for_date=date) | ||
timestamp = datetime.combine(first_sunday, get_time("08:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
|
||
self.assertIsNone(log.shift) | ||
|
||
def test_consecutive_shift_assignments_overlapping_within_grace_period(self): | ||
# test adjustment for start and end times if they are overlapping | ||
# within "begin_check_in_before_shift_start_time" and "allow_check_out_after_shift_end_time" periods | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,84 @@ def test_working_hours_threshold_for_absent_and_half_day_2(self): | |
attendance = frappe.db.get_value("Attendance", {"shift": shift_type.name}, "status") | ||
self.assertEqual(attendance, "Absent") | ||
|
||
@set_holiday_list("Salary Slip Test Holiday List", "_Test Company") | ||
def test_mark_auto_attendance_on_holiday_enabled(self): | ||
from hrms.hr.doctype.employee_checkin.test_employee_checkin import make_checkin | ||
|
||
# add current date as holiday | ||
date = getdate() | ||
holiday_list = frappe.get_doc("Holiday List", self.holiday_list) | ||
holiday_list.append( | ||
"holidays", | ||
{ | ||
"holiday_date": date, | ||
"description": "test", | ||
}, | ||
) | ||
holiday_list.save() | ||
|
||
shift_type = setup_shift_type( | ||
shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=True | ||
) | ||
shift_type.holiday_list = None | ||
shift_type.save() | ||
|
||
employee = make_employee( | ||
"[email protected]", default_shift=shift_type.name, company="_Test Company" | ||
) | ||
|
||
# make logs | ||
timestamp = datetime.combine(date, get_time("08:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
timestamp = datetime.combine(date, get_time("12:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
|
||
shift_type.process_auto_attendance() | ||
|
||
attendance = frappe.db.get_value( | ||
"Attendance", {"employee": employee, "attendance_date": date}, "status" | ||
) | ||
self.assertEqual(attendance, "Present") | ||
|
||
@set_holiday_list("Salary Slip Test Holiday List", "_Test Company") | ||
def test_mark_auto_attendance_on_holiday_disabled(self): | ||
from hrms.hr.doctype.employee_checkin.test_employee_checkin import make_checkin | ||
|
||
# add current date as holiday | ||
date = getdate() | ||
holiday_list = frappe.get_doc("Holiday List", self.holiday_list) | ||
holiday_list.append( | ||
"holidays", | ||
{ | ||
"holiday_date": date, | ||
"description": "test", | ||
}, | ||
) | ||
holiday_list.save() | ||
|
||
shift_type = setup_shift_type( | ||
shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=False | ||
) | ||
shift_type.holiday_list = None | ||
shift_type.save() | ||
|
||
employee = make_employee( | ||
"[email protected]", default_shift=shift_type.name, company="_Test Company" | ||
) | ||
|
||
# make logs | ||
timestamp = datetime.combine(date, get_time("08:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
timestamp = datetime.combine(date, get_time("12:00:00")) | ||
log = make_checkin(employee, timestamp) | ||
|
||
shift_type.process_auto_attendance() | ||
|
||
attendance = frappe.db.get_value( | ||
"Attendance", {"employee": employee, "attendance_date": date}, "status" | ||
) | ||
self.assertIsNone(attendance) | ||
|
||
def test_mark_absent_for_dates_with_no_attendance(self): | ||
employee = make_employee("[email protected]", company="_Test Company") | ||
shift_type = setup_shift_type(shift_type="Test Absent with no Attendance") | ||
|
@@ -403,6 +481,7 @@ def setup_shift_type(**args): | |
"allow_check_out_after_shift_end_time": 60, | ||
"process_attendance_after": add_days(date, -2), | ||
"last_sync_of_checkin": now_datetime() + timedelta(days=1), | ||
"mark_auto_attendance_on_holidays": args.mark_auto_attendance_on_holidays or False, | ||
} | ||
) | ||
|
||
|