diff --git a/app/routes/automation.py b/app/routes/automation.py index 4ee4c3d..8951468 100644 --- a/app/routes/automation.py +++ b/app/routes/automation.py @@ -452,7 +452,8 @@ async def preview_automation( grupos_vta_all = agrupar_por_recepcion(rows_vta) grupos_vta = {k: v for k, v in grupos_vta_all.items() - if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas} + if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas + and int(v[0].get("NUM_FACTURA") or 0) != 0} ventas_preview = [] for id_rec, grupo_rows in grupos_vta.items(): @@ -704,7 +705,8 @@ async def run_automation( excluded_ventas = load_excluded_ventas_set() grupos_vta_all = agrupar_por_recepcion(rows_vta) grupos_vta = {k: v for k, v in grupos_vta_all.items() - if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas} + if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas + and int(v[0].get("NUM_FACTURA") or 0) != 0} resultado["paso4_ventas"]["excluidos"] = len(grupos_vta_all) - len(grupos_vta) endpoint_venta = f"{TNS_BASE}/v2/facturacion/Ventas/Crear" @@ -930,6 +932,8 @@ async def reenviar_venta( contrato_vta = str(rows[0].get("CODCONTRATO") or "").strip() if contrato_vta in excluded_ventas: return JSONResponse({"success": False, "message": f"Contrato {contrato_vta} excluido"}) + if int(rows[0].get("NUM_FACTURA") or 0) == 0: + return JSONResponse({"success": False, "message": "Factura sin nĂºmero asignado (00000)"}) from collections import defaultdict grupos: dict = defaultdict(list)