diff --git a/src/index.html b/src/index.html index 91ac001..df8bd11 100644 --- a/src/index.html +++ b/src/index.html @@ -1380,32 +1380,32 @@ function buildConfirmHTML(data) { ${cartPix > 0 ? fmt(cartPix) : '-'} `; - return ` + let html = ` Fechamento de Caixa + @media print { body { background: #fff; font-weight: bold !important; } }

${data.loja}

@@ -1604,26 +1604,26 @@ function buildPrintHTML(data) { Fechamento de Caixa
@@ -2556,8 +2556,10 @@ window._editAddRow = function(tblId) { for (let c = 0; c < cols; c++) { const td = row.insertCell(-1); const isNum = numericCols.includes(c); - td.innerHTML = ``; + td.innerHTML = ``; } + // Recalcula após adicionar + window._recalcEditTotals(); }; // Lê todos os dados das grades editáveis do modal @@ -2651,27 +2653,27 @@ function openEditModal(full) { const cartPixHTML = editTableHTML('pix', ['Valor (R$)'], cartPix_rows.length ? cartPix_rows : [['']], [0]); // --- Vales --- - const vales_rows = (full.vales || []).map(r => [r.nome||r.Nome||'', r.valor, r.obs||r.Obs||'']); + const vales_rows = (full.vales_arr || []).map(r => [r.nome||r.Nome||'', r.valor||0, r.obs||r.Obs||'']); const valesHTML = editTableHTML('vales', ['Nome', 'Valor (R$)', 'Obs'], vales_rows.length ? vales_rows : [['','','']], [1]); // --- Despesas --- - const despesas_rows = (full.despesas || []).map(r => [r.desc||r.Desc||'', r.obs||r.Obs||'', r.valor]); + const despesas_rows = (full.despesas_arr || []).map(r => [r.desc||r.Desc||'', r.obs||r.Obs||'', r.valor||0]); const despesasHTML = editTableHTML('despesas', ['Descrição', 'Obs', 'Valor (R$)'], despesas_rows.length ? despesas_rows : [['','','']], [2]); // --- Sangrias --- - const sangrias_rows = (full.sangrias || []).map(r => [r.hora||r.Hora||'', r.retirada, r.gerente||r.Gerente||'']); + const sangrias_rows = (full.sangrias_arr || []).map(r => [r.hora||r.Hora||'', r.retirada||r.valor||0, r.gerente||r.Gerente||'']); const sangriasHTML = editTableHTML('sangrias', ['Hora', 'Valor (R$)', 'Gerente'], sangrias_rows.length ? sangrias_rows : [['','','']], [1]); // --- Cancelamentos --- - const cancel_rows = (full.cancelamentos || []).map(r => [r.numero||r.Numero||'', r.valor, r.motivo||r.Motivo||'']); + const cancel_rows = (full.cancelamentos_arr || []).map(r => [r.numero||r.Numero||'', r.valor||0, r.motivo||r.Motivo||'']); const cancelHTML = editTableHTML('cancelamentos', ['Número', 'Valor (R$)', 'Motivo'], cancel_rows.length ? cancel_rows : [['','','']], [1]); // --- PIX CNPJ --- - const pixcnpj_rows = (full.pixcnpj || []).map(r => [r.nome||r.Nome||'', r.valor]); + const pixcnpj_rows = (full.pixcnpj_arr || []).map(r => [r.nome||r.desc||r.Desc||'', r.valor||0]); const pixcnpjHTML = editTableHTML('pixcnpj', ['Nome', 'Valor (R$)'], pixcnpj_rows.length ? pixcnpj_rows : [['','']], [1]); // --- A Receber --- - const receber_rows = (full.receber || []).map(r => [r.nome||r.Nome||'', r.valor]); + const receber_rows = (full.receber_arr || []).map(r => [r.nome||r.Nome||'', r.valor||0]); const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]); // --- Totais (só leitura formatado) --- @@ -3124,33 +3126,36 @@ function consultaToPrintData(full) { // Imprime o relatório — usa iframe como openPrintPreview (Tauri não bloqueia) window.printRelatorio = function() { - const full = window._currentConsulta; - if (!full) return; - const data = consultaToPrintData(full); - const html = buildPrintHTML(data); - const previewStyle = ` - `; - const fullHtml = `Recibo${previewStyle}${html}`; + let html = ` + + +Fechamento de Caixa + + +${buildPrintHTML(data)} +`; const existing = document.getElementById('print-preview-overlay'); if (existing) document.body.removeChild(existing); @@ -3172,7 +3177,7 @@ window.printRelatorio = function() { overlay.appendChild(btnFechar); overlay.appendChild(btnImprimir); document.body.appendChild(overlay); - iframe.srcdoc = fullHtml; + iframe.srcdoc = html; }; // Intercepta o envio — se sync_status=editing, faz PATCH