feat(turnero): pago combinado con desglose por efectivo, transferencia y tarjeta
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4626ca3f28
commit
76dda4722a
@@ -501,16 +501,32 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
placeholder="Total $" step="100" min="0">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<select id="sel-pago" class="form-select form-select-sm">
|
||||
<select id="sel-pago" class="form-select form-select-sm" onchange="togglePagoCombinado()">
|
||||
<option value="">— Forma de pago —</option>
|
||||
<option value="efectivo">Efectivo</option>
|
||||
<option value="transferencia">Transferencia</option>
|
||||
<option value="tarjeta">Tarjeta</option>
|
||||
<option value="eps">EPS / Convenio</option>
|
||||
<option value="cortesia">Cortesía</option>
|
||||
<option value="combinado">Pago combinado</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Panel pago combinado -->
|
||||
<div id="panel-combinado" class="d-none mt-2 p-2 border rounded" style="background:#f8fafc">
|
||||
<div class="row g-2 align-items-center mb-1">
|
||||
<div class="col-5"><label class="form-label mb-0 small fw-semibold"><i class="fas fa-money-bill-wave me-1 text-success"></i>Efectivo</label></div>
|
||||
<div class="col-7"><input type="number" id="comb-efectivo" class="form-control form-control-sm" placeholder="$0" min="0" step="100" oninput="sumarCombinado()"></div>
|
||||
</div>
|
||||
<div class="row g-2 align-items-center mb-1">
|
||||
<div class="col-5"><label class="form-label mb-0 small fw-semibold"><i class="fas fa-university me-1 text-primary"></i>Transferencia</label></div>
|
||||
<div class="col-7"><input type="number" id="comb-transferencia" class="form-control form-control-sm" placeholder="$0" min="0" step="100" oninput="sumarCombinado()"></div>
|
||||
</div>
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-5"><label class="form-label mb-0 small fw-semibold"><i class="fas fa-credit-card me-1 text-warning"></i>Tarjeta</label></div>
|
||||
<div class="col-7"><input type="number" id="comb-tarjeta" class="form-control form-control-sm" placeholder="$0" min="0" step="100" oninput="sumarCombinado()"></div>
|
||||
</div>
|
||||
</div>
|
||||
<textarea id="inp-obs" class="form-control form-control-sm mt-2"
|
||||
rows="2" placeholder="Observaciones…" maxlength="500"></textarea>
|
||||
</div>
|
||||
@@ -1120,6 +1136,27 @@ function seleccionarPaciente(pac) {
|
||||
_historialPacienteId = pac.id;
|
||||
}
|
||||
|
||||
function togglePagoCombinado() {
|
||||
const combinado = document.getElementById('sel-pago').value === 'combinado';
|
||||
document.getElementById('panel-combinado').classList.toggle('d-none', !combinado);
|
||||
const inp = document.getElementById('inp-total');
|
||||
inp.readOnly = combinado;
|
||||
inp.style.background = combinado ? '#e9ecef' : '';
|
||||
if (combinado) sumarCombinado();
|
||||
}
|
||||
function sumarCombinado() {
|
||||
const v = id => parseFloat(document.getElementById(id).value) || 0;
|
||||
const total = v('comb-efectivo') + v('comb-transferencia') + v('comb-tarjeta');
|
||||
document.getElementById('inp-total').value = total || '';
|
||||
}
|
||||
function resetPagoCombinado() {
|
||||
['comb-efectivo','comb-transferencia','comb-tarjeta'].forEach(id => document.getElementById(id).value = '');
|
||||
document.getElementById('panel-combinado').classList.add('d-none');
|
||||
const inp = document.getElementById('inp-total');
|
||||
inp.readOnly = false;
|
||||
inp.style.background = '';
|
||||
}
|
||||
|
||||
function desvincularPaciente() {
|
||||
pacienteActivo = null;
|
||||
_historialPacienteId = null;
|
||||
@@ -1264,8 +1301,13 @@ async function guardarSolicitud() {
|
||||
lugar_id: lugarId,
|
||||
exam_tipo_ids: examIds,
|
||||
numero_orden: document.getElementById('inp-consecutivo').value.trim() || null,
|
||||
total_cobrado: parseFloat(document.getElementById('inp-total').value) || null,
|
||||
metodo_pago: document.getElementById('sel-pago').value || null,
|
||||
total_cobrado: parseFloat(document.getElementById('inp-total').value) || null,
|
||||
metodo_pago: document.getElementById('sel-pago').value || null,
|
||||
pagos_detalle: document.getElementById('sel-pago').value === 'combinado' ? {
|
||||
efectivo: parseFloat(document.getElementById('comb-efectivo').value) || 0,
|
||||
transferencia: parseFloat(document.getElementById('comb-transferencia').value) || 0,
|
||||
tarjeta: parseFloat(document.getElementById('comb-tarjeta').value) || 0,
|
||||
} : null,
|
||||
observaciones: document.getElementById('inp-obs').value.trim() || null,
|
||||
embarazada: document.getElementById('chk-embarazada').checked ? 1 : 0,
|
||||
}),
|
||||
@@ -1612,6 +1654,10 @@ async function soltarTurno() {
|
||||
// ── Helpers ───────────────────────────────────────────────────
|
||||
function resetCheckboxes() {
|
||||
document.querySelectorAll('.exam-chk').forEach(c => c.checked = false);
|
||||
document.getElementById('sel-pago').value = '';
|
||||
document.getElementById('inp-total').value = '';
|
||||
document.getElementById('inp-obs').value = '';
|
||||
resetPagoCombinado();
|
||||
}
|
||||
function toggleTodosExamenes(val) {
|
||||
document.querySelectorAll('.exam-chk').forEach(c => c.checked = val);
|
||||
|
||||
Reference in New Issue
Block a user