{% extends "base.html" %} {% from "_componentes/tarjeta.html" import tarjeta %} {% from "_componentes/badges.html" import badge, badge_estado_alerta, badge_nivel_alerta %} {% from "_componentes/tabla.html" import tabla %} {% from "_componentes/aviso.html" import aviso as aviso_en_linea %} {% block titulo %}Alerta {{ alerta.id }} · {{ regla.clave }}{% endblock %} {% block contenido %}

← Alertas

Alerta #{{ alerta.id }} · {{ regla.clave }} {{ regla.nombre }}

{{ badge_nivel_alerta(alerta.nivel) }} {{ badge_estado_alerta(alerta.estado) }} · regla {{ regla.version }} vigente desde {{ regla.vigente_desde.strftime("%d/%m/%Y") }} · plazo: {{ alerta.plazo_aviso or "análisis interno" }}{% if alerta.vence_el %} · vence el {{ alerta.vence_el.strftime("%d/%m/%Y") }}{% endif %}

{% if aviso %}{% endif %} {% if error %}{{ aviso_en_linea(error, tono="peligro") }}{% endif %} {% call tarjeta("Regla", subtitulo=regla.criterio_texto) %}
Clave
{{ regla.clave }} · familia {{ regla.familia }}
Versión que la produjo
{{ regla.version }} (regla_id {{ regla.id }}){% if regla.valid_to %} {{ badge("sustituida", "aviso") }}{% endif %}
Tipo de evaluación
{{ regla.tipo_evaluacion }}
Parámetros
{% for k, v in (alerta.evidencia.parametros or {}).items() if not k.startswith("_") %}{{ k }}={{ v }} {% else %}—{% endfor %}
{% endcall %} {% call tarjeta("Cliente, crédito y transacciones") %}
Cliente
{{ cliente.id_externo }} · sus alertas
Crédito
{% if credito %}{{ credito.id_externo }} · ${{ "{:,.2f}".format(credito.monto) }} · {{ credito.status }}{% else %}—{% endif %}
{% if transacciones %} {% set columnas = [{"clave": "fecha_pago", "titulo": "Fecha"}, {"clave": "tipo", "titulo": "Tipo"}, {"clave": "metodo", "titulo": "Método"}, {"clave": "titular_origen", "titulo": "Titular origen"}, {"clave": "total", "titulo": "Total", "alinear": "der"}] %} {% call(fila, col) tabla(columnas, transacciones) %} {% if col.clave == "fecha_pago" %}{{ fila.fecha_pago.strftime("%d/%m/%Y") }}{% if fila.id == alerta.evidencia.transaccion_id %} {{ badge("dispara", "peligro") }}{% endif %} {% elif col.clave == "total" %}${{ "{:,.2f}".format(fila.total) }} {% else %}{{ fila[col.clave] or "—" }}{% endif %} {% endcall %} {% endif %} {% endcall %} {% call tarjeta("Evidencia", subtitulo="Los valores que dispararon la regla y el umbral aplicado") %}
{% for etiqueta, valor in evidencia %}
{{ etiqueta }}
{{ valor }}
{% endfor %}
{% endcall %} {% call tarjeta("Gestión", subtitulo="Responsable: " ~ (alerta.responsable or "sin asignar")) %} {% if puede_mutar %}
{% if transicion_disponible.en_revision %}
{% endif %} {% if caso_abierto %} Ver caso #{{ caso_abierto.id }} {% elif transicion_disponible.escalada %} Escalar: abrir caso {% endif %} {% if puede_cerrar %}
{% else %}

{{ badge("Cerrar requiere rol oficial", "aviso") }} Esta alerta es crítica.

{% endif %}
{% elif alerta.estado == "cerrada" %}

{{ badge("Cerrada", "neutro") }} Sin acciones disponibles.{% if caso_abierto %} Caso #{{ caso_abierto.id }}{% endif %}

{% elif caso_abierto %}

{{ badge("En caso", "acento") }} Ver caso #{{ caso_abierto.id }}

{% else %}

{{ badge("Solo lectura", "neutro") }} Tu rol ({{ usuario.rol }}) solo consulta.

{% endif %} {% endcall %} {% call tarjeta("Historial", subtitulo="Reconstruido desde el audit trail") %} {% set columnas = [{"clave": "fecha", "titulo": "Fecha"}, {"clave": "accion", "titulo": "Acción"}, {"clave": "usuario", "titulo": "Usuario"}, {"clave": "cambio", "titulo": "Cambio"}, {"clave": "motivo", "titulo": "Motivo"}] %} {% call(fila, col) tabla(columnas, historial, vacio="Sin eventos.") %} {% if col.clave == "fecha" %}{{ fila.fecha.strftime("%d/%m/%Y %H:%M") }} {% elif col.clave == "cambio" %}{% if fila.antes %}{{ fila.antes.estado or fila.antes.responsable or "" }} → {% endif %}{{ (fila.despues or {}).get("estado") or (fila.despues or {}).get("responsable") or (fila.despues or {}).get("regla") or "" }} {% else %}{{ fila[col.clave] or "—" }}{% endif %} {% endcall %} {% endcall %} {% endblock %}