From 15f6ca65dba5ddd4f1e566ebd0ae816d3da7e4e5 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 1 Jul 2026 17:13:46 -0500 Subject: [PATCH] feat: add descuento from RECEPCION.VALORDESC to RDA header Pulls r.VALORDESC in all SQL queries (automation, test_rda, queries defaults) and maps it to the top-level descuento field in the RdaPaciente JSON encabezado. Co-Authored-By: Claude Sonnet 4.6 --- app/routes/automation.py | 1 + app/routes/queries.py | 2 ++ app/routes/test_rda.py | 2 +- app/services/json_generator.py | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/routes/automation.py b/app/routes/automation.py index 8790531..512e856 100644 --- a/app/routes/automation.py +++ b/app/routes/automation.py @@ -58,6 +58,7 @@ SELECT r.CLASEPROC, r.HORAINICIORECEPCION, r.VALORTOTAL, + r.VALORDESC, rel.COD_EXAMEN, COALESCE(NULLIF(TRIM(ex.NUM_ISS), ''), TRIM(rel.COD_EXAMEN)) AS CUPS, rel.PRECIO, diff --git a/app/routes/queries.py b/app/routes/queries.py index d2992ec..0f24da1 100644 --- a/app/routes/queries.py +++ b/app/routes/queries.py @@ -47,6 +47,7 @@ WHERE p.DOCIDENT = :doc_num""", r.CLASEPROC, r.HORAINICIORECEPCION, r.VALORTOTAL, + r.VALORDESC, rel.COD_EXAMEN, COALESCE(NULLIF(TRIM(ex.NUM_ISS), ''), TRIM(rel.COD_EXAMEN)) AS CUPS, rel.PRECIO, @@ -80,6 +81,7 @@ WHERE r.NUM_FACTURA = :num_factura""", r.CLASEPROC, r.HORAINICIORECEPCION, r.VALORTOTAL, + r.VALORDESC, rel.COD_EXAMEN, COALESCE(NULLIF(TRIM(ex.NUM_ISS), ''), TRIM(rel.COD_EXAMEN)) AS CUPS, rel.PRECIO, diff --git a/app/routes/test_rda.py b/app/routes/test_rda.py index 64e10c1..0c360b8 100644 --- a/app/routes/test_rda.py +++ b/app/routes/test_rda.py @@ -20,7 +20,7 @@ _SQL_RDA_BY_WHERE = """ SELECT r.IDRECEPCION, r.PREFIJO, r.NUM_FACTURA, r.FECHA_RECEPCION, r.COD_PACIENTE, r.NIT_EMPRESA, r.DIAG_PPAL, r.TIPOUSU, r.TIPOUSUSISPRO, r.AUTORIZACION, r.CLASEPROC, - r.HORAINICIORECEPCION, r.VALORTOTAL, rel.COD_EXAMEN, + r.HORAINICIORECEPCION, r.VALORTOTAL, r.VALORDESC, rel.COD_EXAMEN, COALESCE(NULLIF(TRIM(ex.NUM_ISS), ''), TRIM(rel.COD_EXAMEN)) AS CUPS, rel.PRECIO, rel.FECHA_REPORTADO, m.COD_ESPECIALIDAD, diff --git a/app/services/json_generator.py b/app/services/json_generator.py index 93fb0c9..cef5989 100644 --- a/app/services/json_generator.py +++ b/app/services/json_generator.py @@ -220,6 +220,7 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe "numeroAutorizacion": autorizacion, "fechaAutorizacion": date.today().strftime("%d/%m/%Y"), "vigenciaAutorizacion": vigencia, + "descuento": int(float(h.get("VALORDESC") or 0)), "detallePedido": detalle_pedido, "detalleFormaPago": [{ "codigoFormaPago": cod_forma_pago,