{% extends "base.html" %} {% from "_componentes/tarjeta.html" import tarjeta %} {% from "_componentes/badges.html" import badge, badge_nivel, badge_estado_alerta, badge_nivel_alerta %} {% from "_componentes/aviso.html" import aviso as aviso_en_linea %} {% from "_componentes/iconos.html" import icono %} {% from "operaciones/_perfil.html" import perfil_observado, perfil_etiquetas %} {% from "_componentes/pendiente.html" import pendiente %} {#- Ids que son destino de redirecciones y no cambian: #documentos, #declaracion y #listas. -#} {% block titulo %}Cliente {{ cliente.id_externo }}{% endblock %} {% from "avisos/_reportes.html" import reportes_aviso %} {% block contenido %} {%- set ABIERTAS = ("nueva", "en_revision", "escalada") %} {%- set alertas_abiertas = alertas | selectattr("0.estado", "in", ABIERTAS) | list | length %} {%- set casos_abiertos = casos | rejectattr("estado", "equalto", "cerrado") | list | length %} {%- set ETIQUETAS_LISTA = {"ofac_sdn": "OFAC", "onu": "ONU", "sat_69b": "69-B", "pep": "PEP"} %} {%- set activas = namespace(por_lista={}, confirmadas=0, pendientes=0) %} {%- for c, li in coincidencias if c.decision != "descartada" %} {%- if li %}{% set _ = activas.por_lista.update({li.nombre: True}) %}{% endif %} {%- if c.decision == "confirmada" %}{% set activas.confirmadas = activas.confirmadas + 1 %}{% else %}{% set activas.pendientes = activas.pendientes + 1 %}{% endif %} {%- endfor %} {% if aviso %} {% set textos_aviso = {"identificacion": "Identificación guardada como versión nueva.", "declaracion": "Declaración registrada."} %} {% if aviso.startswith("alerta-") %}{% set texto = "Alerta manual registrada (" ~ aviso ~ ")." %} {% elif aviso.startswith("documento-") %}{% set texto = "Documento guardado (" ~ aviso ~ ")." %} {% elif aviso.startswith("tercero-") %}{% set texto = "Tercero dado de alta; confirma la declaración abajo." %} {% elif aviso.startswith("screening-") %}{% set partes = aviso.split("-") %}{% set texto = "Screening ejecutado: " ~ partes[1] ~ " coincidencias nuevas en " ~ partes[2] ~ " nombres consultados." %} {% else %}{% set texto = textos_aviso.get(aviso, aviso) %}{% endif %} {% if aviso != "alta" %}
{% endif %} {% endif %}Cliente · {{ "Persona física" if cliente.tipo_persona == "fisica" else "Persona moral" }}
{%- if identificacion %}| Documento | Estado | Versión | Vigencia / emisión | Cotejado | Archivo |
|---|---|---|---|---|---|
| {{ fila.catalogo.nombre if fila.catalogo else doc.tipo }}{% if doc.subtipo %}{{ doc.subtipo | replace("_", " ") }}{% endif %} | {{ badge(fila.estado | capitalize, {"vigente": "exito", "vencido": "peligro", "desactualizado": "peligro"}[fila.estado]) }} |
v{{ doc.version }}
{%- if fila.historial | length > 1 %}
{{ fila.historial | length - 1 }} anterior{{ "es" if fila.historial | length > 2 else "" }}
|
{%- if doc.vigencia %}Vigente hasta {{ doc.vigencia.strftime("%d/%m/%Y") }}{% endif %}
{%- if doc.fecha_emision %}{% if doc.vigencia %} {% endif %}Emitido {{ doc.fecha_emision.strftime("%d/%m/%Y") }}{% endif %} {%- if not doc.vigencia and not doc.fecha_emision %}—{% endif -%} |
{% if doc.cotejado_por %}{{ badge("Contra original", "exito") }} {{ doc.cotejado_por }}{% else %}{{ badge("Sin cotejar", "aviso") }}{% endif %} | {{ doc.nombre_original or "descargar" }}{% if doc.tamano_bytes %}{{ "{:,.0f}".format(doc.tamano_bytes / 1024) }} KB · sha256 {{ doc.sha256[:12] }}…{% endif %} |
| Sin documentos. | |||||
{{ badge("Solo analista u oficial", "neutro") }} Tu rol ({{ usuario.rol }}) consulta y descarga; cada descarga queda en el audit trail.
{%- endif %} {% endcall %} {# ------------------------------------------------------------ Declaración #} {% set acciones %} {%- if declaracion %} {%- if declaracion.por_cuenta_propia %}{{ badge("Por cuenta propia", "exito") }} {%- else %}{{ badge("Por cuenta de un tercero", "aviso") }} {% if tercero %}{{ tercero.id_externo }}{% else %}#{{ declaracion.tercero_id }}{% endif %}{% endif %} {%- else %}Sin declaración registrada{% endif %} {%- endset %} {% call tarjeta("Declaración", subtitulo=("Por cuenta propia o de un tercero · vigente desde " ~ declaracion.valid_from | mx("%d/%m/%Y %H:%M") ~ " · " ~ declaracion.created_by) if declaracion else "Por cuenta propia o de un tercero · versionada", acciones=acciones, plano=True, id="declaracion", clase="ancla") %} {%- if historial_declaraciones | length > 1 %}Persona moral: el modelo v2 se calibró con personas físicas. {{ pendiente("ponderacion_morales") }}
{% endif %} {%- if evaluacion %}| Lista | Entrada | Persona | Score | Decisión | Decidió |
|---|---|---|---|---|---|
| {{ titulos_listas.get(li.nombre, li.nombre) if li else (c.fuente | fuente) }}{% if li %}versión {{ li.fecha_version.strftime("%d/%m/%Y") }}{% endif %} | {{ c.texto_lista or "Bandera LISTAS del esquema" }}{% if c.alias %} {{ badge("alias", "info") }}{% endif %} | {% if c.persona_id == cliente.id %}El cliente{% else %}{{ (roles_relacionados.get(c.persona_id) or (c.detalle or {}).get("rol_consultado", "relacionado")) | replace("_", " ") }} · #{{ c.persona_id }}{% endif %} | {{ c.score if c.score is not none else "—" }} | {{ badge(c.decision | capitalize, {"confirmada": "peligro", "descartada": "neutro", "pendiente": "aviso"}[c.decision]) }} | {{ c.decidido_por or "—" }} |
| Fecha | Tipo | Método | Titular origen | Total |
|---|---|---|---|---|
| {{ t.fecha_pago.strftime("%d/%m/%Y") }} | {{ (t.tipo or "—") | capitalize }} | {{ (t.metodo or "—") | capitalize }} | {{ badge(t.titular_origen, "peligro" if t.titular_origen == "TERCERO" else ("aviso" if t.titular_origen == "CUENTA" else "neutro")) }} | ${{ "{:,.2f}".format(t.total) }} |
| Sin transacciones. | ||||
| Regla | Nivel | Estado | Vence | Resp. |
|---|---|---|---|---|
| {{ regla.clave }} {{ regla.nombre }} {{ regla.version }} | {{ badge_nivel_alerta(alerta.nivel) }} | {{ badge_estado_alerta(alerta.estado) }} | {{ alerta.vence_el.strftime("%d/%m/%Y") if alerta.vence_el else "—" }} | {{ alerta.responsable or "—" }} |
{{ badge("Solo analista u oficial", "neutro") }} Tu rol ({{ usuario.rol }}) solo consulta.
{%- endif %} {% endcall %} {# ---------------------------------------------------------------- Beneficiario controlador (D9) #} {%- if cliente.tipo_persona == "moral" %} {% set acciones %}Grafo de participaciones, captura e historial{% endset %} {% call tarjeta("Beneficiario controlador", subtitulo=("Criterio " ~ beneficiarios[0].criterio ~ " · vigente desde " ~ beneficiarios[0].valid_from | mx("%d/%m/%Y %H:%M")) if beneficiarios else "Prelación: participación ≥ 25 %, control por otros medios, administrador", acciones=acciones, plano=True, id="c-beneficiario", clase="ancla") %}