From 35cba080042169ff5f3b22cdbdecaa6312dc8d8f Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 16 Jul 2026 20:27:18 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20precios=20particulares=20autom=C3=A1tic?= =?UTF-8?q?os=20al=20seleccionar=20ex=C3=A1menes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sin empresa: usa precio_base de exam_tipos (tarifa particular) - Panel de precios se muestra con solo seleccionar exámenes (no requiere convenio) - Total se aplica automáticamente al campo de cobro sin clic manual Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/get_precios_examenes.php | 11 +++++++++-- modules/turnero/views/recepcion.php | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/turnero/api/get_precios_examenes.php b/modules/turnero/api/get_precios_examenes.php index 2eaf4fb..62d1675 100644 --- a/modules/turnero/api/get_precios_examenes.php +++ b/modules/turnero/api/get_precios_examenes.php @@ -75,10 +75,10 @@ if ($nitEmpresa !== '') { } } -// ── Obtener nombre/codigo de los exámenes ───────────────────── +// ── Obtener nombre/codigo/precio_base de los exámenes ──────── $ph = implode(',', array_fill(0, count($examIds), '?')); $stmtX = $pdo->prepare( - "SELECT id AS exam_tipo_id, codigo, nombre FROM exam_tipos WHERE id IN ($ph)" + "SELECT id AS exam_tipo_id, codigo, nombre, precio_base FROM exam_tipos WHERE id IN ($ph)" ); $stmtX->execute($examIds); $examMap = []; @@ -121,6 +121,13 @@ foreach ($examIds as $examId) { } } + // Sin tarifa de empresa: usar precio_base (particular) + if (!$tienePrecio && $examen['precio_base'] !== null && (float)$examen['precio_base'] > 0) { + $tienePrecio = true; + $valorBase = (float)$examen['precio_base']; + $valorFinal = $valorBase; + } + // Si no hay precio, dejar null (sin tarifa o sin mapeo) $subtotal += $valorFinal ?? 0; diff --git a/modules/turnero/views/recepcion.php b/modules/turnero/views/recepcion.php index c5eb0af..a3515a6 100644 --- a/modules/turnero/views/recepcion.php +++ b/modules/turnero/views/recepcion.php @@ -2251,7 +2251,7 @@ async function _doRecalcular() { const nit = document.getElementById('inp-empresa-nit').value.trim(); const subId = document.getElementById('sel-subgrupo').value; - if (!examIds.length || !nit) { + if (!examIds.length) { document.getElementById('panel-precios').classList.add('d-none'); return; } @@ -2296,6 +2296,12 @@ async function _doRecalcular() { } document.getElementById('panel-precios').classList.remove('d-none'); + + // Auto-aplicar total al campo de cobro + const totalFinal = j.total || j.subtotal || 0; + if (totalFinal > 0) { + document.getElementById('inp-total').value = Math.round(totalFinal); + } } function aplicarPrecioCalculado() {