+
¡Listo!
+
+
+
+
Detalle del pedido
+
+
+
+ Total
+
+
+
+
+
OK
@@ -153,6 +188,22 @@
¡Listo!
return btn.dataset.payLabel || PAY_LABELS[btn.dataset.pay] || btn.dataset.pay;
}
+ function toggleCajaTotalsPanel(hidden) {
+ const panel = document.getElementById('caja-totals-panel');
+ if (!panel) return;
+ panel.style.display = hidden ? 'none' : '';
+ }
+
+ function toggleSiteHeader(hidden) {
+ document.querySelectorAll('header.container-xxl').forEach((siteHeader) => {
+ if (hidden) {
+ siteHeader.style.setProperty('display', 'none', 'important');
+ } else {
+ siteHeader.style.removeProperty('display');
+ }
+ });
+ }
+
function getLines() {
const lines = [];
document.querySelectorAll('.qty-input').forEach(input => {
@@ -174,18 +225,43 @@
¡Listo!
}
function clampQty(input, delta) {
- const min = parseInt(input.min) || 0;
- const max = parseInt(input.max) || 9999;
- const next = Math.min(max, Math.max(min, (parseInt(input.value) || 0) + delta));
+ const parsedMin = parseInt(input.min, 10);
+ const parsedMax = parseInt(input.max, 10);
+ const min = Number.isNaN(parsedMin) ? 0 : parsedMin;
+ const max = Number.isNaN(parsedMax) ? 9999 : parsedMax;
+ const current = parseInt(input.value) || 0;
+ if (delta > 0 && current >= max) {
+ return;
+ }
+ const next = Math.min(max, Math.max(min, current + delta));
input.value = next;
updateTotal();
+ updateStepperButtons(input);
+ }
+
+ function updateStepperButtons(input) {
+ const stepper = input.closest('.qty-stepper');
+ if (!stepper) return;
+ const minusBtn = stepper.querySelector('.qty-minus');
+ const plusBtn = stepper.querySelector('.qty-plus');
+ const value = parseInt(input.value) || 0;
+ const parsedMin = parseInt(input.min, 10);
+ const parsedMax = parseInt(input.max, 10);
+ const min = Number.isNaN(parsedMin) ? 0 : parsedMin;
+ const max = Number.isNaN(parsedMax) ? 9999 : parsedMax;
+ if (minusBtn) minusBtn.disabled = value <= min;
+ if (plusBtn) plusBtn.disabled = value >= max;
}
document.querySelectorAll('.qty-stepper').forEach(stepper => {
const input = stepper.querySelector('.qty-input');
stepper.querySelector('.qty-minus').addEventListener('click', () => clampQty(input, -1));
stepper.querySelector('.qty-plus').addEventListener('click', () => clampQty(input, 1));
- input.addEventListener('input', updateTotal);
+ input.addEventListener('input', function() {
+ updateTotal();
+ updateStepperButtons(input);
+ });
+ updateStepperButtons(input);
});
async function postJson(url, body) {
@@ -226,6 +302,7 @@
¡Listo!
}
function hideAllScreens() {
+ toggleSiteHeader(true);
document.getElementById('caja-header').style.display = 'none';
document.getElementById('cart-section').style.display = 'none';
document.getElementById('mp-qr-section').style.display = 'none';
@@ -241,6 +318,11 @@
¡Listo!
document.getElementById('mp-qr-loading').style.display = 'none';
document.getElementById('mp-qr-waiting').style.display = 'none';
document.getElementById('mp-qr-loading-text').textContent = 'Generando QR...';
+ const qrCancelBtn = document.getElementById('mp-qr-cancel');
+ if (qrCancelBtn) {
+ qrCancelBtn.disabled = false;
+ qrCancelBtn.innerHTML = 'Cancelar';
+ }
}
function resetToCaja() {
@@ -251,12 +333,17 @@
¡Listo!
statusUrl = null;
cancelUrl = null;
setPayProcessing(false);
+ toggleSiteHeader(false);
resetMpQrUi();
+ toggleCajaTotalsPanel(true);
document.getElementById('point-section').style.display = 'none';
document.getElementById('success-section').style.display = 'none';
document.getElementById('caja-header').style.display = '';
document.getElementById('cart-section').style.display = '';
- document.querySelectorAll('.qty-input').forEach(i => { i.value = '0'; });
+ document.querySelectorAll('.qty-input').forEach(i => {
+ i.value = '0';
+ updateStepperButtons(i);
+ });
const email = document.getElementById('customer-email');
if (email) email.value = '';
const markUsed = document.getElementById('mark-as-used');
@@ -299,8 +386,9 @@
¡Listo!
function showMpQrScreen(totalLabel) {
setPayProcessing(false);
+ toggleCajaTotalsPanel(true);
hideAllScreens();
- document.getElementById('mp-qr-section').style.display = 'block';
+ document.getElementById('mp-qr-section').style.display = 'flex';
document.getElementById('mp-qr-total').textContent = totalLabel;
document.getElementById('mp-qr-container').innerHTML = '';
setMpQrLoading(true, 'Generando QR...');
@@ -324,27 +412,54 @@
¡Listo!
});
}
- function showSuccess(totalAmount) {
+ function formatMoney(value) {
+ const numeric = parseFloat(value || 0);
+ return '$' + numeric.toLocaleString('es-AR');
+ }
+
+ function getSelectedLineDetails() {
+ const lines = [];
+ document.querySelectorAll('.qty-input').forEach(input => {
+ const qty = parseInt(input.value) || 0;
+ if (qty <= 0) return;
+ lines.push({
+ name: input.dataset.name,
+ quantity: qty,
+ unitPrice: parseFloat(input.dataset.price || 0),
+ });
+ });
+ return lines;
+ }
+
+ function updateCajaTotalsCard(cajaTotals) {
+ if (!cajaTotals) return;
+ const cashEl = document.getElementById('caja-total-cash');
+ const mpEl = document.getElementById('caja-total-mp');
+ if (cashEl) cashEl.textContent = formatMoney(cajaTotals.cash_total);
+ if (mpEl) mpEl.textContent = formatMoney(cajaTotals.mp_total);
+ }
+
+ function showSuccess(totalAmount, cajaTotals) {
clearTimeout(pollTimer);
setPayProcessing(false);
hideAllScreens();
- const formatted = parseFloat(totalAmount).toLocaleString('es-AR');
+ const formatted = formatMoney(totalAmount);
+ const lineDetails = getSelectedLineDetails();
+ toggleCajaTotalsPanel(false);
document.getElementById('success-message').textContent =
- 'Pago confirmado por $' + formatted;
- document.getElementById('success-section').style.display = 'block';
-
- let secondsLeft = 5;
- const countdownEl = document.getElementById('success-countdown');
- function tickCountdown() {
- countdownEl.textContent = 'Volviendo a la caja en ' + secondsLeft + '...';
- if (secondsLeft <= 0) {
- returnToCajaAfterSale();
- return;
- }
- secondsLeft -= 1;
- countdownTimer = setTimeout(tickCountdown, 1000);
- }
- tickCountdown();
+ 'Pago confirmado';
+ const linesEl = document.getElementById('success-invoice-lines');
+ linesEl.innerHTML = lineDetails.map((line) => (
+ '
' +
+ '' + line.name + ' ' +
+ '' + line.quantity + ' x ' + formatMoney(line.unitPrice) + ' ' +
+ '
'
+ )).join('') || '
Sin ítems.
';
+ document.getElementById('success-order-total').textContent = formatted;
+ updateCajaTotalsCard(cajaTotals);
+ document.getElementById('success-section').style.display = 'flex';
+
+ document.getElementById('success-countdown').textContent = '';
document.getElementById('success-ok').onclick = function() {
returnToCajaAfterSale();
@@ -352,6 +467,12 @@
¡Listo!
}
async function cancelPendingSale() {
+ const qrCancelBtn = document.getElementById('mp-qr-cancel');
+ if (qrCancelBtn && !qrCancelBtn.disabled) {
+ qrCancelBtn.disabled = true;
+ qrCancelBtn.innerHTML =
+ '
Cancelando...';
+ }
if (!cancelUrl) {
resetToCaja();
return;
@@ -381,7 +502,7 @@
¡Listo!
});
if (sale.status === 'PAID') {
- showSuccess(sale.total_amount);
+ showSuccess(sale.total_amount, sale.caja_totals);
return;
}
@@ -399,17 +520,18 @@
¡Listo!
setMpQrLoading(false);
document.getElementById('mp-qr-waiting').style.display = 'block';
pollDelay = 2000;
- pollStatus((data) => showSuccess(data.total_amount));
+ pollStatus((data) => showSuccess(data.total_amount, data.caja_totals));
return;
}
if (paymentMethod === 'MP_POINT') {
setPayProcessing(false);
+ toggleCajaTotalsPanel(true);
hideAllScreens();
document.getElementById('point-section').style.display = 'block';
await postJson(base + 'pay/mp-point/', {});
pollDelay = 2000;
- pollStatus((data) => showSuccess(data.total_amount));
+ pollStatus((data) => showSuccess(data.total_amount, data.caja_totals));
}
} catch (e) {
setPayProcessing(false);
diff --git a/user_profile/templates/mi_fuego/caja_v2/ticket_stats_panel.html b/user_profile/templates/mi_fuego/caja_v2/ticket_stats_panel.html
index 18fe211..c4b0f37 100644
--- a/user_profile/templates/mi_fuego/caja_v2/ticket_stats_panel.html
+++ b/user_profile/templates/mi_fuego/caja_v2/ticket_stats_panel.html
@@ -7,10 +7,10 @@
- Efectivo: ${{ caja_payment_totals.cash_total|floatformat:0|intcomma }}
+ Efectivo: ${{ caja_payment_totals.cash_total|floatformat:0|intcomma }}
- MP: ${{ caja_payment_totals.mp_total|floatformat:0|intcomma }}
+ MP: ${{ caja_payment_totals.mp_total|floatformat:0|intcomma }}
Totales de esta caja (click para ver transacciones)