-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Information about bug
Fix: Include all Attendance records regardless of Checkin status
Changed the JOIN type from INNER JOIN to LEFT JOIN when connecting
'Attendance' and 'Employee Checkin' tables in the attendance query.
This ensures that Attendance records that do not have associated Employee
Checkins (such as 'Absent' or manual entries) are correctly included in the result set,
preventing data loss in reports/views relying on this query.
the old function:
query = (
frappe.qb.from_(attendance)
.inner_join(checkin)
.on(checkin.attendance == attendance.name)
.inner_join(shift_type)
.on(attendance.shift == shift_type.name)
.select(
attendance.name,
attendance.employee,
attendance.employee_name,
attendance.shift,
attendance.attendance_date,
attendance.status,
attendance.in_time,
attendance.out_time,
attendance.working_hours,
attendance.late_entry,
attendance.early_exit,
attendance.department,
attendance.company,
checkin.shift_start,
checkin.shift_end,
checkin.shift_actual_start,
checkin.shift_actual_end,
shift_type.enable_late_entry_marking,
shift_type.late_entry_grace_period,
shift_type.enable_early_exit_marking,
shift_type.early_exit_grace_period,
)
.where(attendance.docstatus == 1)
.groupby(attendance.name)
)
the new query:
query = (
frappe.qb.from_(attendance)
# Use LEFT JOIN here to keep all Attendance records
.left_join(checkin)
.on(checkin.attendance == attendance.name)
# This can remain inner_join if every attendance has a shift type
.inner_join(shift_type)
.on(attendance.shift == shift_type.name)
.select(
attendance.name,
attendance.employee,
attendance.employee_name,
attendance.shift,
attendance.attendance_date,
attendance.status,
attendance.in_time,
attendance.out_time,
attendance.working_hours,
attendance.late_entry,
attendance.early_exit,
attendance.department,
attendance.company,
checkin.shift_start,
checkin.shift_end,
checkin.shift_actual_start,
checkin.shift_actual_end,
shift_type.enable_late_entry_marking,
shift_type.late_entry_grace_period,
shift_type.enable_early_exit_marking,
shift_type.early_exit_grace_period,
)
.where(attendance.docstatus == 1)
.groupby(attendance.name)
)
Module
HR
Version
ERPNext: v15.57.5 (version-15)
Frappe Framework: v15.63.1 (v15.23.1)
Frappe HR: v15.43.0 (heads/v15.35.2)
Frappe Lending: v0.0.1 (version-15)
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
No status