feat(cotizador): agrega el renglón $TOMA$ a la plantilla (Camino B)
Inserta el par de párrafos 'TOMA A CUENTA' / $TOMA$ justo después de RENTA ANTICIPADA (antes de VALOR RESIDUAL TOTAL) dentro de la fila de montos, clonando el par de RENTA ANTICIPADA para heredar formato/fuente/alineación. No es una fila <w:tr> nueva: son párrafos apilados en las celdas etiqueta/valor, alineados por índice, igual que los VR por año. Con toma → 'TOMA A CUENTA - $X' entre RENTA ANTICIPADA y VR TOTAL. Sin toma → $TOMA$='' → el mecanismo de párrafos vacíos auto-elimina la fila, sin dejar hueco. Verificado con PDF real (soffice) en ambos casos. pdf_generator ya llenaba $TOMA$ (línea 135); esto solo agrega el renglón visual. NO toca calculator.py. 78 tests (backup local en Plantilla_WK2.docm.bak). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3da1e2da26
commit
ddb926e5d1
2 files changed
+41
No files matched your search
Binary file not shown.
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user