# Solicitudes de Pagos(Obtener Lista de Solicitudes (1)) - [paymentRequestList]

## 🧾 Descripción

*Este servicio obtiene la **lista de solicitudes de pago** realizadas en el ERP, aplicando restricciones dependientes del usuario, su departamento y reglas de validación definidas por el área de Gerencia.*

El módulo:

- Valida si el usuario tiene configuraciones de **validación personalizadas** (`Validacion de Pagos Gerencia`).
- Filtra solicitudes de pago según:
    
    
    - Estado de validación
    - Concepto
    - Montos permitidos según reglas del usuario
    - Solicitudes de los últimos 6 meses
- Obtiene y agrupa los **archivos transados** (imágenes, documentos y archivos) asociados a cada solicitud.

Si el usuario **no está autorizado**, el módulo devuelve un mensaje de bloqueo.

---

# 🚀 Endpoint

### **POST /payment-request-list**

---

# 📥 Request Body

Ejemplo:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22department%22%3A-%22log"><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">"department"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"LOGISTICA"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"concepto"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Compras abastecimiento interno"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"usuario"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"usuario@empresa.com"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"status"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Validado"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

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

<div class="_tableContainer_1rjym_1" id="bkmrk-campo-tipo-descripci"><div class="group _tableWrapper_1rjym_13 flex w-fit flex-col-reverse" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="1471" data-start="1166"><thead data-end="1196" data-start="1166"><tr data-end="1196" data-start="1166"><th data-col-size="sm" data-end="1174" data-start="1166">Campo</th><th data-col-size="sm" data-end="1181" data-start="1174">Tipo</th><th data-col-size="md" data-end="1196" data-start="1181">Descripción</th></tr></thead><tbody data-end="1471" data-start="1228"><tr data-end="1278" data-start="1228"><td data-col-size="sm" data-end="1241" data-start="1228">department</td><td data-col-size="sm" data-end="1250" data-start="1241">string</td><td data-col-size="md" data-end="1278" data-start="1250">Departamento del usuario</td></tr><tr data-end="1331" data-start="1279"><td data-col-size="sm" data-end="1290" data-start="1279">concepto</td><td data-col-size="sm" data-end="1299" data-start="1290">string</td><td data-col-size="md" data-end="1331" data-start="1299">Concepto filtrado (opcional)</td></tr><tr data-end="1362" data-start="1332"><td data-col-size="sm" data-end="1342" data-start="1332">usuario</td><td data-col-size="sm" data-end="1351" data-start="1342">string</td><td data-col-size="md" data-end="1362" data-start="1351">User ID</td></tr><tr data-end="1471" data-start="1363"><td data-col-size="sm" data-end="1372" data-start="1363">status</td><td data-col-size="sm" data-end="1381" data-start="1372">string</td><td data-col-size="md" data-end="1471" data-start="1381">Estado de validación (opcional). Si es vacío, se excluyen "No requiere" y "Rechazado".</td></tr></tbody></table>

</div></div>---

# 🔐 Seguridad

Requiere conexión válida con el ERP vía `dbErp()` y `ServiceErp()`.

---

# 🧠 Flujo del Servicio (resumen funcional)

### 1️⃣ Validación de permisos del usuario

Se consulta: `<span class="hljs-attribute">tabValidacion</span> de Pagos Gerencia`

Si no existe configuración para ese usuario:

<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">"El modulo esta inhabilitado para su departamento"</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️⃣ Construcción de filtros principales

- Se restringe a solicitudes con:
    
    
    - `estado_documento NOT IN ('Pago Rechazado')`
    - Fecha dentro de los últimos 6 meses.

Si existen reglas personalizadas:

- Se aplican límites de **concepto/monto** por cada configuración.
- Se agregan múltiples filtros OR en el WHERE.

### 3️⃣ Filtrado por estado

- Si se envía un estado explícito → búsqueda exacta.
- Si no → se excluyen `"No requiere"` y `"Rechazado"`.

### 4️⃣ Filtrado por concepto

Si el body incluye un concepto → se agrega un `WHERE concepto = X`.

### 5️⃣ Consulta principal

Se obtiene:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-name%2C-fecha%2C-estado_"><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-type">name</span>, fecha, estado_de_validación, moneda,departamento, proveedor, ruc, concepto, monto,number_factura, voucher`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>Desde: `tabSolicitud de Pagos`

### 6️⃣ Obtención de archivos transados

Por cada solicitud encontrada se consultan los archivos: `<span class="hljs-attribute">tabArchivos</span> Transados`

Clasifica:

- **Imagen** (.jpg, .jpeg, .png)
- **Documento** (.pdf, .xlsx, .xls)
- **Archivo** (otros)

Y asigna nombres:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-imagen-1-documento-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-attribute">Imagen</span> <span class="hljs-number">1</span>Documento <span class="hljs-number">1</span>Archivo <span class="hljs-number">1</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 7️⃣ Construcción de la respuesta final

Cada solicitud incluye:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22archivos_transado"><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">"archivos_transados"</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">"documento_factura"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"url o vacío"</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>---

# 📤 Response 200 – Ejemplo exitoso

<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 Solicitudes generada 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-punctuation">{</span>      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"SP-0001"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-10"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"estado"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Validado"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"moneda"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"PEN"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"departamento"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"LOGISTICA"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"proveedor"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Proveedor SAC"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"ruc"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"20123456789"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"concepto"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Transacción / Compensaciones"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"monto"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">1500</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"numero"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"F001-12345"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"documento_factura"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"/files/factura.pdf"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"archivos_transados"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>        <span class="hljs-punctuation">{</span>          <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"ARCH-001"</span><span class="hljs-punctuation">,</span>          <span class="hljs-attr">"parent"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"SP-0001"</span><span class="hljs-punctuation">,</span>          <span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"/file-download/123.jpg"</span><span class="hljs-punctuation">,</span>          <span class="hljs-attr">"nombre_archivo"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Imagen 1"</span>        <span class="hljs-punctuation">}</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>---

# ❌ Posibles Errores

### 1️⃣ Usuario sin permisos para usar el módulo

<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">"El modulo esta inhabilitado para su departamento"</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 cargar solicitudes

<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">"Surgió un error al cargar la lista de solicitudes, intente nuevamente"</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️⃣ No existen solicitudes dentro de los filtros

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-true%2C-%22ms-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">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No existen solicitudes"</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>---

# 📚 Tablas / Recursos Usados

### ✔ `tabValidacion de Pagos Gerencia`

Campos usados:

- usuario
- concepto
- monto

### ✔ `tabSolicitud de Pagos`

Campos:

- name, fecha, estado\_de\_validación, moneda, proveedor, ruc, concepto
- monto, number\_factura, voucher

### ✔ `tabArchivos Transados`

Campos:

- name, url, parent

---

# 🗃 Lógica en pseudo-código

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-usuario_rules-%3D-get-"><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>`usuario_rules = GET ValidacionPagos where usuario = Xif empty(usuario_rules):    return módulo inhabilitadobuild base filters:    estado_documento NOT IN ('Pago Rechazado')    fecha >= hoy - 6 mesesif usuario_rules exist:    for each rule:        add OR (concepto = rule.concepto AND monto > rule.monto)if status enviado:    add estado_de_validación = Xelse:    exclude ['No requiere', 'Rechazado']if concepto enviado:    add concepto = Xrequests = query SolicitudPagos with filtersif no requests:    return lista vacíaget archivos_transados for all requestsgroup and classify archivos by typereturn lista final con archivos agrupados`</td></tr></tbody></table>

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