Fix error display: show TNS response separately, default filter contrato=011

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-26 19:25:33 -05:00
co-authored by Claude Sonnet 4.6
parent da99a446f1
commit e477aa2bea
2 changed files with 23 additions and 9 deletions
+9 -3
View File
@@ -234,13 +234,18 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)):
examenes = [r.get("COD_EXAMEN", "") for r in grupo_rows]
try:
r = await client.post(endpoint_rda, json=rda_json, headers=headers)
raw_resp = r.text
try:
data = r.json()
ok_rda = (data.get("status") or (data.get("data") or {}).get("success", False)) if isinstance(data, dict) else False
msg_rda = ((data.get("data") or {}).get("response") or data.get("message") or r.text[:200])
ok_rda = bool(data.get("status") or (data.get("data") or {}).get("success", False)) if isinstance(data, dict) else False
msg_rda = (
((data.get("data") or {}).get("response"))
or data.get("message")
or raw_resp[:300]
)
except Exception:
ok_rda = r.status_code < 300
msg_rda = r.text[:200]
msg_rda = raw_resp[:300]
pasos.append({
"tipo": "rda",
"idrecepcion": id_rec,
@@ -251,6 +256,7 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)):
"status": r.status_code,
"ok": ok_rda,
"mensaje": msg_rda,
"respuesta_tns": raw_resp,
"json_enviado": rda_json,
})
except Exception as ex:
+14 -6
View File
@@ -9,7 +9,7 @@
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
<h3 class="font-semibold text-gray-800"><i class="fas fa-list mr-2 text-blue-500"></i>Candidatos disponibles</h3>
<div class="flex gap-2 items-center flex-wrap">
<input id="filtro-contrato" type="text" placeholder="Contrato (ej: 011)"
<input id="filtro-contrato" type="text" placeholder="Contrato (ej: 011)" value="011"
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-32">
<input id="filtro-articulos" type="text" placeholder="Artículos (ej: CH4,TSH,GLI)"
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-56"
@@ -189,6 +189,9 @@ async function enviarRDA() {
} else {
const jsonStr = JSON.stringify(p.json_enviado || {}, null, 2);
const uid = 'json_' + p.idrecepcion;
const uid2 = 'resp_' + p.idrecepcion;
let respTns = '';
try { respTns = JSON.stringify(JSON.parse(p.respuesta_tns || '{}'), null, 2); } catch(e) { respTns = p.respuesta_tns || ''; }
html += `
<div class="rounded-lg border ${p.ok ? 'border-green-200 bg-green-50' : 'border-red-200 bg-red-50'}">
<div class="flex items-start gap-3 p-3">
@@ -198,16 +201,21 @@ async function enviarRDA() {
IDRECEPCION <span class="font-mono text-blue-700">${p.idrecepcion}</span>
· Factura <span class="font-mono">${p.factura}</span>
· Contrato <span class="font-mono text-purple-700">${p.contrato}</span>
<span class="text-gray-400 text-xs ml-1">HTTP ${p.status || '?'}</span>
</p>
<p class="text-xs text-gray-500 mt-0.5">Exámenes: ${(p.examenes || []).join(', ')}</p>
<div class="mt-1.5 px-3 py-2 rounded ${p.ok ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'} text-sm font-medium break-words">
${p.ok ? '✅' : '❌'} ${p.mensaje || '(sin mensaje)'}
<div class="mt-2 px-3 py-2 rounded-lg border ${p.ok ? 'border-green-300 bg-green-100 text-green-900' : 'border-red-300 bg-red-100 text-red-900'} text-sm font-semibold">
${p.mensaje || '(sin mensaje de TNS)'}
</div>
${!p.ok ? `<p class="text-xs text-gray-400 mt-1">HTTP ${p.status || '?'}</p>` : ''}
</div>
<button onclick="document.getElementById('${uid}').classList.toggle('hidden')"
class="px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 text-gray-600 rounded shrink-0">Ver JSON</button>
<div class="flex flex-col gap-1 shrink-0">
<button onclick="document.getElementById('${uid2}').classList.toggle('hidden')"
class="px-2 py-1 text-xs bg-yellow-100 hover:bg-yellow-200 text-yellow-800 rounded">Resp. TNS</button>
<button onclick="document.getElementById('${uid}').classList.toggle('hidden')"
class="px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 text-gray-600 rounded">JSON env.</button>
</div>
</div>
<pre id="${uid2}" class="hidden mx-3 mb-1 p-3 bg-yellow-950 text-yellow-200 rounded text-xs overflow-x-auto whitespace-pre-wrap">${respTns.replace(/</g,'&lt;')}</pre>
<pre id="${uid}" class="hidden mx-3 mb-3 p-3 bg-gray-900 text-green-300 rounded text-xs overflow-x-auto whitespace-pre-wrap">${jsonStr.replace(/</g,'&lt;')}</pre>
</div>`;
}