diff --git a/pos/static/js/pos.js b/pos/static/js/pos.js index e22cac4..905df87 100644 --- a/pos/static/js/pos.js +++ b/pos/static/js/pos.js @@ -162,6 +162,78 @@ const POS = (() => { } } + // ─── Cut X / Z (Close Register) ────── + function showCutZModal() { + document.getElementById('cutZModal').classList.add('open'); + document.getElementById('cutZResult').innerHTML = ''; + loadCutX(); + } + function closeCutZModal() { + document.getElementById('cutZModal').classList.remove('open'); + document.getElementById('cutZResult').innerHTML = ''; + } + async function loadCutX() { + const el = document.getElementById('cutZSummary'); + try { + const data = await api('/pos/api/register/cut-x'); + if (data.error) { + el.innerHTML = '
' + data.error + '
'; + return; + } + let html = 'Error cargando resumen
'; + } + } + async function confirmCutZ() { + const amount = parseFloat(document.getElementById('cutZClosingAmount').value) || 0; + try { + const data = await api('/pos/api/register/cut-z', { + method: 'POST', + body: JSON.stringify({ closing_amount: amount }) + }); + if (data.error) { + document.getElementById('cutZResult').innerHTML = '' + data.error + ''; + return; + } + const diffColor = data.difference > 0 ? 'var(--color-success)' : (data.difference < 0 ? 'var(--color-error)' : 'var(--color-text-muted)'); + document.getElementById('cutZResult').innerHTML = 'Caja cerrada correctamente'; + document.getElementById('registerInfo').innerHTML = 'Sin caja abierta'; + currentRegister = null; + closeCutZModal(); + showToast('Corte Z completado. Diferencia: $' + data.difference.toFixed(2)); + } catch (e) { + document.getElementById('cutZResult').innerHTML = 'Error de red'; + } + } + // ─── Cart ──────────────────────────── function addToCart(item) { const existing = cart.find(c => c.inventory_id === item.inventory_id); @@ -1195,5 +1267,6 @@ const POS = (() => { showTicket, closeTicketModal, printTicket, connectThermal, thermalPrint, showOpenRegisterModal, closeOpenRegisterModal, openRegister, + showCutZModal, closeCutZModal, loadCutX, confirmCutZ, }; })(); diff --git a/pos/templates/pos.html b/pos/templates/pos.html index ac40483..b3f573b 100644 --- a/pos/templates/pos.html +++ b/pos/templates/pos.html @@ -14,7 +14,7 @@ - + @@ -202,6 +202,7 @@