debug: endpoint temporal /automation/debug-cmxc para diagnosticar recepciones CMXC
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
648a0a1910
commit
3aa07543db
@@ -145,6 +145,31 @@ async def automation_page(request: Request, user: dict = Depends(get_current_use
|
||||
})
|
||||
|
||||
|
||||
@router.get("/debug-cmxc")
|
||||
async def debug_cmxc(request: Request, user: dict = Depends(get_current_user), fecha: str = ""):
|
||||
"""Diagnóstico temporal: muestra recepciones CMXC para una fecha."""
|
||||
conn = get_connection()
|
||||
configs = {row["key"]: row["value"] for row in conn.execute("SELECT * FROM config").fetchall()}
|
||||
conn.close()
|
||||
fb, fb_ok, fb_msg = get_firebird_from_config(configs)
|
||||
if not fb_ok:
|
||||
return JSONResponse({"error": fb_msg})
|
||||
if not fecha:
|
||||
fecha = date.today().isoformat()
|
||||
ok, err, rows = fb.execute_query("""
|
||||
SELECT r.IDRECEPCION, r.PREFIJO, r.NUM_FACTURA, r.PS_NUM,
|
||||
r.NIT_EMPRESA, r.VALORTOTAL, r.FECHA_RECEPCION
|
||||
FROM RECEPCION r
|
||||
WHERE r.FECHA_RECEPCION BETWEEN ? AND ?
|
||||
AND r.PREFIJO = 'CMXC'
|
||||
ORDER BY r.IDRECEPCION
|
||||
""", {"fecha_ini": f"{fecha} 00:00:00", "fecha_fin": f"{fecha} 23:59:59"})
|
||||
fb.disconnect()
|
||||
if not ok:
|
||||
return JSONResponse({"error": err})
|
||||
return JSONResponse({"fecha": fecha, "total": len(rows), "rows": rows})
|
||||
|
||||
|
||||
def _build_sql(contrato: str):
|
||||
if contrato:
|
||||
fp = "AND e.CODCONTRATO = :contrato"
|
||||
|
||||
Reference in New Issue
Block a user