260 lines
17 KiB
HTML
260 lines
17 KiB
HTML
{% extends "base.html" %}
|
|
{% from "_componentes/tarjeta.html" import tarjeta %}
|
|
{% from "_componentes/aviso.html" import aviso as aviso_ui %}
|
|
{% from "_componentes/badges.html" import badge %}
|
|
|
|
{#- Preparación del aviso del periodo (Pieza N, bloque 3). Todo sale de
|
|
services/avisos_preparacion.py; el analista y el oficial preparan, el auditor consulta. -#}
|
|
|
|
{% set ancho = "amplio" %}
|
|
{% set estados = {
|
|
"borrador": ("Borrador", "info"),
|
|
"generado": ("Generado", "acento"),
|
|
"presentado": ("Presentado", "aviso"),
|
|
"acusado": ("Acusado", "exito"),
|
|
"rechazado": ("Rechazado", "peligro"),
|
|
} %}
|
|
|
|
{% block titulo %}Aviso de {{ mes }}{% endblock %}
|
|
|
|
{% block contenido %}
|
|
<header class="pagina__encabezado">
|
|
<div class="pagina__textos pagina__textos--ancho">
|
|
<p class="pagina__ceja">Avisos al Servicio de Administración Tributaria · periodo {{ periodo }}</p>
|
|
<h1 class="pagina__titulo">Aviso de {{ mes }}</h1>
|
|
<p class="pagina__meta" data-limites>
|
|
{%- if aviso %}{% set e = estados[aviso.estado] %}{{ badge(e[0], e[1]) }}{% if aviso.tipo == "sin_operaciones" %} <span>Informe sin operaciones</span>{% endif %}{% else %}{{ badge("Sin preparar", "neutro") }}{% endif %}
|
|
<span class="texto-tenue">·</span><span>Fecha límite {{ limite.strftime("%d/%m/%Y") }}</span>
|
|
{%- if facilidad %}<span class="texto-tenue">·</span><span title="Facilidad del sexto dígito numérico del RFC (Preguntas frecuentes del SAT 2026, 5.2 y 5.3)">con la facilidad del sexto dígito del RFC: {{ facilidad.strftime("%d/%m/%Y") }}</span>{% endif %}
|
|
<span class="texto-tenue">·</span><a class="enlace-subrayado" href="/avisos/{{ anterior }}">periodo anterior</a>
|
|
<span class="texto-tenue">·</span><a class="enlace-subrayado" href="/avisos/{{ siguiente }}">siguiente</a>
|
|
</p>
|
|
</div>
|
|
</header>
|
|
|
|
{% if error %}{{ aviso_ui(error, tono="peligro") }}{% endif %}
|
|
|
|
<ol class="pasos-flujo" aria-label="Flujo mensual" data-fase="{{ fase }}">
|
|
{%- for f in fases %}
|
|
<li class="pasos-flujo__paso{{ ' es-actual' if f.clave == fase }}" data-paso="{{ f.clave }}"><strong>{{ f.titulo }}</strong><small>días {{ f.pasos }}</small></li>
|
|
{%- endfor %}
|
|
</ol>
|
|
{% if fase == "vencido" %}{{ aviso_ui("La fecha límite de este aviso ya pasó y no tiene acuse.", tono="peligro") }}
|
|
{% elif fase == "terminado" %}{{ aviso_ui("Aviso acusado: el periodo está cerrado.", tono="exito") }}
|
|
{% elif fase == "pendiente" %}{{ aviso_ui("El periodo todavía no termina: el aviso se prepara a partir del día 1 del mes siguiente.", tono="info") }}{% endif %}
|
|
|
|
{% if situacion %}
|
|
<div data-situacion-plazo>
|
|
{{ aviso_ui(("Acusado" if aviso.estado == "acusado" else "Sin acuse") ~ " " ~ situacion.dias_de_retraso ~ " días después de la fecha límite (" ~ situacion.limite.strftime("%d/%m/%Y") ~ "). " ~ situacion.tramo.titulo ~ ": multa de " ~ situacion.tramo.uma_minimo ~ " a " ~ situacion.tramo.uma_maximo ~ " veces la UMA ($" ~ "{:,.2f}".format(situacion.monto_minimo) ~ " a $" ~ "{:,.2f}".format(situacion.monto_maximo) ~ " con la UMA de la empresa). El plazo de los 30 días " ~ ("vence" if situacion.tramo.clave == "en_30_dias" else "venció") ~ " el " ~ situacion.fin_tolerancia.strftime("%d/%m/%Y") ~ ". Fundamento: " ~ situacion.tramo.fundamento ~ ".", tono="peligro") }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if sin_informacion %}
|
|
{{ aviso_ui("La información cargada llega al " ~ (informacion_al.strftime("%d/%m/%Y") if informacion_al else "—") ~ ": no cubre el periodo completo. Carga la información del mes antes de generar el aviso.", tono="aviso") }}
|
|
{% endif %}
|
|
|
|
{% call tarjeta("Operaciones objeto de aviso", subtitulo="Créditos con alerta de aviso del periodo (A-01 y A-02) y los que se agregaron con justificación") %}
|
|
{% if candidatas %}
|
|
<div class="tabla-contenedor">
|
|
<table class="tabla" data-candidatas>
|
|
<thead><tr><th>Crédito</th><th>Cliente</th><th>Fecha</th><th class="num">Monto</th><th>Instrumento</th><th class="num">Acumulado 6 meses</th><th>Motivo</th><th>Tipo de alerta</th><th>Estado</th>{% if puede_preparar and es_borrador and aviso %}<th></th>{% endif %}</tr></thead>
|
|
<tbody>
|
|
{%- for c in candidatas %}
|
|
<tr data-credito="{{ c.id_credito }}"{% if c.excluida %} class="es-tenue"{% endif %}>
|
|
<td class="mono"><a href="/creditos/{{ c.credito_id }}">{{ c.id_credito }}</a></td>
|
|
<td><a href="/clientes/{{ c.cliente_id }}">{{ c.cliente }}</a></td>
|
|
<td>{{ c.fecha.strftime("%d/%m/%Y") if c.fecha else "—" }}</td>
|
|
<td class="num">${{ "{:,.2f}".format(c.monto) }}</td>
|
|
<td>{{ c.instrumento or "—" }}</td>
|
|
<td class="num">{{ "$" ~ "{:,.2f}".format(c.acumulado) if c.acumulado is not none else "—" }}</td>
|
|
<td>{{ "Inclusión manual" if c.manual else c.reglas | join(", ") }}</td>
|
|
<td data-tipo-alerta="{{ alertas[c.credito_id].tipo_alerta if c.credito_id in alertas else '' }}">{% if c.credito_id in alertas %}{% set a = alertas[c.credito_id] %}<span class="mono">{{ a.tipo_alerta }}</span>{% if a.descripcion %}<small class="texto-tenue">{{ a.descripcion }}</small>{% endif %}
|
|
{%- if a.a_criterio %}<small class="texto-tenue" data-a-criterio>A criterio del oficial ({{ a.a_criterio | join(", ") }}){% if a.elegido %}: eligió {{ a.elegido }}{% endif %}</small>{% endif %}
|
|
{%- if puede_confirmar and es_borrador and aviso and a.opciones %}
|
|
<form method="post" action="/avisos/{{ periodo }}/operaciones/{{ c.credito_id }}/tipo-alerta" class="formulario-en-linea" data-elegir-tipo-alerta>
|
|
<select class="campo__entrada" name="codigo" aria-label="Clave elegida por el oficial">
|
|
<option value="">Lo que dice la tabla</option>
|
|
{%- for o in a.opciones if o != "9999" %}<option value="{{ o }}"{% if a.elegido == o %} selected{% endif %}>{{ o }}</option>{% endfor %}
|
|
</select>
|
|
<button class="boton boton--secundario" type="submit">Aplicar</button>
|
|
</form>
|
|
{%- endif %}
|
|
{%- if puede_confirmar and es_borrador and aviso %}
|
|
<details class="detalle-en-linea" data-subir-9999>
|
|
<summary>{{ "Editar la narrativa" if a.tipo_alerta == "9999" else "Subir a 9999 (otra alerta)" }}</summary>
|
|
<form method="post" action="/avisos/{{ periodo }}/operaciones/{{ c.credito_id }}/descripcion" class="formulario-en-linea">
|
|
<textarea class="campo__entrada" name="descripcion" rows="3" maxlength="3000" aria-label="Narrativa de la alerta">{{ c.descripcion_alerta or a.sugerencia }}</textarea>
|
|
<button class="boton boton--secundario" type="submit">Guardar 9999 con esta narrativa</button>
|
|
</form>
|
|
{%- if a.elevada %}
|
|
<form method="post" action="/avisos/{{ periodo }}/operaciones/{{ c.credito_id }}/descripcion"><input type="hidden" name="descripcion" value=""><button class="boton boton--secundario" type="submit">Quitar 9999</button></form>
|
|
{%- endif %}
|
|
</details>
|
|
{%- endif %}{% else %}—{% endif %}</td>
|
|
<td>{% if c.excluida %}{{ badge("Excluida", "neutro") }}<small class="texto-tenue">{{ c.justificacion }}</small>{% else %}{{ badge("Incluida", "exito") }}{% endif %}</td>
|
|
{%- if puede_preparar and es_borrador and aviso %}
|
|
<td>
|
|
<form method="post" action="/avisos/{{ periodo }}/operaciones/{{ c.credito_id }}/{{ 'incluir' if c.excluida else 'excluir' }}" class="formulario-en-linea">
|
|
<input class="campo__entrada" type="text" name="justificacion" placeholder="Justificación" minlength="10" required aria-label="Justificación">
|
|
<button class="boton boton--secundario" type="submit">{{ "Volver a incluir" if c.excluida else "Excluir" }}</button>
|
|
</form>
|
|
</td>
|
|
{%- endif %}
|
|
</tr>
|
|
{%- endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<p class="texto-tenue" data-sin-candidatas>Sin operaciones objeto de aviso en {{ mes }}: corresponde el informe sin operaciones (no presentarlo también es infracción).</p>
|
|
{% endif %}
|
|
{% if puede_preparar and es_borrador and aviso %}
|
|
<form method="post" action="/avisos/{{ periodo }}/incluir" class="formulario-en-linea" data-incluir-manual>
|
|
<input class="campo__entrada campo__entrada--mono" type="text" name="id_credito" placeholder="Identificador del crédito" required aria-label="Identificador del crédito">
|
|
<input class="campo__entrada" type="text" name="justificacion" placeholder="Justificación" minlength="10" required aria-label="Justificación">
|
|
<button class="boton boton--secundario" type="submit">Agregar al aviso</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endcall %}
|
|
|
|
{% call tarjeta("Datos faltantes", subtitulo="No se genera el aviso mientras falte algo; cada renglón lleva a donde se corrige") %}
|
|
{% if faltantes %}
|
|
<ul class="lista-faltantes" data-faltantes>
|
|
{%- for f in faltantes %}
|
|
<li data-campo="{{ f.campo }}"><span class="mono">{{ f.campo }}</span> · {{ f.mensaje }}{% if f.enlace %} <a class="enlace-subrayado" href="{{ f.enlace }}">corregir</a>{% endif %}</li>
|
|
{%- endfor %}
|
|
</ul>
|
|
{% elif aviso %}
|
|
<p class="texto-tenue" data-sin-faltantes>Sin datos faltantes{% if aviso.estado == "borrador" %}{% if sin_confirmar %}: falta confirmar los supuestos{% else %}: el aviso está listo para generarse{% endif %}{% endif %}.</p>
|
|
{% elif faltantes_empresa %}
|
|
<p class="texto-tenue">Empresa: falta {{ faltantes_empresa | join("; ") }}. <a class="enlace-subrayado" href="/perfil-regulatorio/sujeto-obligado">corregir</a></p>
|
|
{% else %}
|
|
<p class="texto-tenue">Prepara el aviso para revisar los datos de cada cliente y crédito.</p>
|
|
{% endif %}
|
|
{% endcall %}
|
|
|
|
{% if aviso and supuestos %}
|
|
{% call tarjeta("Supuestos", subtitulo="Valores que el aviso no toma capturados sino inferidos; el oficial los confirma antes de generar") %}
|
|
<div class="tabla-contenedor">
|
|
<table class="tabla" data-supuestos>
|
|
<thead><tr><th>Elemento</th><th>Valor supuesto</th><th>Origen</th><th class="num">Operaciones</th><th>Estado</th>{% if puede_confirmar and es_borrador %}<th></th>{% endif %}</tr></thead>
|
|
<tbody>
|
|
{%- for s in supuestos %}
|
|
<tr data-supuesto="{{ s.campo }}" data-fuente="{{ s.fuente }}">
|
|
<td class="mono">{{ s.campo }}</td>
|
|
<td>{% for v in s.valores[:3] %}{{ v }}{% if not loop.last %}<br>{% endif %}{% endfor %}{% if s.valores | length > 3 %}<br><small class="texto-tenue">y {{ s.valores | length - 3 }} más</small>{% endif %}</td>
|
|
<td>{{ badge("Supuesto", "aviso") }} {{ s.origen }}{% if s.enlace %} <a class="enlace-subrayado" href="{{ s.enlace }}">cambiar</a>{% endif %}</td>
|
|
<td class="num">{{ s.creditos | length if s.creditos else s.clientes | length }}</td>
|
|
<td>{% if s.confirmado_por %}{{ badge("Confirmado", "exito") }}<small class="texto-tenue">{{ s.confirmado_por }} · {{ s.confirmado_en | mx }}</small>{% else %}{{ badge("Sin confirmar", "neutro") }}{% endif %}</td>
|
|
{%- if puede_confirmar and es_borrador %}
|
|
<td>{% if not s.confirmado_por %}<form method="post" action="/avisos/{{ periodo }}/supuestos/confirmar"><input type="hidden" name="supuesto_id" value="{{ s.id }}"><button class="boton boton--secundario" type="submit">Confirmar</button></form>{% endif %}</td>
|
|
{%- endif %}
|
|
</tr>
|
|
{%- endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% if sin_confirmar %}
|
|
<p class="texto-tenue" data-sin-confirmar>{{ sin_confirmar | length }} supuesto{{ "s" if sin_confirmar | length != 1 }} sin confirmar: el aviso no se genera hasta que el oficial los confirme o los corrija donde dice «cambiar».</p>
|
|
{% if puede_confirmar and es_borrador %}
|
|
<form method="post" action="/avisos/{{ periodo }}/supuestos/confirmar" class="acciones" data-confirmar-todos>
|
|
<button class="boton boton--secundario" type="submit">Confirmar todos los supuestos</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endcall %}
|
|
{% endif %}
|
|
|
|
{% if aviso %}
|
|
{% call tarjeta("Generación del XML", subtitulo=(formato.nombre ~ " · " ~ formato.clave) if formato else "Sin formato vigente") %}
|
|
{% if aviso.estado == "borrador" %}
|
|
{% if puede_generar %}
|
|
<form method="post" action="/avisos/{{ periodo }}/generar" class="acciones" data-generar>
|
|
<button class="boton boton--primario" type="submit"{% if faltantes or sin_confirmar %} disabled{% endif %}>Generar y validar el XML</button>
|
|
{% if faltantes or sin_confirmar %}<small class="texto-tenue">Antes: {% if faltantes %}corrige los datos faltantes{% endif %}{% if faltantes and sin_confirmar %} y {% endif %}{% if sin_confirmar %}confirma los supuestos{% endif %}.</small>{% endif %}
|
|
</form>
|
|
{% else %}
|
|
<p class="texto-tenue">El oficial de cumplimiento genera el XML.</p>
|
|
{% endif %}
|
|
{% elif aviso.xml_sha256 %}
|
|
<dl class="datos" data-xml-generado>
|
|
<div class="datos__par"><dt>Formato</dt><dd class="texto mono">{{ aviso.version_formato }}</dd></div>
|
|
<div class="datos__par"><dt>Generado</dt><dd class="texto">{{ aviso.generado_por }} · {{ aviso.generado_en | mx }}</dd></div>
|
|
<div class="datos__par"><dt>Huella SHA-256</dt><dd class="texto mono">{{ aviso.xml_sha256 }}</dd></div>
|
|
</dl>
|
|
{% if puede_generar %}
|
|
<p class="acciones">
|
|
<a class="boton boton--primario" href="/avisos/{{ periodo }}/xml" data-descargar-xml>Descargar el XML</a>
|
|
</p>
|
|
{% if aviso.estado == "generado" %}
|
|
<form method="post" action="/avisos/{{ periodo }}/borrador" class="formulario-en-linea" data-volver-borrador>
|
|
<input class="campo__entrada" type="text" name="motivo" placeholder="Motivo" required aria-label="Motivo">
|
|
<button class="boton boton--secundario" type="submit">Volver a borrador para corregir</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if aviso.estado in ("generado", "presentado") and puede_generar %}
|
|
<div class="bloque-acuse" data-acuse>
|
|
<h3 class="tarjeta__subtitulo">Acuse del portal</h3>
|
|
{% set sha = (propuesta.sha256 if propuesta else acuse_form.get("acuse_sha")) %}
|
|
{% if not sha %}
|
|
<form method="post" action="/avisos/{{ periodo }}/acuse/leer" enctype="multipart/form-data" class="formulario-en-linea" data-leer-acuse>
|
|
<input class="campo__entrada" type="file" name="archivo" accept="application/pdf" required aria-label="PDF del acuse">
|
|
<button class="boton boton--secundario" type="submit">Subir el PDF del acuse</button>
|
|
</form>
|
|
{% else %}
|
|
{% if propuesta %}<p class="texto-tenue" data-propuesta>{% if propuesta.legible %}Folio y fecha propuestos a partir del PDF: revísalos antes de registrar.{% else %}No se pudo leer el PDF: captura el folio y la fecha del acuse.{% endif %}</p>{% endif %}
|
|
<form method="post" action="/avisos/{{ periodo }}/acuse" class="formulario-en-linea" data-registrar-acuse>
|
|
<input type="hidden" name="acuse_sha" value="{{ sha }}">
|
|
<input class="campo__entrada campo__entrada--mono" type="text" name="folio" placeholder="AAAA-999999999" value="{{ (propuesta.folio if propuesta else acuse_form.get('folio')) or '' }}" required aria-label="Folio del acuse">
|
|
<input class="campo__entrada" type="date" name="fecha_presentacion" value="{{ (propuesta.fecha_presentacion.isoformat() if propuesta and propuesta.fecha_presentacion else acuse_form.get('fecha')) or '' }}" required aria-label="Fecha de presentación">
|
|
<button class="boton boton--primario" type="submit">Registrar el acuse</button>
|
|
</form>
|
|
{% endif %}
|
|
<form method="post" action="/avisos/{{ periodo }}/rechazo" class="formulario-en-linea" data-rechazo>
|
|
<textarea class="campo__entrada" name="mensaje" rows="2" placeholder="Mensaje de rechazo del portal" required aria-label="Mensaje de rechazo"></textarea>
|
|
<button class="boton boton--secundario" type="submit">Registrar rechazo</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
{% if aviso.estado == "acusado" %}
|
|
<dl class="datos" data-acusado>
|
|
<div class="datos__par"><dt>Folio del acuse</dt><dd class="texto mono">{{ aviso.folio_acuse }}</dd></div>
|
|
<div class="datos__par"><dt>Presentado</dt><dd class="texto">{{ aviso.fecha_presentacion.strftime("%d/%m/%Y") if aviso.fecha_presentacion else "—" }}</dd></div>
|
|
<div class="datos__par"><dt>Registró</dt><dd class="texto">{{ aviso.acusado_por or "—" }}{% if aviso.acusado_en %} · {{ aviso.acusado_en | mx }}{% endif %}</dd></div>
|
|
</dl>
|
|
{% if aviso.acuse_ruta and puede_ver_acuse %}<p class="acciones"><a class="boton boton--secundario" href="/avisos/{{ periodo }}/acuse.pdf" data-descargar-acuse>Descargar el acuse</a></p>{% endif %}
|
|
{% endif %}
|
|
{% if aviso.motivo_rechazo and aviso.estado != "acusado" %}
|
|
{{ aviso_ui("Último rechazo del portal: " ~ aviso.motivo_rechazo, tono="aviso") }}
|
|
{% endif %}
|
|
{% if errores %}
|
|
<div class="tabla-contenedor">
|
|
<table class="tabla" data-errores-validacion>
|
|
<thead><tr><th>Capa</th><th>Regla</th><th>Campo</th><th>Operación</th><th>Qué corregir</th></tr></thead>
|
|
<tbody>
|
|
{%- for f in errores %}
|
|
<tr data-regla="{{ f.error.regla }}">
|
|
<td>{{ f.error.titulo_capa }}</td>
|
|
<td class="mono">{{ f.error.regla }}</td>
|
|
<td class="mono">{{ f.error.campo }}</td>
|
|
<td>{% if f.credito %}<a href="/creditos/{{ f.credito.id }}">{{ f.credito.id_externo }}</a> · <a href="/clientes/{{ f.cliente_id }}">{{ f.cliente }}</a>{% elif f.error.referencia %}<span class="mono">{{ f.error.referencia }}</span>{% else %}Archivo{% endif %}</td>
|
|
<td>{{ f.error.mensaje }}</td>
|
|
</tr>
|
|
{%- endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{% endif %}
|
|
|
|
{% if puede_preparar and es_borrador %}
|
|
<form method="post" action="/avisos/{{ periodo }}/preparar" class="acciones" data-preparar>
|
|
{%- if not candidatas and not aviso %}<input type="hidden" name="tipo" value="sin_operaciones">{% endif %}
|
|
<button class="boton boton--primario" type="submit">{% if aviso %}Revisar de nuevo{% elif candidatas %}Preparar el aviso{% else %}Preparar el informe sin operaciones{% endif %}</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endblock %}
|