From 1548aadf3cf8667fed15e4ea4796ef22705f55c3 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 1 Jul 2026 11:53:09 -0500 Subject: [PATCH] fix: set valor=0 in detallePedido; parse full factura (prefix+number) in search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - json_generator: send valor:0 per item instead of PRECIO from Firebird - test_rda + transaccion: accept "LHXC03726" format — extracts numeric part for NUM_FACTURA and letter prefix for PREFIJO filter when prefix present Co-Authored-By: Claude Sonnet 4.6 --- app/routes/test_rda.py | 12 ++++++++++-- app/routes/transaccion.py | 3 +++ app/services/json_generator.py | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/routes/test_rda.py b/app/routes/test_rda.py index 5914086..c481f1b 100644 --- a/app/routes/test_rda.py +++ b/app/routes/test_rda.py @@ -222,8 +222,16 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)): return JSONResponse({"error": f"Error Firebird: {fb_msg}"}) if modo == "factura": - where = "r.NUM_FACTURA = :val" - params = {"val": int(valor)} + import re as _re + nums = _re.findall(r'\d+', valor) + num_val = int(nums[-1]) if nums else 0 + prefix = _re.sub(r'[\d\s]', '', valor).strip().upper() + if prefix: + where = "r.NUM_FACTURA = :val AND TRIM(r.PREFIJO) = :prefijo" + params = {"val": num_val, "prefijo": prefix} + else: + where = "r.NUM_FACTURA = :val" + params = {"val": num_val} else: where = "r.IDRECEPCION = :val" params = {"val": int(valor)} diff --git a/app/routes/transaccion.py b/app/routes/transaccion.py index eb25fa9..1a1aff7 100644 --- a/app/routes/transaccion.py +++ b/app/routes/transaccion.py @@ -26,9 +26,12 @@ def _query_rows(cfg, query_text, factura, fecha_inicio, fecha_fin): return None, msg, None nums = _re.findall(r'\d+', factura or "") num_val = int(nums[-1]) if nums else (factura or "") + prefix = _re.sub(r'[\d\s]', '', factura or "").strip().upper() params = {"fecha_ini": f"{fecha_inicio} 00:00:00", "fecha_fin": f"{fecha_fin} 23:59:59"} if ":num_factura" in query_text: params["num_factura"] = num_val + if ":prefijo" in query_text: + params["prefijo"] = prefix ok2, err, rows = fb.execute_query(query_text, params) fb.disconnect() if not ok2: diff --git a/app/services/json_generator.py b/app/services/json_generator.py index 9354d5c..efd9f4b 100644 --- a/app/services/json_generator.py +++ b/app/services/json_generator.py @@ -153,7 +153,7 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe "codigoBodega": "00", "cantidad": 1, "tipoUnidad": "D", - "valor": float(row.get("PRECIO") or 0), + "valor": 0, "descuento": float(row.get("DESCUENTO") or 0), "porcentajeIva": 0, "impConsumo": 0,