-
Notifications
You must be signed in to change notification settings - Fork 717
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 #2075 from frappe/version-14-hotfix
chore: release v14
- Loading branch information
Showing
9 changed files
with
139 additions
and
50 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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
frappe.listview_settings["Employee Checkin"] = { | ||
onload: function (listview) { | ||
listview.page.add_action_item(__("Fetch Shifts"), () => { | ||
const checkins = listview.get_checked_items().map((checkin) => checkin.name); | ||
frappe.call({ | ||
method: "hrms.hr.doctype.employee_checkin.employee_checkin.bulk_fetch_shift", | ||
freeze: true, | ||
args: { | ||
checkins, | ||
}, | ||
}); | ||
}); | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
from hrms.hr.doctype.employee_checkin.employee_checkin import ( | ||
add_log_based_on_employee_field, | ||
bulk_fetch_shift, | ||
calculate_working_hours, | ||
mark_attendance_and_link_log, | ||
) | ||
|
@@ -457,6 +458,40 @@ def test_consecutive_shift_assignments_overlapping_within_grace_period(self): | |
log = make_checkin(employee, timestamp) | ||
self.assertEqual(log.shift, shift2.name) | ||
|
||
def test_bulk_fetch_shift(self): | ||
emp1 = make_employee("[email protected]", company="_Test Company") | ||
emp2 = make_employee("[email protected]", company="_Test Company") | ||
|
||
# 8 - 12 | ||
shift1 = setup_shift_type(shift_type="Shift 1") | ||
# 12:30 - 16:30 | ||
shift2 = setup_shift_type(shift_type="Shift 2", start_time="12:30:00", end_time="16:30:00") | ||
|
||
frappe.db.set_value("Employee", emp1, "default_shift", shift1.name) | ||
frappe.db.set_value("Employee", emp2, "default_shift", shift1.name) | ||
|
||
date = getdate() | ||
timestamp = datetime.combine(date, get_time("12:30:00")) | ||
|
||
log1 = make_checkin(emp1, timestamp) | ||
self.assertEqual(log1.shift, shift1.name) | ||
log2 = make_checkin(emp2, timestamp) | ||
self.assertEqual(log2.shift, shift1.name) | ||
|
||
mark_attendance_and_link_log([log2], "Present", date) | ||
|
||
make_shift_assignment(shift2.name, emp1, date) | ||
make_shift_assignment(shift2.name, emp2, date) | ||
|
||
bulk_fetch_shift([log1.name, log2.name]) | ||
|
||
log1.reload() | ||
# shift changes according to the new assignment | ||
self.assertEqual(log1.shift, shift2.name) | ||
log2.reload() | ||
# shift does not change since attendance is already marked | ||
self.assertEqual(log2.shift, shift1.name) | ||
|
||
|
||
def make_n_checkins(employee, n, hours_to_reverse=1): | ||
logs = [make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n + 1))] | ||
|
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
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