fix: set valor=0 in detallePedido; parse full factura (prefix+number) in search

- 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 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-01 11:54:08 -05:00
co-authored by Claude Sonnet 4.6
parent 4b77f0a0ac
commit 1548aadf3c
3 changed files with 14 additions and 3 deletions
+10 -2
View File
@@ -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)}