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>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""
|
|
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
|