Skip to content

Attendance (الحضور والانصراف)

Track employee check-in/check-out with automatic calculation of worked hours, overtime, and late minutes. Supports bulk operations and correction requests.

Attributes

FieldTypeDescription
idintegerPrimary key
employee_idintegerEmployee FK
datedateAttendance date
check_indatetimeCheck-in time
check_outdatetimeCheck-out time (nullable)
statusenumpresent, late, absent, on_leave, half_day
worked_hoursdecimalCalculated worked hours
overtime_hoursdecimalOvertime hours
late_minutesintegerMinutes late
early_leave_minutesintegerMinutes left early
check_in_sourcestringSource (manual, device, etc.)
check_out_sourcestringSource
notesstringNotes (nullable)

Correction Attributes

FieldTypeDescription
idintegerPrimary key
attendance_idintegerAttendance FK
employee_idintegerEmployee FK
original_check_indatetimeOriginal check-in
original_check_outdatetimeOriginal check-out
corrected_check_indatetimeCorrected check-in
corrected_check_outdatetimeCorrected check-out
reasonstringCorrection reason
statusenumpending, approved, rejected
approved_byintegerApprover User FK
rejection_reasonstringReason for rejection (nullable)

API Endpoints

MethodURLDescription
GET/api/hr/attendanceList attendance records (paginated)
POST/api/hr/attendance/check-inEmployee check-in
POST/api/hr/attendance/check-outEmployee check-out
POST/api/hr/attendance/bulkBulk check-in for multiple employees
GET/api/hr/attendance/summaryAttendance summary report
POST/api/hr/attendance/correctionsSubmit correction request
PUT/api/hr/attendance/corrections/{id}/approveApprove/reject correction

Query Parameters

ParameterTypeDescription
employee_idintegerFilter by employee
datedateFilter by specific date
date_fromdateFilter from date
date_todateFilter to date
statusstringFilter 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

Moon ERP API Documentation