Skip to content

Schedules (جداول الورديات)

Manage employee shift schedules with bulk creation support across date ranges and specific days of the week.

Attributes

FieldTypeDescription
idintegerPrimary key
employee_idintegerEmployee FK
shift_idintegerShift FK
datedateSchedule date
statusenumscheduled, attended, absent, on_leave

API Endpoints

MethodURLDescription
GET/api/hr/schedulesList schedules (filtered)
POST/api/hr/schedules/bulkBulk create schedules
PUT/api/hr/schedules/{id}Update a schedule
DELETE/api/hr/schedules/{id}Delete a schedule

Query Parameters (List)

ParameterTypeDescription
employee_idintegerFilter by employee
department_idintegerFilter by department
shift_idintegerFilter by shift
date_fromdateStart date range
date_todateEnd date range

Bulk Create

Create schedules for multiple employees over a date range, specifying which days of the week:

bash
curl -X POST "https://moon-erp.elbaset.com/api/hr/schedules/bulk" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "employee_ids": [1, 2, 3],
    "shift_id": 1,
    "date_from": "2026-03-01",
    "date_to": "2026-03-31",
    "days_of_week": [0, 1, 2, 3, 4]
  }'
dart
final response = await dio.post('/api/hr/schedules/bulk', data: {
  'employee_ids': [1, 2, 3],
  'shift_id': 1,
  'date_from': '2026-03-01',
  'date_to': '2026-03-31',
  'days_of_week': [0, 1, 2, 3, 4],
});
// Response: { "created": 66, "skipped": 0 }

Days of Week

ValueDay
0Sunday
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday

Business Rules

  • Each employee can only have one schedule per date (unique constraint on employee_id + date)
  • Bulk create skips existing records instead of failing (returns created and skipped counts)
  • Schedules are paginated (50 per page), ordered by date then employee
  • Supports filtering by department through employee relationship

Moon ERP API Documentation