From 8660ac47552246ffc0223c4f93653c278afd78d0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Jun 2026 12:55:30 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20fmtNum=20shows=20.00=20only=20when=20nee?= =?UTF-8?q?ded;=20Diferen=C3=A7a=3DSaldoCaixa-SaldoEsperado;=20sys-total?= =?UTF-8?q?=20already=20includes=20pixCnpj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.html b/src/index.html index 0e4386e..f9d13b5 100644 --- a/src/index.html +++ b/src/index.html @@ -600,7 +600,10 @@ const setVal = (id, v) => { const e = document.getElementById(id); if (e) e.valu const val = id => { const e = document.getElementById(id); return e ? e.value : ''; }; const fmtNum = v => { const n = typeof v === 'number' ? v : parseNum(v); - return isNaN(n) ? '' : n.toLocaleString('pt-BR', { minimumFractionDigits: 2 }); + if (isNaN(n)) return ''; + // Only show decimals if not a whole number + const decimals = Number.isInteger(n) ? 0 : 2; + return n.toLocaleString('pt-BR', { minimumFractionDigits: decimals, maximumFractionDigits: 2 }); }; // Format time: 4 digits → HH:MM @@ -837,8 +840,9 @@ function updateTotals() { const fr = receberTotal; setText('fech-total', fmt(fd + fc + fr)); - // Diferença = Saldo Esperado − Fechamento - const diff = parseNum(val('f-saldo-esperado')) - (fd + fc + fr); + // Diferença = Saldo Caixa − Saldo Esperado + const saldoCaixa = sysTotal; + const diff = saldoCaixa - parseNum(val('f-saldo-esperado')); const difEl = document.getElementById('diferenca'); if (difEl) { difEl.textContent = fmt(diff);