Actualizar Flujo de n8n: Portal de Verificación de Nómina GT - Históricos.json
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"name": "Portal de Verificación de Nómina GT - Históricos",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"path": "cruce-cuentas-gt-historicos",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2.1,
|
||||
"position": [
|
||||
-112,
|
||||
-16
|
||||
],
|
||||
"id": "47845bfd-64f5-47ec-89e6-c0faa317e08b",
|
||||
"name": "Webhook Históricos GT",
|
||||
"webhookId": "e92a1ebc-80e5-4afe-b38d-48a92c4b7fea"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const items = $input.all();\n\nfunction formatDate(value) {\n if (!value) return '';\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return String(value).slice(0, 10);\n return date.toISOString().slice(0, 10);\n}\n\nfunction toNumber(value) {\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction normalizeStatus(value, discrepancias) {\n const status = String(value || '').toLowerCase();\n\n if (status === 'resuelto') return 'resuelto';\n if (status === 'procesado' && toNumber(discrepancias) === 0) return 'procesado';\n\n return 'pendiente_revision';\n}\n\nfunction statusLabel(status) {\n if (status === 'resuelto') return 'RESUELTO';\n if (status === 'procesado') return 'PROCESADO';\n return 'PENDIENTE REVISIÓN';\n}\n\nconst reports = items.map((item) => {\n const row = item.json || {};\n\n const discrepancias = toNumber(row.discrepancias);\n const bancoSinNomina = toNumber(row.banco_sin_nomina);\n const nominaSinCuenta = toNumber(row.nomina_sin_cuenta);\n const bancoSinBamboo = toNumber(row.banco_sin_bamboo);\n const nominaSinBamboo = toNumber(row.nomina_sin_bamboo);\n const bambooSinNomina = toNumber(row.bamboo_sin_nomina);\n\n const totalPendientes =\n discrepancias +\n bancoSinNomina +\n nominaSinCuenta +\n bancoSinBamboo +\n nominaSinBamboo +\n bambooSinNomina;\n\n const estado = normalizeStatus(row.estado, totalPendientes);\n\n return {\n id: row.id,\n\n fecha: formatDate(row.period_end || row.ejecutado_en || row.created_at),\n fechaEjecucion: row.ejecutado_en || row.created_at,\n\n periodo: row.period_label || '',\n year: row.year,\n month: row.month,\n periodType: row.period_type,\n periodStart: row.period_start,\n periodEnd: row.period_end,\n\n archivoNomina: row.payroll_file_name || '',\n archivosBanco: row.bank_file_names || [],\n\n coincidencias: toNumber(row.coincidencias),\n discrepancias,\n bancoSinNomina,\n nominaSinCuenta,\n bancoSinBamboo,\n nominaSinBamboo,\n bambooSinNomina,\n totalPendientes,\n\n totalNomina: toNumber(row.total_nomina),\n totalBanco: toNumber(row.total_banco),\n diferenciaTotal: toNumber(row.diferencia_total),\n\n estado,\n estadoLabel: statusLabel(estado),\n\n reportUrl: row.report_url || '',\n spreadsheetId: row.spreadsheet_id || '',\n\n ejecutadoPorNombre: row.ejecutado_por_nombre || '',\n ejecutadoPorEmail: row.ejecutado_por_email || '',\n\n resueltoPorNombre: row.resuelto_por_nombre || '',\n resueltoPorEmail: row.resuelto_por_email || '',\n resueltoEn: row.resuelto_en || null,\n comentarioResolucion: row.comentario_resolucion || '',\n };\n});\n\nreturn [\n {\n json: {\n ok: true,\n stage: 'historicos_gt_listos',\n count: reports.length,\n reports,\n },\n },\n];"
|
||||
},
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
304,
|
||||
-16
|
||||
],
|
||||
"id": "0fb42965-9a23-42e1-bd82-152452dc54ed",
|
||||
"name": "Normalizar históricos para app"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "https://dbit.digitalcompass.agency/rest/v1/cruces_cuentas_gt_reportes?select=*&order=ejecutado_en.desc&limit=100",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "apikey",
|
||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.4,
|
||||
"position": [
|
||||
96,
|
||||
-16
|
||||
],
|
||||
"id": "3b8cd950-a973-433e-82a1-fcd67bc9a483",
|
||||
"name": "Consultar históricos Supabase"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ $json }}",
|
||||
"options": {
|
||||
"responseHeaders": {
|
||||
"entries": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Access-Control-Allow-Origin",
|
||||
"value": "*"
|
||||
},
|
||||
{
|
||||
"name": "Access-Control-Allow-Methods",
|
||||
"value": "GET,POST,OPTIONS"
|
||||
},
|
||||
{
|
||||
"name": "Access-Control-Allow-Headers",
|
||||
"value": "Content-Type, Authorization"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.5,
|
||||
"position": [
|
||||
528,
|
||||
-16
|
||||
],
|
||||
"id": "31c2d67f-3989-4342-9be3-ed718fc63e79",
|
||||
"name": "Responder históricos app"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"content": "# 📚 HISTÓRICOS DE VERIFICACIÓN — GUATEMALA\n\nEntrega a la aplicación el historial de reportes procesados para Guatemala.\n\n## Recepción de la solicitud\n\nEl Webhook recibe desde el Portal de Verificación de Nóminas una solicitud GET para cargar los registros históricos.\n\nLa solicitud puede incluir parámetros utilizados por la aplicación, como:\n\n- Año.\n- Mes.\n- Tipo de período.\n- Estado del reporte.\n- Usuario responsable.\n- Identificador del reporte.\n- Parámetros de ordenamiento o filtrado.\n\n## Consulta en Supabase\n\nEl flujo consulta en Supabase los reportes históricos correspondientes a Guatemala.\n\nSupabase funciona como fuente oficial para recuperar información como:\n\n- Identificador del reporte.\n- Año y mes procesados.\n- Tipo de nómina o período.\n- Fecha de ejecución.\n- Estado del reporte.\n- Cantidad de hallazgos.\n- Enlace al reporte generado.\n- Usuario que ejecutó el proceso.\n- Usuario y fecha de resolución.\n- Comentario de resolución, cuando exista.\n\n## Normalización para la aplicación\n\nLos registros recuperados se transforman al formato esperado por el portal.\n\nEste bloque:\n\n- Normaliza nombres de campos.\n- Convierte fechas al formato utilizado por la interfaz.\n- Establece valores predeterminados para campos vacíos.\n- Ordena los reportes según la lógica del portal.\n- Conserva los enlaces necesarios.\n- Prepara una estructura consistente aunque no existan resultados.\n\n## Respuesta al portal\n\nEl workflow devuelve a la aplicación:\n\n- Indicador de éxito.\n- Lista de históricos encontrados.\n- Cantidad total de registros.\n- Datos normalizados para mostrar en la interfaz.\n\nCuando no existen históricos, debe responder correctamente con una lista vacía y no tratar el resultado como un error.\n\n## Reglas\n\n- Consultar únicamente reportes correspondientes a Guatemala.\n- No modificar ningún registro durante esta operación.\n- No devolver campos internos o sensibles que la aplicación no necesita.\n- No inventar valores cuando Supabase devuelve campos vacíos.\n- Mantener una estructura de respuesta estable.\n- Responder siempre al Webhook para evitar solicitudes abiertas.\n- Supabase es la fuente oficial de los históricos mostrados en el portal.",
|
||||
"height": 1296,
|
||||
"width": 1504,
|
||||
"color": 6
|
||||
},
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-768,
|
||||
-752
|
||||
],
|
||||
"id": "0a6676a2-9aff-4a7c-b138-05bef8bb8752",
|
||||
"name": "Sticky Note"
|
||||
}
|
||||
],
|
||||
"pinData": {},
|
||||
"connections": {
|
||||
"Webhook Históricos GT": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Consultar históricos Supabase",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Consultar históricos Supabase": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Normalizar históricos para app",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Normalizar históricos para app": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Responder históricos app",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": true,
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate",
|
||||
"availableInMCP": true,
|
||||
"timeSavedMode": "fixed",
|
||||
"errorWorkflow": "puF4LUczoSz3hcek",
|
||||
"timezone": "America/Santo_Domingo",
|
||||
"callerPolicy": "workflowsFromSameOwner"
|
||||
},
|
||||
"versionId": "fab93c67-7332-4b99-80fe-648c4cace390",
|
||||
"meta": {
|
||||
"instanceId": "b4b77b17af092830e794eef639ce2f6d7daccf7eddc075060b03b3b6545aac70"
|
||||
},
|
||||
"id": "QDKFgvoJKviQbDl3",
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user