feat(operaciones): inicio de la ventana vigente en la pantalla de cierre
GET /operaciones/cierre suma inicio_ventana_vigente (aggregates.inicio_ventana sobre el corte actual y la ventana del tenant, como Inicio) para dibujar la ventana vigente junto a la nueva. La lógica del cierre no cambia.
This commit is contained in:
1 parent
c55955649a
commit
a8d416b938
2 files changed
+9
-1
No files matched your search
@@ -24,6 +24,7 @@ from starlette.responses import HTMLResponse, RedirectResponse, Response
|
||||
|
||||
from app.auth import requiere_rol
|
||||
from app.db import get_db
|
||||
from app.engine.aggregates import inicio_ventana
|
||||
from app.importers.operations import TAMANO_MAXIMO_BYTES
|
||||
from app.models import Usuario
|
||||
from app.models.usuario import Rol
|
||||
@@ -173,11 +174,16 @@ def _cierre(
|
||||
justificacion: str = "",
|
||||
status_code: int = 200,
|
||||
) -> HTMLResponse:
|
||||
plan = servicio_periodo.plan_de_cierre(db, fecha_hoy=servicio_periodo.hoy())
|
||||
return render(
|
||||
request,
|
||||
"operaciones/cierre.html",
|
||||
{
|
||||
"plan": servicio_periodo.plan_de_cierre(db, fecha_hoy=servicio_periodo.hoy()),
|
||||
"plan": plan,
|
||||
# Para dibujar la ventana vigente junto a la nueva (como en Inicio).
|
||||
"inicio_ventana_vigente": inicio_ventana(
|
||||
plan.corte_actual, request.state.tenant.ventana_meses
|
||||
),
|
||||
"puede_cerrar": request.state.usuario.rol in ROLES_CIERRE,
|
||||
"error": error,
|
||||
"justificacion": justificacion,
|
||||
|
||||
@@ -633,6 +633,8 @@ def test_cierre_por_http_exige_confirmacion_y_justificacion(cliente: TestClient,
|
||||
pantalla = cliente.get("/operaciones/cierre")
|
||||
assert pantalla.status_code == 200
|
||||
assert "irreversible" in pantalla.text and "/data/pld.db" in pantalla.text
|
||||
# Corte vigente 31/08/2026 con ventana de 6 meses: (28/02/2026, 31/08/2026].
|
||||
assert pantalla.context["inicio_ventana_vigente"] == date(2026, 2, 28)
|
||||
assert (
|
||||
cliente.post(
|
||||
"/operaciones/cierre", data={"justificacion": "Sin marcar la casilla de confirmación."}
|
||||
|
||||
Reference in new issue
Block a user