diff --git a/Plantilla_WK2.docm b/Plantilla_WK2.docm index e02b69f..948f3d5 100644 Binary files a/Plantilla_WK2.docm and b/Plantilla_WK2.docm differ diff --git a/tests/test_toma_a_cuenta.py b/tests/test_toma_a_cuenta.py index 9f3abd4..0eae7de 100644 --- a/tests/test_toma_a_cuenta.py +++ b/tests/test_toma_a_cuenta.py @@ -48,6 +48,47 @@ def test_toma_placeholder_vacio_se_oculta(): assert reps["$TOMA$"] == "" +# ── Camino B: el renglón $TOMA$ vive en la plantilla ───────────── + +def test_plantilla_tiene_placeholder_toma(): + import zipfile + with zipfile.ZipFile(pg.TEMPLATE_PATH) as z: + xml = z.read("word/document.xml").decode("utf-8", "ignore") + assert "$TOMA$" in xml + + +def _texto_tablas_docx(path): + from docx import Document + doc = Document(path) + return "\n".join( + p.text for t in doc.tables for r in t.rows for c in r.cells + for p in c.paragraphs + ) + + +def test_build_docx_con_toma_muestra_fila(): + import tempfile + tmp = tempfile.mkdtemp() + try: + path = pg._build_docx(_params(), _result(95000.0), tmp, toma_valor=30000.0) + txt = _texto_tablas_docx(path).upper() + finally: + __import__("shutil").rmtree(tmp, ignore_errors=True) + assert "TOMA A CUENTA" in txt + assert "30,000.00" in txt + + +def test_build_docx_sin_toma_oculta_fila(): + import tempfile + tmp = tempfile.mkdtemp() + try: + path = pg._build_docx(_params(), _result(125000.0), tmp, toma_valor=0.0) + txt = _texto_tablas_docx(path).upper() + finally: + __import__("shutil").rmtree(tmp, ignore_errors=True) + assert "TOMA A CUENTA" not in txt # la fila se auto-elimina sin toma + + # ── Fase 1: handlers conversacionales ──────────────────────────── def _msg(texto):