Skip to content

Employees (الموظفون)

Comprehensive employee management with lifecycle tracking, documents, emergency contacts, and dependents.

Attributes

FieldTypeDescription
idintegerPrimary key
employee_numberstringAuto-generated (EMP-0001)
first_name_arstringArabic first name
last_name_arstringArabic last name
first_name_enstringEnglish first name (nullable)
last_name_enstringEnglish last name (nullable)
department_idintegerDepartment FK (nullable)
position_idintegerPosition FK (nullable)
branch_idintegerBranch FK (nullable)
manager_idintegerDirect manager (Employee FK, nullable)
hire_datedateHire date
contract_typeenumpermanent, contract, part_time, probation
contract_start_datedateContract start (nullable)
contract_end_datedateContract end (required if contract type)
statusenumactive, on_leave, suspended, terminated, resigned
basic_salarydecimalBase salary
payment_methodenumbank_transfer, cash, check
genderstringmale or female
national_idstringNational ID (nullable)
phonestringPhone (nullable)
emailstringEmail (nullable)

API Endpoints

MethodURLDescription
GET/api/hr/employeesList employees (paginated)
POST/api/hr/employeesCreate employee (with nested data)
GET/api/hr/employees/{id}Show employee with all relations
PUT/api/hr/employees/{id}Update employee
DELETE/api/hr/employees/{id}Soft-delete employee
PUT/api/hr/employees/{id}/statusChange employee status
POST/api/hr/employees/{id}/documentsAdd document
DELETE/api/hr/employees/{id}/documents/{doc}Delete document

Query Parameters

ParameterTypeDescription
department_idintegerFilter by department
position_idintegerFilter by position
statusstringFilter by status enum value
searchstringSearch by employee_number

Create with Nested Data

When creating an employee, you can include documents, emergency contacts, and dependents in a single request:

bash
curl -X POST "https://moon-erp.elbaset.com/api/hr/employees" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "first_name_ar": "أحمد",
    "last_name_ar": "محمد",
    "first_name_en": "Ahmed",
    "last_name_en": "Mohamed",
    "hire_date": "2026-03-01",
    "contract_type": "permanent",
    "status": "active",
    "basic_salary": 8000,
    "payment_method": "bank_transfer",
    "gender": "male",
    "department_id": 1,
    "position_id": 1,
    "emergency_contacts": [
      {
        "name": "سارة أحمد",
        "relationship": "spouse",
        "phone": "+20123456789"
      }
    ],
    "dependents": [
      {
        "name": "يوسف أحمد",
        "relationship": "child",
        "date_of_birth": "2020-05-15",
        "gender": "male"
      }
    ]
  }'
dart
final response = await dio.post('/api/hr/employees', data: {
  'first_name_ar': 'أحمد',
  'last_name_ar': 'محمد',
  'hire_date': '2026-03-01',
  'contract_type': 'permanent',
  'status': 'active',
  'basic_salary': 8000,
  'payment_method': 'bank_transfer',
  'gender': 'male',
  'department_id': 1,
  'emergency_contacts': [
    {'name': 'سارة أحمد', 'relationship': 'spouse', 'phone': '+20123456789'}
  ],
});

Status Transitions

Use PUT /api/hr/employees/{id}/status with:

json
{
  "status": "terminated",
  "termination_date": "2026-03-01",
  "termination_reason": "Contract ended"
}

termination_date is required when status is terminated or resigned.

Business Rules

  • Employee number is auto-generated via SequenceService (EMP-0001, EMP-0002, etc.)
  • contract_end_date is required when contract_type is contract
  • Show endpoint eager-loads: department, position, branch, manager, documents, emergencyContacts, dependents
  • Documents support file upload with type classification (contract, id_copy, passport, certificate, etc.)

Moon ERP API Documentation