fix(cobranza): quita la leyenda "Incluye contratos con día 29/30/31..."
La leyenda aparecía siempre que la búsqueda agregaba días huérfanos (fin de mes), aunque ningún contrato cayera en un día inexistente (p. ej. 30 de junio mostraba la leyenda sin contratos de día 31). Confundía. Se elimina la leyenda del reporte diario (_formatear_reporte) y semanal (_formatear_reporte_semanal). No se toca la lógica: el flag incluye_orfanos sigue calculándose en sheets.generar_reporte_cobros; solo deja de renderizarse. Rentas, montos, VR, extras y el recorrido huérfano→último día→lunes intactos. tests/test_leyenda_orfanos.py: la leyenda no aparece ni con incluye_orfanos=True (diario y semanal). 32 tests OK. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6db44f502f
commit
3b6b40ccd8
2 files changed
+43
-4
No files matched your search
@@ -1669,8 +1669,6 @@ def _formatear_reporte(reporte: dict) -> str:
|
||||
encabezado = f"📋 *Cobros — {_fecha_larga_es(fecha)}*"
|
||||
if es_lunes:
|
||||
encabezado += "\n_(incluye sáb-dom)_"
|
||||
if reporte.get("incluye_orfanos"):
|
||||
encabezado += "\nℹ️ _Incluye contratos con día 29/30/31 que no existen este mes_"
|
||||
partes.append(encabezado)
|
||||
|
||||
# Sección 1 — rentas del día (siempre presente)
|
||||
@@ -1789,8 +1787,6 @@ def _formatear_reporte_semanal(reporte: dict) -> str:
|
||||
encabezado = f"📋 *Cobranza semanal — {_rango_semana_es(lunes, viernes)}*"
|
||||
else:
|
||||
encabezado = "📋 *Cobranza semanal*"
|
||||
if reporte.get("incluye_orfanos"):
|
||||
encabezado += "\nℹ️ _Incluye contratos con día 29/30/31 que no existen este mes_"
|
||||
|
||||
partes: list[str] = [encabezado]
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
La leyenda informativa "Incluye contratos con día 29/30/31 que no existen este
|
||||
mes" se removió: ya NO debe aparecer en el reporte, ni siquiera cuando el
|
||||
reporte trae incluye_orfanos=True. Solo se valida la presencia/ausencia de la
|
||||
leyenda; no se toca el cálculo de rentas/VR/extras.
|
||||
"""
|
||||
import os
|
||||
from datetime import date
|
||||
|
||||
os.environ.setdefault("OPENAI_API_KEY", "test-key-no-usada")
|
||||
|
||||
from src.api.webhook import _formatear_reporte, _formatear_reporte_semanal
|
||||
|
||||
LEYENDA = "29/30/31" # fragmento único de la leyenda removida
|
||||
|
||||
|
||||
def test_leyenda_no_aparece_diario():
|
||||
reporte = {
|
||||
"fecha": date(2026, 6, 30),
|
||||
"es_lunes": False,
|
||||
"rentas": [],
|
||||
"vr": [],
|
||||
"extras": [],
|
||||
"incluye_orfanos": True, # aunque venga True, NO debe imprimirse la leyenda
|
||||
}
|
||||
texto = _formatear_reporte(reporte)
|
||||
assert LEYENDA not in texto
|
||||
assert "no existen este mes" not in texto
|
||||
|
||||
|
||||
def test_leyenda_no_aparece_semanal():
|
||||
reporte = {
|
||||
"fecha": date(2026, 6, 29),
|
||||
"lunes": date(2026, 6, 29),
|
||||
"viernes": date(2026, 7, 3),
|
||||
"rentas_por_dia": {},
|
||||
"vr": [],
|
||||
"extras": [],
|
||||
"incluye_orfanos": True,
|
||||
}
|
||||
texto = _formatear_reporte_semanal(reporte)
|
||||
assert LEYENDA not in texto
|
||||
assert "no existen este mes" not in texto
|
||||
Reference in new issue
Block a user