feat: impressao bold; JSON vales/sangrias/despesas/pixcnpj/receber/cancelamentos; recalc on add row
Build Fechamento de Caixa / build (macos-14, app) (push) Has been cancelled
Build Fechamento de Caixa / build (ubuntu-22.04, deb) (push) Has been cancelled
Build Fechamento de Caixa / build (windows-2022, msi) (push) Has been cancelled

This commit is contained in:
root
2026-06-30 18:08:19 +00:00
parent 84578fe43d
commit 8ea5ba771a
+60 -55
View File
@@ -1380,32 +1380,32 @@ function buildConfirmHTML(data) {
<td>${cartPix > 0 ? fmt(cartPix) : '-'}</td> <td>${cartPix > 0 ? fmt(cartPix) : '-'}</td>
</tr>`; </tr>`;
return `<!DOCTYPE html> let html = `<!DOCTYPE html>
<html><head> <html><head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Fechamento de Caixa</title> <title>Fechamento de Caixa</title>
<style> <style>
* { box-sizing: border-box; margin: 0; padding: 0; } * { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; } body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.header { text-align: center; margin-bottom: 8px; } .header { text-align: center; margin-bottom: 8px; }
.header h1 { font-size: 18px; } .header h1 { font-size: 18px; font-weight: bold; }
.header h2 { font-size: 14px; font-weight: normal; } .header h2 { font-size: 14px; font-weight: normal; }
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; } hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; } .section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; } .row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
.row.total-row { font-weight: bold; } .row.total-row { font-weight: bold; }
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; } .cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; } .cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
.cart-table td { padding: 2px 4px; text-align: right; } .cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
.cart-table td:first-child { text-align: left; } .cart-table td:first-child { text-align: left; }
.cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; } .cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; }
.subtotal { font-size: 12px; margin-top: 4px; } .subtotal { font-size: 12px; margin-top: 4px; }
.diff-ok { color: #2e7d32; } .subtotal .row { padding: 1px 0; }
.diff-bad { color: #c0272d; } .diff-ok { color: #2e7d32; font-weight: bold; }
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; } .diff-bad { color: #c0272d; font-weight: bold; }
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; } .footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
@media print { body { margin: 0; } } @media print { body { background: #fff; font-weight: bold !important; } }
</style>
</head><body> </head><body>
<div class="header"> <div class="header">
<h1>${data.loja}</h1> <h1>${data.loja}</h1>
@@ -1604,26 +1604,26 @@ function buildPrintHTML(data) {
<title>Fechamento de Caixa</title> <title>Fechamento de Caixa</title>
<style> <style>
* { box-sizing: border-box; margin: 0; padding: 0; } * { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; } body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.header { text-align: center; margin-bottom: 8px; } .header { text-align: center; margin-bottom: 8px; }
.header h1 { font-size: 18px; } .header h1 { font-size: 18px; font-weight: bold; }
.header h2 { font-size: 14px; font-weight: normal; } .header h2 { font-size: 14px; font-weight: normal; }
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; } hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; } .section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; } .row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
.row.total-row { font-weight: bold; } .row.total-row { font-weight: bold; }
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; } .cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; } .cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
.cart-table td { padding: 2px 4px; text-align: right; } .cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
.cart-table td:first-child { text-align: left; } .cart-table td:first-child { text-align: left; }
.cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; } .cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; }
.subtotal { font-size: 12px; margin-top: 4px; } .subtotal { font-size: 12px; margin-top: 4px; }
.subtotal .row { padding: 1px 0; } .subtotal .row { padding: 1px 0; }
.diff-ok { color: #2e7d32; } .diff-ok { color: #2e7d32; font-weight: bold; }
.diff-bad { color: #c0272d; } .diff-bad { color: #c0272d; font-weight: bold; }
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; } .obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; } .footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
@media print { body { margin: 0; } } @media print { body { background: #fff; font-weight: bold !important; } }
</style> </style>
</head><body> </head><body>
<div class="header"> <div class="header">
@@ -2556,8 +2556,10 @@ window._editAddRow = function(tblId) {
for (let c = 0; c < cols; c++) { for (let c = 0; c < cols; c++) {
const td = row.insertCell(-1); const td = row.insertCell(-1);
const isNum = numericCols.includes(c); const isNum = numericCols.includes(c);
td.innerHTML = `<input data-tbl="${tblId}" data-row="${newRowIdx}" data-col="${c}" value="" ${isNum ? `style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} />`; td.innerHTML = `<input data-tbl="${tblId}" data-row="${newRowIdx}" data-col="${c}" value="" ${isNum ? `oninput="window._recalcEditTotals()" onblur="this.value=fmtBR(this)" style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} />`;
} }
// Recalcula após adicionar
window._recalcEditTotals();
}; };
// Lê todos os dados das grades editáveis do modal // 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]); const cartPixHTML = editTableHTML('pix', ['Valor (R$)'], cartPix_rows.length ? cartPix_rows : [['']], [0]);
// --- Vales --- // --- 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]); const valesHTML = editTableHTML('vales', ['Nome', 'Valor (R$)', 'Obs'], vales_rows.length ? vales_rows : [['','','']], [1]);
// --- Despesas --- // --- 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]); const despesasHTML = editTableHTML('despesas', ['Descrição', 'Obs', 'Valor (R$)'], despesas_rows.length ? despesas_rows : [['','','']], [2]);
// --- Sangrias --- // --- 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]); const sangriasHTML = editTableHTML('sangrias', ['Hora', 'Valor (R$)', 'Gerente'], sangrias_rows.length ? sangrias_rows : [['','','']], [1]);
// --- Cancelamentos --- // --- 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]); const cancelHTML = editTableHTML('cancelamentos', ['Número', 'Valor (R$)', 'Motivo'], cancel_rows.length ? cancel_rows : [['','','']], [1]);
// --- PIX CNPJ --- // --- 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]); const pixcnpjHTML = editTableHTML('pixcnpj', ['Nome', 'Valor (R$)'], pixcnpj_rows.length ? pixcnpj_rows : [['','']], [1]);
// --- A Receber --- // --- 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]); const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]);
// --- Totais (só leitura formatado) --- // --- Totais (só leitura formatado) ---
@@ -3124,33 +3126,36 @@ function consultaToPrintData(full) {
// Imprime o relatório — usa iframe como openPrintPreview (Tauri não bloqueia) // Imprime o relatório — usa iframe como openPrintPreview (Tauri não bloqueia)
window.printRelatorio = function() { window.printRelatorio = function() {
const full = window._currentConsulta; let html = `<!DOCTYPE html>
if (!full) return; <html><head>
const data = consultaToPrintData(full); <meta charset="UTF-8">
const html = buildPrintHTML(data); <title>Fechamento de Caixa</title>
const previewStyle = ` <style>
<style> * { box-sizing: border-box; margin: 0; padding: 0; }
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 13px; background: #fff; padding: 10px; } body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.header { text-align: center; margin-bottom: 8px; } .header { text-align: center; margin-bottom: 8px; }
.header h1 { font-size: 18px; } .header h1 { font-size: 18px; font-weight: bold; }
.header h2 { font-size: 14px; font-weight: normal; } .header h2 { font-size: 14px; font-weight: normal; }
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; } hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; } .section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; } .row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
.row.total-row { font-weight: bold; } .row.total-row { font-weight: bold; }
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; } .cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; } .cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
.cart-table td { padding: 2px 4px; text-align: right; } .cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
.cart-table td:first-child { text-align: left; } .cart-table td:first-child { text-align: left; }
.cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; } .cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; }
.subtotal { font-size: 12px; margin-top: 4px; } .subtotal { font-size: 12px; margin-top: 4px; }
.diff-ok { color: #2e7d32; } .subtotal .row { padding: 1px 0; }
.diff-bad { color: #c0272d; } .diff-ok { color: #2e7d32; font-weight: bold; }
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; } .diff-bad { color: #c0272d; font-weight: bold; }
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; } .obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
@media print { body { background: #fff; } } .footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
</style>`; @media print { body { background: #fff; font-weight: bold !important; } }
const fullHtml = `<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Recibo</title>${previewStyle}</head><body>${html}</body></html>`; </style>
</head><body>
${buildPrintHTML(data)}
</body></html>`;
const existing = document.getElementById('print-preview-overlay'); const existing = document.getElementById('print-preview-overlay');
if (existing) document.body.removeChild(existing); if (existing) document.body.removeChild(existing);
@@ -3172,7 +3177,7 @@ window.printRelatorio = function() {
overlay.appendChild(btnFechar); overlay.appendChild(btnFechar);
overlay.appendChild(btnImprimir); overlay.appendChild(btnImprimir);
document.body.appendChild(overlay); document.body.appendChild(overlay);
iframe.srcdoc = fullHtml; iframe.srcdoc = html;
}; };
// Intercepta o envio — se sync_status=editing, faz PATCH // Intercepta o envio — se sync_status=editing, faz PATCH