Skip to content

Commit c3ebaee

Browse files
authored
Merge pull request #1750 from frappe/version-15-hotfix
chore: release v15
2 parents d82a184 + dec4c0d commit c3ebaee

File tree

9 files changed

+238
-101
lines changed

9 files changed

+238
-101
lines changed

hrms/hr/doctype/leave_application/leave_application.js

+9
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ frappe.ui.form.on("Leave Application", {
102102
frm.set_intro("");
103103
if (frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) {
104104
frm.set_intro(__("Fill the form and save it"));
105+
} else if (
106+
frm.perm[0] &&
107+
frm.perm[0].submit &&
108+
!frm.is_dirty() &&
109+
!frm.is_new() &&
110+
!frappe.model.has_workflow(this.doctype) &&
111+
frm.doc.docstatus === 0
112+
) {
113+
frm.set_intro(__("Submit this Leave Application to confirm."));
105114
}
106115

107116
frm.trigger("set_employee");

hrms/hr/doctype/shift_assignment/shift_assignment.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,11 @@ def get_prev_or_next_shift(
459459
for date_range in shift_dates:
460460
# midnight shifts will span more than a day
461461
start_date, end_date = date_range[0], add_days(date_range[1], 1)
462-
reverse = next_shift_direction == "reverse"
462+
463+
if reverse := (next_shift_direction == "reverse"):
464+
end_date = min(end_date, for_timestamp.date())
465+
elif next_shift_direction == "forward":
466+
start_date = max(start_date, for_timestamp.date())
463467

464468
for dt in generate_date_range(start_date, end_date, reverse=reverse):
465469
shift_details = get_employee_shift(

hrms/hr/doctype/shift_assignment/test_shift_assignment.py

+33
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,36 @@ def test_consecutive_day_and_night_shifts(self):
295295
self.assertEqual(checkin.shift_type, checkout.shift_type)
296296
self.assertEqual(checkin.actual_start.date(), today)
297297
self.assertEqual(checkout.actual_end.date(), today)
298+
299+
def test_shift_details_on_consecutive_days_with_overlapping_timings(self):
300+
# defaults
301+
employee = make_employee("[email protected]", company="_Test Company")
302+
today = getdate()
303+
yesterday = add_days(today, -1)
304+
305+
# shift 1
306+
shift_type = setup_shift_type(shift_type="Morning", start_time="07:00:00", end_time="12:00:00")
307+
make_shift_assignment(shift_type.name, employee, add_days(yesterday, -1), yesterday)
308+
309+
# shift 2
310+
shift_type = setup_shift_type(shift_type="Afternoon", start_time="09:30:00", end_time="14:00:00")
311+
make_shift_assignment(shift_type.name, employee, today, add_days(today, 1))
312+
313+
# current_shift shift log - checkin in the grace period of current shift, non-overlapping with prev shift
314+
current_shift = get_actual_start_end_datetime_of_shift(
315+
employee, get_datetime(f"{today} 14:01:00"), True
316+
)
317+
self.assertEqual(current_shift.shift_type.name, "Afternoon")
318+
self.assertEqual(current_shift.actual_start, get_datetime(f"{today} 08:30:00"))
319+
self.assertEqual(current_shift.actual_end, get_datetime(f"{today} 15:00:00"))
320+
321+
# previous shift
322+
checkin = get_actual_start_end_datetime_of_shift(
323+
employee, get_datetime(f"{yesterday} 07:01:00"), True
324+
)
325+
checkout = get_actual_start_end_datetime_of_shift(
326+
employee, get_datetime(f"{yesterday} 13:00:00"), True
327+
)
328+
self.assertTrue(checkin.shift_type.name == checkout.shift_type.name == "Morning")
329+
self.assertEqual(checkin.actual_start, get_datetime(f"{yesterday} 06:00:00"))
330+
self.assertEqual(checkout.actual_end, get_datetime(f"{yesterday} 13:00:00"))

hrms/hr/doctype/shift_type/test_shift_type.py

+23
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,29 @@ def test_mark_absent_for_dates_with_no_attendance_for_midnight_shift(self):
371371
self.assertEqual(len(absent_records), 2)
372372

373373
def test_do_not_mark_absent_before_shift_actual_end_time(self):
374+
from hrms.hr.doctype.employee_checkin.test_employee_checkin import make_checkin
375+
376+
employee = make_employee("[email protected]", company="_Test Company")
377+
today = getdate()
378+
yesterday = add_days(today, -1)
379+
380+
# shift 1
381+
shift_1 = setup_shift_type(shift_type="Morning", start_time="07:00:00", end_time="12:30:00")
382+
make_shift_assignment(shift_1.name, employee, add_days(yesterday, -1), yesterday)
383+
384+
# shift 2
385+
shift_2 = setup_shift_type(shift_type="Afternoon", start_time="09:30:00", end_time="18:00:00")
386+
make_shift_assignment(shift_2.name, employee, today, add_days(today, 1))
387+
388+
# update last sync of checkin for shift 2
389+
shift_2.process_attendance_after = add_days(today, -2)
390+
shift_2.last_sync_of_checkin = datetime.combine(today, get_time("09:01:00"))
391+
shift_2.save()
392+
shift_2.process_auto_attendance()
393+
394+
self.assertIsNone(frappe.db.get_value("Attendance", {"attendance_date": today, "employee": employee}))
395+
396+
def test_do_not_mark_absent_before_shift_actual_end_time_for_midnight_shift(self):
374397
"""
375398
Tests employee is not marked absent for a shift spanning 2 days
376399
before its actual end time

hrms/patches.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ hrms.patches.v15_0.rename_and_update_leave_encashment_fields
2222
hrms.patches.v14_0.update_title_in_employee_onboarding_and_separation_templates
2323
hrms.patches.v15_0.make_hr_settings_tab_in_company_master
2424
hrms.patches.v15_0.enable_allow_checkin_setting
25-
hrms.patches.v15_0.set_default_asset_action_in_fnf
25+
hrms.patches.v15_0.set_default_asset_action_in_fnf
26+
hrms.patches.v15_0.add_loan_docperms_to_ess
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import frappe
2+
3+
from hrms.setup import add_lending_docperms_to_ess
4+
5+
6+
def execute():
7+
if "lending" in frappe.get_installed_apps():
8+
add_lending_docperms_to_ess()

hrms/payroll/doctype/payroll_period/payroll_period.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
],
5555
"links": [],
56-
"modified": "2020-06-29 17:17:12.689089",
56+
"modified": "2024-05-05 14:50:12.419714",
5757
"modified_by": "Administrator",
5858
"module": "Payroll",
5959
"name": "Payroll Period",
@@ -71,6 +71,15 @@
7171
"share": 1,
7272
"write": 1
7373
},
74+
{
75+
"email": 1,
76+
"export": 1,
77+
"print": 1,
78+
"read": 1,
79+
"report": 1,
80+
"role": "Employee",
81+
"share": 1
82+
},
7483
{
7584
"create": 1,
7685
"delete": 1,

0 commit comments

Comments
 (0)