feat: precios particulares automáticos al seleccionar exámenes
- 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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fa338e9e11
commit
35cba08004
@@ -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), '?'));
|
$ph = implode(',', array_fill(0, count($examIds), '?'));
|
||||||
$stmtX = $pdo->prepare(
|
$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);
|
$stmtX->execute($examIds);
|
||||||
$examMap = [];
|
$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)
|
// Si no hay precio, dejar null (sin tarifa o sin mapeo)
|
||||||
$subtotal += $valorFinal ?? 0;
|
$subtotal += $valorFinal ?? 0;
|
||||||
|
|
||||||
|
|||||||
@@ -2251,7 +2251,7 @@ async function _doRecalcular() {
|
|||||||
const nit = document.getElementById('inp-empresa-nit').value.trim();
|
const nit = document.getElementById('inp-empresa-nit').value.trim();
|
||||||
const subId = document.getElementById('sel-subgrupo').value;
|
const subId = document.getElementById('sel-subgrupo').value;
|
||||||
|
|
||||||
if (!examIds.length || !nit) {
|
if (!examIds.length) {
|
||||||
document.getElementById('panel-precios').classList.add('d-none');
|
document.getElementById('panel-precios').classList.add('d-none');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2296,6 +2296,12 @@ async function _doRecalcular() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('panel-precios').classList.remove('d-none');
|
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() {
|
function aplicarPrecioCalculado() {
|
||||||
|
|||||||
Reference in New Issue
Block a user