Actualizar backend/main.py

This commit is contained in:
2026-10-05 17:11:35 -05:00
parent 4b5bbfabaa
commit 1d2bd45a70

View File

@@ -173,9 +173,10 @@ def get_cobranza(
sede_filtro: str = Query("TODOS"), sede_filtro: str = Query("TODOS"),
prog_filtro: str = Query("TODOS"), prog_filtro: str = Query("TODOS"),
venc_hasta: str = Query("TODOS"), venc_hasta: str = Query("TODOS"),
frec_filtro: str = Query("TODOS"),
): ):
try: try:
return services.cobranza(ano, mes, sectorista, agrupacion, sede_filtro, prog_filtro, venc_hasta) return services.cobranza(ano, mes, sectorista, agrupacion, sede_filtro, prog_filtro, venc_hasta, frec_filtro)
except Exception as e: except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
@@ -190,9 +191,10 @@ def get_cobranza_detalle(
prog_filtro: str = Query("TODOS"), prog_filtro: str = Query("TODOS"),
sede_filtro: str = Query("TODOS"), sede_filtro: str = Query("TODOS"),
venc_hasta: str = Query("TODOS"), venc_hasta: str = Query("TODOS"),
frec_filtro: str = Query("TODOS"),
): ):
try: try:
return services.cobranza_detalle(grupo, ano, mes, sectorista, agrupacion, prog_filtro, sede_filtro, venc_hasta) return services.cobranza_detalle(grupo, ano, mes, sectorista, agrupacion, prog_filtro, sede_filtro, venc_hasta, frec_filtro)
except Exception as e: except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
@@ -548,6 +550,42 @@ def post_comisiones_config(payload: dict = Body(...)):
except Exception as e: except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
@app.get("/api/facturas/buscar")
def get_facturas_buscar(ano: int = Query(...), mes: int = Query(0)):
try:
return services.facturas_buscar(ano, mes)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/api/comisiones/metas")
def get_comisiones_metas(ano: int = Query(...), mes: int = Query(...)):
try:
return services.comisiones_metas_listar(ano, mes)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.post("/api/comisiones/metas/guardar")
def post_comisiones_metas(payload: dict = Body(...)):
try:
return services.comisiones_metas_guardar(payload.get("ano"), payload.get("mes"), payload.get("filas", []))
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/api/comisiones/export")
def get_comisiones_export(ano: int = Query(...), mes: int = Query(...)):
from fastapi.responses import StreamingResponse
from io import BytesIO
try:
data = services.comisiones_export_excel(ano, mes)
headers = {"Content-Disposition": f"attachment; filename=comisiones_{ano}_{mes}.xlsx"}
return StreamingResponse(BytesIO(data),
media_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
headers=headers)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
# ── ASESORES (Chatwoot) ──────────────────────────────────────────────────── # ── ASESORES (Chatwoot) ────────────────────────────────────────────────────
CHATWOOT_URL = "https://gestor.escueladerefrigeracion.edu.pe" CHATWOOT_URL = "https://gestor.escueladerefrigeracion.edu.pe"