Attendance (الحضور والانصراف)
Track employee check-in/check-out with automatic calculation of worked hours, overtime, and late minutes. Supports bulk operations and correction requests.
Attributes
| Field | Type | Description |
|---|---|---|
id | integer | Primary key |
employee_id | integer | Employee FK |
date | date | Attendance date |
check_in | datetime | Check-in time |
check_out | datetime | Check-out time (nullable) |
status | enum | present, late, absent, on_leave, half_day |
worked_hours | decimal | Calculated worked hours |
overtime_hours | decimal | Overtime hours |
late_minutes | integer | Minutes late |
early_leave_minutes | integer | Minutes left early |
check_in_source | string | Source (manual, device, etc.) |
check_out_source | string | Source |
notes | string | Notes (nullable) |
Correction Attributes
| Field | Type | Description |
|---|---|---|
id | integer | Primary key |
attendance_id | integer | Attendance FK |
employee_id | integer | Employee FK |
original_check_in | datetime | Original check-in |
original_check_out | datetime | Original check-out |
corrected_check_in | datetime | Corrected check-in |
corrected_check_out | datetime | Corrected check-out |
reason | string | Correction reason |
status | enum | pending, approved, rejected |
approved_by | integer | Approver User FK |
rejection_reason | string | Reason for rejection (nullable) |
API Endpoints
| Method | URL | Description |
|---|---|---|
GET | /api/hr/attendance | List attendance records (paginated) |
POST | /api/hr/attendance/check-in | Employee check-in |
POST | /api/hr/attendance/check-out | Employee check-out |
POST | /api/hr/attendance/bulk | Bulk check-in for multiple employees |
GET | /api/hr/attendance/summary | Attendance summary report |
POST | /api/hr/attendance/corrections | Submit correction request |
PUT | /api/hr/attendance/corrections/{id}/approve | Approve/reject correction |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
employee_id | integer | Filter by employee |
date | date | Filter by specific date |
date_from | date | Filter from date |
date_to | date | Filter to date |
status | string | Filter by status |
Examples
bash
# Check-in
curl -X POST "https://moon-erp.elbaset.com/api/hr/attendance/check-in" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"employee_id": 1,
"notes": "Arrived on time"
}'
# Check-out
curl -X POST "https://moon-erp.elbaset.com/api/hr/attendance/check-out" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{ "employee_id": 1 }'
# Bulk check-in
curl -X POST "https://moon-erp.elbaset.com/api/hr/attendance/bulk" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"date": "2026-03-01",
"entries": [
{ "employee_id": 1, "check_in": "2026-03-01 08:00:00" },
{ "employee_id": 2, "check_in": "2026-03-01 08:15:00" }
]
}'
# Submit correction
curl -X POST "https://moon-erp.elbaset.com/api/hr/attendance/corrections" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"attendance_id": 1,
"corrected_check_in": "2026-03-01 08:00:00",
"corrected_check_out": "2026-03-01 17:00:00",
"reason": "Forgot to check in via device"
}'dart
// Check-in
final response = await dio.post('/api/hr/attendance/check-in', data: {
'employee_id': 1,
'notes': 'Arrived on time',
});
// Bulk check-in
final response = await dio.post('/api/hr/attendance/bulk', data: {
'date': '2026-03-01',
'entries': [
{'employee_id': 1, 'check_in': '2026-03-01 08:00:00'},
{'employee_id': 2, 'check_in': '2026-03-01 08:15:00'},
],
});Business Rules
- Worked hours, overtime, and late minutes are auto-calculated based on the employee's assigned shift
- Late minutes are calculated against the shift's grace period
- Overtime kicks in after the shift's
overtime_threshold - Correction requests require manager approval before updating the attendance record
- Only one attendance record per employee per date