diff --git a/app/routes/automation.py b/app/routes/automation.py index 054eef9..941b337 100644 --- a/app/routes/automation.py +++ b/app/routes/automation.py @@ -454,25 +454,15 @@ async def preview_automation( if rda_por_pac.get(str(p.get("CODIGO", ""))) ] - grupos_vta_all = agrupar_por_factura(rows_vta) - ventas_debug = [] grupos_vta = {} - for k, v in grupos_vta_all.items(): + for k, v in agrupar_por_factura(rows_vta).items(): if not isinstance(v, list) or not v: continue - num_fac_val = int(v[0].get("NUM_FACTURA") or 0) - contrato_val = str(v[0].get("CODCONTRATO") or "").strip() - prefijo_val = str(v[0].get("PREFIJO") or "").strip() - motivo = None - if num_fac_val == 0: - motivo = "sin_factura" - elif contrato_val in excluded_ventas: - motivo = f"excluido_ventas ({contrato_val})" - if motivo: - ventas_debug.append({"key": k, "prefijo": prefijo_val, "num_factura": num_fac_val, - "contrato": contrato_val, "motivo": motivo}) - else: - grupos_vta[k] = v + if int(v[0].get("NUM_FACTURA") or 0) == 0: + continue + if str(v[0].get("CODCONTRATO") or "").strip() in excluded_ventas: + continue + grupos_vta[k] = v ventas_preview = [] ventas_gen_errors = [] @@ -505,9 +495,6 @@ async def preview_automation( "excluidos": excluidos_count, "preservicios": len(grupos_ps), "ventas": len(grupos_vta), - "ventas_raw": len(rows_vta or []), - "ventas_grupos_total": len(grupos_vta_all), - "ventas_filtradas": ventas_debug, "ventas_gen_errors": ventas_gen_errors, "pacientes_preview": pacientes_preview, "preservicios_preview": preservicios_preview,