Propagate sin_contrato_set to transaccion and test-rda routes

All generar_rda_paciente calls in transaccion.py (4) and test_rda.py (2)
now pass sin_contrato_set so contract 040 sends numeroContrato: null
consistently across all send paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-11 09:22:00 -05:00
co-authored by Claude Sonnet 4.6
parent c18da17317
commit 3d848fbf2d
2 changed files with 9 additions and 5 deletions
+4 -3
View File
@@ -13,7 +13,7 @@ from app.services.json_generator import (
agrupar_por_recepcion,
)
from app.services.api_client import get_tns_token, TNS_BASE
from app.routes.contratos import load_contrato_map, load_excluded_set
from app.routes.contratos import load_contrato_map, load_excluded_set, load_sin_contrato_set
router = APIRouter(prefix="/test-rda", tags=["test-rda"])
@@ -208,7 +208,8 @@ async def preview_rda(request: Request, user: dict = Depends(get_current_user),
cod_c = str(grupo[0].get("CODCONTRATO") or "").strip()
excluido = cod_c in load_excluded_set()
rda_json = generar_rda_paciente(grupo, prof_def, esp_def, remis_def, prefijo_def,
contrato_map=load_contrato_map())
contrato_map=load_contrato_map(),
sin_contrato_set=load_sin_contrato_set())
return JSONResponse({"json": rda_json, "excluido": excluido, "contrato": cod_c})
@@ -323,7 +324,7 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)):
num_factura = str(grupo_rows[0].get("NUM_FACTURA") or "").strip()
numero_override = num_factura
rda_json = generar_rda_paciente(grupo_rows, prof_def, esp_def, remis_def, prefijo_def, numero_override,
contrato_map=contrato_map)
contrato_map=contrato_map, sin_contrato_set=load_sin_contrato_set())
examenes = [r.get("COD_EXAMEN", "") for r in grupo_rows]
try:
r = await client.post(endpoint_rda, json=rda_json, headers=headers)
+5 -2
View File
@@ -8,7 +8,7 @@ from app.auth import get_current_user
from app.services.firebird_service import get_firebird_from_config
from app.services.json_generator import generar_rda_paciente, agrupar_por_recepcion
from app.services.api_client import get_tns_token, TNS_BASE
from app.routes.contratos import load_contrato_map, load_excluded_set
from app.routes.contratos import load_contrato_map, load_excluded_set, load_sin_contrato_set
from app.utils.activity import log_activity, get_ip
router = APIRouter(prefix="/transaccion", tags=["transaccion"])
@@ -106,7 +106,7 @@ async def preview_transaccion(
enviado = _is_sent(id_rec)
cod_c = str(grupo_rows[0].get("CODCONTRATO") or "").strip()
is_excluded = cod_c in excluded
rda = generar_rda_paciente(grupo_rows, prof_def, esp_def, remis_def, prefijo_def, contrato_map=contrato_map)
rda = generar_rda_paciente(grupo_rows, prof_def, esp_def, remis_def, prefijo_def, contrato_map=contrato_map, sin_contrato_set=load_sin_contrato_set())
items.append({
"idrecepcion": id_rec,
"factura": grupo_rows[0].get("NUM_FACTURA", ""),
@@ -180,6 +180,7 @@ async def send_one(
cfg.get("prefijo_tns_default", "00"),
numero_override_one,
contrato_map=load_contrato_map(),
sin_contrato_set=load_sin_contrato_set(),
)
raw_resp = ""
@@ -283,6 +284,7 @@ async def send_transaccion(
cfg.get("prefijo_tns_default", "00"),
numero_override,
contrato_map=contrato_map,
sin_contrato_set=load_sin_contrato_set(),
)
raw_resp = ""
ok_rda = False
@@ -394,6 +396,7 @@ async def send_direct(
cfg.get("prefijo_tns_default", "00"),
num_fac,
contrato_map=contrato_map,
sin_contrato_set=load_sin_contrato_set(),
)
raw_resp = ""
ok_rda = False