Saltearse al contenido

Incidencias

Tipos de incidencia

Modelo

interface IncidentType {
id: string;
name: string; // "Retraso", "Ausencia", "Falta leve", "Falta grave"
code: string; // "RET", "AUS", "FLV", "FGR"
category: 'attendance' | 'conduct' | 'safety' | 'performance';
severity: 1 | 2 | 3 | 4 | 5; // 1=menor, 5=grave
requires_documentation: boolean;
deduct_from_payroll: boolean;
active: boolean;
}

Endpoints

GET /api/hr/incident-types
POST /api/hr/incident-types
PATCH /api/hr/incident-types/:id
DELETE /api/hr/incident-types/:id

Ejemplos

[
{ "name": "Retraso", "code": "RET", "category": "attendance", "severity": 1 },
{ "name": "Ausencia injustificada", "code": "AUS", "category": "attendance", "severity": 3 },
{ "name": "Incumplimiento seguridad", "code": "SEG", "category": "safety", "severity": 5 }
]

Incidencias registradas

Modelo

interface Incident {
id: string;
employee_id: string;
incident_type_id: string;
date: string;
description: string;
duration_minutes?: number; // Para ausencias/retrasos
documentation_url?: string; // PDF del parte
reported_by: string;
status: 'reported' | 'under_review' | 'resolved' | 'escalated';
action_taken?: string;
disciplinary_action?: string;
created_at: string;
resolved_at?: string;
}

Endpoints

MetodoRutaDescripcion
GET/api/hr/incidentsListar incidencias
POST/api/hr/incidentsRegistrar incidencia
GET/api/hr/incidents/:idVer incidencia
PATCH/api/hr/incidents/:idActualizar incidencia
POST/api/hr/incidents/:id/resolveResolver incidencia
DELETE/api/hr/incidents/:idEliminar incidencia

Registrar incidencia

POST /api/hr/incidents
Authorization: Bearer <token>
Content-Type: application/json
{
"employee_id": "emp_001",
"incident_type_id": "inc_ret",
"date": "2026-05-07",
"description": "Llegada 25 minutos tarde sin justificacion",
"duration_minutes": 25,
"reported_by": "emp_003"
}

Listar incidencias de un empleado

GET /api/hr/incidents?employee_id=emp_001&from=2026-01-01&to=2026-12-31

Informe de incidencias por periodo

GET /api/hr/reports/incidents?from=2026-01-01&to=2026-06-30
{
"total_incidents": 12,
"by_type": [
{ "type": "Retraso", "count": 7 },
{ "type": "Ausencia", "count": 5 }
],
"by_employee": [
{ "employee": "Carlos Martinez", "count": 5, "severity": "high" }
],
"incidents_cost": 450.00
}

Resumen de endpoints

MetodoRutaDescripcion
GET/api/hr/incident-typesListar tipos de incidencia
POST/api/hr/incident-typesCrear tipo de incidencia
PATCH/api/hr/incident-types/:idEditar tipo
DELETE/api/hr/incident-types/:idEliminar tipo
GET/api/hr/incidentsListar incidencias
POST/api/hr/incidentsRegistrar incidencia
GET/api/hr/incidents/:idVer incidencia
PATCH/api/hr/incidents/:idActualizar incidencia
POST/api/hr/incidents/:id/resolveResolver incidencia
GET/api/hr/reports/incidentsInforme de incidencias