# Horas Extras del Mes (1) - [getMarkingsForEmployeePerMonth2]

🧾 **Descripción**

Obtiene y calcula todas las **horas extras registradas** para un empleado en un mes específico, detallando:

- Horas al **25%**
- Horas al **35%**
- Horas al **100%** (domingos y feriados)
- Listado detallado por día
- Total acumulado del periodo de corte mensual

El servicio consulta información desde varios recursos del ERP:

- **Cortes (tabCortes)** → para determinar el rango mensual válido
- **Horas Extras (tabHoras Extras)** → totales por mes
- **Marcaciones (tabMarcaciones)** → registros por día
- Archivo local de feriados: `holidays.json`

---

# 🚀 Endpoint

**POST** <span style="color: rgb(224, 62, 45);">**`/get-markings-employee-month`**</span>

📥 **Parámetros en el body**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22employee%22%3A-%22emp-0"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"employee"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"EMP-0001"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"month"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"02"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"year"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# 🔐 Seguridad

- Requiere token interno del ERP (autenticación manejada por <span style="color: rgb(224, 62, 45);">**`ServiceErp()`**</span>).
- Validación del request vía Laravel.

---

# 🧠 Flujo del Servicio (resumen real)

### 1️⃣ Obtiene el corte mensual

Consulta el recurso:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-%2Fresource%2Fcortes"><div class="overflow-y-auto p-4" dir="ltr"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">GET</span> <span class="hljs-operator">/</span>resource<span class="hljs-operator">/</span>Cortesfilters: año <span class="hljs-operator">=</span> <span class="hljs-keyword">year</span>, mes <span class="hljs-operator">=</span> <span class="hljs-keyword">month</span>`</td></tr></tbody></table>

</div><div class="overflow-y-auto p-4" dir="ltr"></div></div>Si no existe corte → retorna error `"No hay corte mensual para este mes"`.

---

### 2️⃣ Obtiene las horas extras acumuladas del mes

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-%2Fresource%2Fhoras-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 68.1375px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 68.1375px;"><td style="height: 68.1375px;">`<span class="hljs-keyword">GET</span> /resource/Horas Extras<span class="hljs-symbol">fields:</span> [<span class="hljs-string">"hhee_al_25"</span>,<span class="hljs-string">"hhee_al_35"</span>,<span class="hljs-string">"hhee_al_100"</span>]<span class="hljs-symbol">filters:</span> año, mes, empleado`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

### 3️⃣ Obtiene las marcaciones dentro del periodo del corte

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-%2Fresource%2Fmarcac"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">GET</span> <span class="hljs-operator">/</span>resource<span class="hljs-operator">/</span>Marcacionesfilters:     user_id <span class="hljs-operator">=</span> employee    <span class="hljs-type">date</span> <span class="hljs-keyword">BETWEEN</span> corte.inicio <span class="hljs-keyword">AND</span> corte.fin    hours <span class="hljs-operator">!=</span> <span class="hljs-number">0</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>Si no hay marcaciones → retorna mensaje informativo.

---

### 4️⃣ Carga feriados desde archivo local

`public/recursos_humanos/holidays.json`

Feriados + domingos se consideran jornada **al 100%**.

---

### 5️⃣ Procesa cada marcación

Por cada registro:

- Si es feriado/domingo → 100%
- Si horas ≤ 2 → 25%
- Si horas &gt; 2
    
    
    - primeras 2h → 25%
    - resto → 35%

Cada día se estructura como:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22fecha%22%3A-%2205-de-en"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"05 DE ENERO"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"porcentaje"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"35%"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"horas_completadas"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"3H"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

### 6️⃣ Arma la respuesta final:

Incluye:

- `marcaciones`: detalle por día
- `horas25`, `horas35`, `horas100`: de la tabla Horas Extras
- `horas_acumuladas`: sumatoria real de horas del mes

---

# 📤 **Response 200 – Ejemplo**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-true%2C-%22ms"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Lista de horas extras generado correctamente"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>    <span class="hljs-attr">"marcaciones"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>      <span class="hljs-punctuation">{</span>        <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"03 DE ENERO"</span><span class="hljs-punctuation">,</span>        <span class="hljs-attr">"porcentaje"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"25%"</span><span class="hljs-punctuation">,</span>        <span class="hljs-attr">"horas_completadas"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2H"</span>      <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>      <span class="hljs-punctuation">{</span>        <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"03 DE ENERO"</span><span class="hljs-punctuation">,</span>        <span class="hljs-attr">"porcentaje"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"35%"</span><span class="hljs-punctuation">,</span>        <span class="hljs-attr">"horas_completadas"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"1H"</span>      <span class="hljs-punctuation">}</span>    <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas25"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"12"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas35"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"4"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas100"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas_acumuladas"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"15"</span>  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# ❗ Posibles Errores

### 1. Corte mensual no configurado

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No hay corte mensual para este mes"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 2. Error al traer horas extras

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m-1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Surgió un error, al obtener las horas extras"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 3. Marcaciones vacías

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m-2"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No hay horas extras registradas para este mes"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>    <span class="hljs-attr">"marcaciones"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas25"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"0"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas35"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"0"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas100"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"0"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"horas_acumuladas"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"0"</span>  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 4. Error en servicio del ERP

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m-3"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Surgió un error, al obtener las marcaciones."</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# 📚 **Schemas utilizados**

### **Cortes**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22dia_inicio%22%3A-%22202"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"dia_inicio"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-01"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"dia_final"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-31"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### **Horas Extras**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22hhee_al_25%22%3A-%2210%22"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"hhee_al_25"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"10"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"hhee_al_35"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"5"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"hhee_al_100"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### **Marcaciones**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22fecha%22%3A-%222025-01-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 29.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 29.6px;"><td style="height: 29.6px;">`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-03"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"horas"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">3</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 🗃 Lógica en pseudo-código

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-corte-%3D-get-cortes-w"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 29.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 29.6px;"><td style="height: 29.6px;">`corte = GET Cortes where año=year and mes=monthif corte empty → return errorhours = GET Horas Extras where año, mes, empleadomarkings = GET Marcaciones where user_id=employee and date between corteferiados = cargar holidays.jsonforeach marking:    if fecha in feriados → 100%    else if horas <= 2 → 25%    else:        agregar 2h al 25%        agregar horas-2 al 35%sumar horas acumuladasreturn {    marcaciones procesadas,    horas25, horas35, horas100,    horas_acumuladas}`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>