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() {