fix: buildPrintHTML usa data.diferenca (sys_total - saldo_esperado); btn-anterior null-check robusto
This commit is contained in:
+11
-3
@@ -1290,7 +1290,10 @@ function buildConfirmHTML(data) {
|
|||||||
// ─── Print Preview Window ──────────────────────────────────────────────────
|
// ─── Print Preview Window ──────────────────────────────────────────────────
|
||||||
function buildPrintHTML(data) {
|
function buildPrintHTML(data) {
|
||||||
const fmt = v => 'R$ ' + (v || 0).toFixed(2).replace('.', ',');
|
const fmt = v => 'R$ ' + (v || 0).toFixed(2).replace('.', ',');
|
||||||
const diferenca = (data.fechamento || 0) - (data.saldo_esperado || 0);
|
// Usa a diferenca ja calculada pelo tauriRecibo (sys_total - saldo_esperado),
|
||||||
|
// igual ao modal de confirmacao — nao recalcula de fechamento.
|
||||||
|
const diferenca = data.diferenca !== undefined ? data.diferenca
|
||||||
|
: ((data.sys_total || 0) - (data.saldo_esperado || 0));
|
||||||
const diffStr = diferenca >= 0 ? `+${fmt(diferenca)}` : fmt(diferenca);
|
const diffStr = diferenca >= 0 ? `+${fmt(diferenca)}` : fmt(diferenca);
|
||||||
const diffColor = diferenca === 0 ? '#2e7d32' : (diferenca > 0 ? '#e65100' : '#c0272d');
|
const diffColor = diferenca === 0 ? '#2e7d32' : (diferenca > 0 ? '#e65100' : '#c0272d');
|
||||||
|
|
||||||
@@ -1700,7 +1703,9 @@ document.getElementById('btn-limpar').addEventListener('click', () => {
|
|||||||
showToast('Rascunho limpo.', 'info');
|
showToast('Rascunho limpo.', 'info');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('btn-anterior').addEventListener('click', async () => {
|
const btnAnterior = document.getElementById('btn-anterior');
|
||||||
|
if (btnAnterior) {
|
||||||
|
btnAnterior.addEventListener('click', async () => {
|
||||||
console.log('[DEBUG] btn-anterior clicado');
|
console.log('[DEBUG] btn-anterior clicado');
|
||||||
const loja = val('f-loja') || 'União';
|
const loja = val('f-loja') || 'União';
|
||||||
console.log('[DEBUG] btn-anterior loja:', loja);
|
console.log('[DEBUG] btn-anterior loja:', loja);
|
||||||
@@ -1825,7 +1830,10 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
|||||||
updateTotals();
|
updateTotals();
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
console.log('[DEBUG] btn-anterior concluído');
|
console.log('[DEBUG] btn-anterior concluído');
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.error('[DEBUG] btn-anterior NÃO encontrado no DOM!');
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('f-obs').addEventListener('input', e => { estado.observacoes = e.target.value; scheduleSave(); });
|
document.getElementById('f-obs').addEventListener('input', e => { estado.observacoes = e.target.value; scheduleSave(); });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user