Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b3b7a9f1d | |||
| 5641de21f8 | |||
| d77ad55fbd | |||
| 4a5cae8f2f | |||
| 313c740470 |
+188
-72
@@ -1871,12 +1871,28 @@ function buildReciboData() {
|
||||
const valesTotal = estado.vales.reduce((s,r) => s+(parseNum(r.valor||0)||0), 0);
|
||||
const receberTotal = estado.receber.reduce((s,r) => s+(parseNum(r.valor||0)||0), 0);
|
||||
const cancelTotal = estado.cancelamentos.reduce((s,r) => s+(parseNum(r.valor||0)||0), 0);
|
||||
const fechamentoCounted = parseNum(val('f-fech-dinheiro')) + parseNum(val('f-fech-cartoes')) + parseNum(val('f-fech-receber'));
|
||||
const saldoEsp = parseNum(val('f-saldo-esperado'));
|
||||
|
||||
// Lê do DOM — mas se estiver vazio usa estado (registro anterior)
|
||||
const trocoDom = parseNum(val('sys-troco'));
|
||||
const saldoTroco = trocoDom || estado.saldo_troco || 0;
|
||||
const saldoCred = parseNum(val('sys-credito')) || cartCred;
|
||||
const saldoDeb = parseNum(val('sys-debito')) || cartDeb;
|
||||
const saldoAli = parseNum(val('sys-alimentacao')) || cartAli;
|
||||
const saldoPixCartao = parseNum(val('sys-pix')) || cartPix;
|
||||
const saldoPixCnpj = parseNum(val('sys-pixcnpj')) || pixCnpjTotal;
|
||||
const saldoVales = parseNum(val('sys-vales')) || valesTotal;
|
||||
const saldoReceber = parseNum(val('sys-receber')) || receberTotal;
|
||||
|
||||
const fechamentoDinheiro = parseNum(val('f-fech-dinheiro')) || estado.fechamento_contado?.dinheiro || 0;
|
||||
const fechamentoCartoes = parseNum(val('f-fech-cartoes')) || estado.fechamento_contado?.cartoes || 0;
|
||||
const fechamentoReceber = parseNum(val('f-fech-receber')) || estado.fechamento_contado?.receber || 0;
|
||||
const fechamentoCounted = fechamentoDinheiro + fechamentoCartoes + fechamentoReceber;
|
||||
const saldoEsperado = parseNum(val('f-saldo-esperado')) || estado.saldo_esperado || 0;
|
||||
|
||||
// Saldo de Caixa (Sistema) = troco + crédito + débito + alimentação + voucher pix + pixcnpj + vales + receber
|
||||
const sysTotal = parseNum(val('sys-troco')) + cartCred + cartDeb + cartAli + cartPix + pixCnpjTotal + valesTotal + receberTotal;
|
||||
const sysTotal = saldoTroco + cartCred + cartDeb + cartAli + cartPix + pixCnpjTotal + valesTotal + receberTotal;
|
||||
// Diferença = saldo de caixa (sistema) - saldo_esperado - cancelamentos
|
||||
const diferenca = sysTotal - saldoEsp - cancelTotal;
|
||||
const diferenca = sysTotal - saldoEsperado - cancelTotal;
|
||||
return {
|
||||
uuid: estado.uuid,
|
||||
id_local: estado.id_local,
|
||||
@@ -1885,14 +1901,14 @@ function buildReciboData() {
|
||||
data: estado.data,
|
||||
operador: estado.operador,
|
||||
turno: estado.turno,
|
||||
saldo_troco: parseNum(val('sys-troco')),
|
||||
saldo_esperado: saldoEsp,
|
||||
saldo_troco: saldoTroco,
|
||||
saldo_esperado: saldoEsperado,
|
||||
fechamento: fechamentoCounted,
|
||||
diferenca: diferenca,
|
||||
sys_total: sysTotal,
|
||||
fechamento_dinheiro: parseNum(val('f-fech-dinheiro')),
|
||||
fechamento_cartoes: parseNum(val('f-fech-cartoes')),
|
||||
fechamento_receber: parseNum(val('f-fech-receber')),
|
||||
fechamento_dinheiro: fechamentoDinheiro,
|
||||
fechamento_cartoes: fechamentoCartoes,
|
||||
fechamento_receber: fechamentoReceber,
|
||||
// Flat totals for ReciboData struct (Rust) — must be numbers
|
||||
credito: cartCred,
|
||||
debito: cartDeb,
|
||||
@@ -2151,11 +2167,6 @@ function buildConsultaModal(recentList) {
|
||||
return `${day}/${m}/${y}`;
|
||||
};
|
||||
const fmtMoney = v => v != null ? `R$ ${parseFloat(v).toFixed(2).replace('.', ',')}` : 'R$ 0,00';
|
||||
const syncBadge = s => {
|
||||
const colors = { synced: '#2e7d32', local: '#e65100', syncing: '#f57f17', error: '#c0272d' };
|
||||
const labels = { synced: '✓ Sync', local: '⚠ Local', syncing: '⏳ Sync', error: '✗ Erro' };
|
||||
return `<span style="background:${colors[s]||'#888'};color:#fff;padding:1px 5px;border-radius:3px;font-size:10px">${labels[s]||s||'?'}</span>`;
|
||||
};
|
||||
const statusBadge = s => {
|
||||
if (s === 'ok') return '<span style="color:#2e7d32;font-weight:bold">✓ OK</span>';
|
||||
if (s === 'sobrando') return '<span style="color:#e65100;font-weight:bold">⚠ SOBRANDO</span>';
|
||||
@@ -2163,56 +2174,104 @@ function buildConsultaModal(recentList) {
|
||||
return s || '?';
|
||||
};
|
||||
|
||||
const rows = recentList.map((item, i) => {
|
||||
const sysTotal = (parseFloat(item.saldo_troco)||0)
|
||||
+ (parseFloat(item.saldo_credito)||0)
|
||||
+ (parseFloat(item.saldo_debito)||0)
|
||||
+ (parseFloat(item.saldo_alimentacao)||0)
|
||||
+ (parseFloat(item.saldo_vales)||0)
|
||||
+ (parseFloat(item.saldo_areceber)||0)
|
||||
+ (parseFloat(item.total_pixcnpj)||0)
|
||||
+ (parseFloat(item.total_cartao_pix)||0);
|
||||
return `<tr>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtDate(item.data)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${item.operador||'?'}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${item.turno||'?'}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtMoney(sysTotal)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtMoney(item.saldo_esperado)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${statusBadge(item.status_diferenca)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${syncBadge(item.sync_status)}</td>
|
||||
<td style="padding:4px 6px;border-bottom:1px solid #eee;text-align:center">
|
||||
<button onclick="event.stopPropagation();window.abrirEditaFechamentoIndex(${i})" style="background:#e65100;color:#fff;border:none;border-radius:4px;padding:4px 10px;cursor:pointer;font-size:11px;white-space:nowrap">✏️ Editar</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
// Calcula saldo de caixa real (mesma fórmula do relatório)
|
||||
const calcSaldoCaixa = item => (parseFloat(item.saldo_troco)||0)
|
||||
+ (parseFloat(item.saldo_credito)||0)
|
||||
+ (parseFloat(item.saldo_debito)||0)
|
||||
+ (parseFloat(item.saldo_alimentacao)||0)
|
||||
+ (parseFloat(item.saldo_vales)||0)
|
||||
+ (parseFloat(item.saldo_areceber)||0)
|
||||
+ (parseFloat(item.total_pixcnpj)||0)
|
||||
+ (parseFloat(item.total_cartao_pix)||0);
|
||||
|
||||
// Ordena por data desc e pega os últimos 5 dias distintos
|
||||
const sortedDesc = [...recentList].sort((a,b) => b.data.localeCompare(a.data));
|
||||
const cincoDias = sortedDesc.slice(0, 5);
|
||||
|
||||
// Último dia distinto (para placeholder do input)
|
||||
const ultimoDia = sortedDesc[0]?.data || '';
|
||||
|
||||
function renderRows(list) {
|
||||
if (!list || list.length === 0) {
|
||||
return `<tr><td colspan="7" style="padding:20px;text-align:center;color:#888;font-size:13px">Nenhum registro encontrado.</td></tr>`;
|
||||
}
|
||||
return list.map((item, i) => {
|
||||
const saldoCaixa = calcSaldoCaixa(item);
|
||||
const diff = saldoCaixa - (parseFloat(item.saldo_esperado)||0);
|
||||
const diffClass = diff === 0 ? '#2e7d32' : diff > 0 ? '#e65100' : '#c0272d';
|
||||
const diffLabel = diff === 0 ? '✓ OK' : diff > 0 ? `+R$ ${diff.toFixed(2).replace('.',',')}` : `-R$ ${Math.abs(diff).toFixed(2).replace('.',',')}`;
|
||||
return `<tr data-idx="${recentList.indexOf(item)}" style="background:${i%2===0?'#fff':'#fafafa'}" onmouseover="this.style.background='#fff3e0'" onmouseout="this.style.background='${i%2===0?'#fff':'#fafafa'}'">
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${fmtDate(item.data)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${item.operador||'?'}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${item.turno||'?'}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${fmtMoney(saldoCaixa)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${fmtMoney(item.saldo_esperado)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:center;cursor:pointer;color:${diffClass};font-weight:bold" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${diffLabel}</td>
|
||||
<td style="padding:4px 6px;border-bottom:1px solid #eee;text-align:center">
|
||||
<button onclick="event.stopPropagation();window.abrirEditaFechamentoIndex(${recentList.indexOf(item)})" style="background:#e65100;color:#fff;border:none;border-radius:4px;padding:4px 10px;cursor:pointer;font-size:11px;white-space:nowrap">✏️ Editar</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
overlay.innerHTML = `
|
||||
<div style="background:#fff;border-radius:10px;padding:20px;max-width:780px;width:95%;max-height:85vh;overflow-y:auto">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
||||
<h2 style="margin:0;font-size:16px">📅 Consultar Fechamentos Anteriores</h2>
|
||||
<button onclick="closeConsultaModal()" style="background:none;border:none;font-size:18px;cursor:pointer">✕</button>
|
||||
<div style="background:#fff;border-radius:10px;padding:20px;max-width:850px;width:95%;max-height:85vh;overflow-y:auto">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;flex-wrap:wrap;gap:8px">
|
||||
<h2 style="margin:0;font-size:16px">📅 Consultar Fechamentos</h2>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<input type="date" id="consulta-busca-data" value="" max="${ultimoDia}" style="padding:6px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px" />
|
||||
<button onclick="window._filtrarConsulta()" style="background:#1565c0;color:#fff;border:none;border-radius:6px;padding:6px 14px;cursor:pointer;font-size:13px">🔍 Buscar</button>
|
||||
<button onclick="closeConsultaModal()" style="background:none;border:none;font-size:18px;cursor:pointer;padding:4px 8px">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="consulta-info" style="font-size:11px;color:#888;margin-bottom:8px"></div>
|
||||
<div style="max-height:55vh;overflow-y:auto;border:1px solid #eee;border-radius:6px">
|
||||
<table style="width:100%;border-collapse:collapse">
|
||||
<thead style="position:sticky;top:0;background:#f5f5f5;z-index:1">
|
||||
<tr>
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">DATA</th>
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">OPERADOR</th>
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">TURNO</th>
|
||||
<th style="padding:6px 8px;text-align:right;font-size:11px;color:#888">SALDO CAIXA</th>
|
||||
<th style="padding:6px 8px;text-align:right;font-size:11px;color:#888">ESPERADO</th>
|
||||
<th style="padding:6px 8px;text-align:center;font-size:11px;color:#888">DIFERENÇA</th>
|
||||
<th style="padding:4px 6px;text-align:center;font-size:11px;color:#888">AÇÃO</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="consulta-tbody">${renderRows(cincoDias)}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="margin-top:8px;font-size:11px;color:#888;text-align:center">
|
||||
Mostrando últimos 5 dias. Use a <strong>busca por data</strong> para encontrar registros mais antigos.
|
||||
</div>
|
||||
<p style="font-size:12px;color:#666;margin:0 0 10px">Clique em um registro para ver o relatório ou clique em <strong>Editar</strong> para abrir a janela de edição.</p>
|
||||
<table style="width:100%;border-collapse:collapse">
|
||||
<thead>
|
||||
<tr style="background:#f5f5f5">
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">DATA</th>
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">OPERADOR</th>
|
||||
<th style="padding:6px 8px;text-align:left;font-size:11px;color:#888">TURNO</th>
|
||||
<th style="padding:6px 8px;text-align:right;font-size:11px;color:#888">SALDO CAIXA</th>
|
||||
<th style="padding:6px 8px;text-align:right;font-size:11px;color:#888">ESPERADO</th>
|
||||
<th style="padding:6px 8px;text-align:center;font-size:11px;color:#888">STATUS</th>
|
||||
<th style="padding:6px 8px;text-align:center;font-size:11px;color:#888">SYNC</th>
|
||||
<th style="padding:6px 8px;text-align:center;font-size:11px;color:#888">AÇÃO</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${rows}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
// Função de busca por data
|
||||
window._filtrarConsulta = () => {
|
||||
const dataBusca = document.getElementById('consulta-busca-data')?.value;
|
||||
const tbody = document.getElementById('consulta-tbody');
|
||||
const info = document.getElementById('consulta-info');
|
||||
if (!tbody) return;
|
||||
if (!dataBusca) {
|
||||
tbody.innerHTML = renderRows(cincoDias);
|
||||
if (info) info.textContent = 'Mostrando últimos 5 dias';
|
||||
return;
|
||||
}
|
||||
const filtrados = recentList.filter(item => item.data === dataBusca);
|
||||
tbody.innerHTML = renderRows(filtrados);
|
||||
if (info) info.textContent = filtrados.length ? `${filtrados.length} registro${filtrados.length!==1?'s':''} em ${fmtDate(dataBusca)}` : `Nenhum registro em ${fmtDate(dataBusca)}`;
|
||||
};
|
||||
|
||||
// Enter na busca
|
||||
document.getElementById('consulta-busca-data')?.addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter') window._filtrarConsulta();
|
||||
});
|
||||
|
||||
window._recentList = recentList;
|
||||
window._consultaAll = recentList;
|
||||
}
|
||||
|
||||
// Abre a janela de edição completa de um registro pelo índice na lista
|
||||
@@ -2700,7 +2759,35 @@ window._recalcEditTotals = function() {
|
||||
if (el('tot-areceber')) el('tot-areceber').textContent = fmtTot(recv_tot);
|
||||
if (el('tot-sangrias')) el('tot-sangrias').textContent = fmtTot(sang_tot);
|
||||
if (el('tot-despesas')) el('tot-despesas').textContent = fmtTot(desp_tot);
|
||||
if (el('tot-cancel')) el('tot-cancel').textContent = fmtTot(canc_tot);
|
||||
if (el('tot-cancel')) el('tot-cancel').textContent = fmtTot(canc_tot);
|
||||
|
||||
// Atualiza campos readonly do saldo de caixa com totais calculados
|
||||
const setReadonly = (id, v) => { if (el(id)) el(id).value = fmtTot(v); };
|
||||
setReadonly('edit-sld-credito', cartCred_tot);
|
||||
setReadonly('edit-sld-debito', cartDeb_tot);
|
||||
setReadonly('edit-sld-alimentacao', cartAli_tot);
|
||||
setReadonly('edit-sld-vales', vales_tot);
|
||||
setReadonly('edit-sld-pixcnpj', pixcnpj_tot);
|
||||
setReadonly('edit-sld-areceber', recv_tot);
|
||||
setReadonly('edit-sld-pixcartao', cartPix_tot);
|
||||
|
||||
// Calcula Saldo Caixa e Diferença em tempo real
|
||||
const trocoVal = parseNum(el('edit-troco')?.value || '0');
|
||||
const esperadoVal = parseNum(el('edit-esperado')?.value || '0');
|
||||
const saldoCaixa = trocoVal + cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot + pixcnpj_tot + vales_tot + recv_tot;
|
||||
const diferenca = saldoCaixa - esperadoVal - canc_tot;
|
||||
|
||||
if (el('edit-saldo-caixa')) {
|
||||
el('edit-saldo-caixa').textContent = saldoCaixa > 0 ? fmtTot(saldoCaixa) : 'R$ 0,00';
|
||||
}
|
||||
if (el('edit-diferenca')) {
|
||||
const fmtDif = v => v >= 0 ? `R$ ${v.toLocaleString('pt-BR', { minimumFractionDigits: 2 })}` : `-R$ ${Math.abs(v).toLocaleString('pt-BR', { minimumFractionDigits: 2 })}`;
|
||||
el('edit-diferenca').textContent = fmtDif(diferenca);
|
||||
// Alerta visual se diferença != 0
|
||||
if (el('edit-diferenca-box')) {
|
||||
el('edit-diferenca-box').style.background = diferenca === 0 ? '#e8f5e9' : diferenca > 0 ? '#fff3e0' : '#ffebee';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Modal de edição completo com todas as grades
|
||||
@@ -2762,20 +2849,32 @@ function openEditModal(full) {
|
||||
const receber_rows = (dados.receber || []).map(r => [r.nome||'', r.valor||0]);
|
||||
const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]);
|
||||
|
||||
// --- Totais (só leitura formatado) ---
|
||||
const totaisInfo = `
|
||||
// --- Totais (só leitura formatado) — calcula dos dados reais ---
|
||||
const totaisInfo = (() => {
|
||||
const calcCred = (dados.cartoes?.credito || full.cartoes_credito || []).reduce((s,r) => s+(parseFloat(typeof r==='object'?r.valor:r)||0), 0);
|
||||
const calcDeb = (dados.cartoes?.debito || full.cartoes_debito || []).reduce((s,r) => s+(parseFloat(typeof r==='object'?r.valor:r)||0), 0);
|
||||
const calcAli = (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).reduce((s,r) => s+(parseFloat(typeof r==='object'?r.valor:r)||0), 0);
|
||||
const calcPix = (dados.cartoes?.pix || full.cartoes_pix || []).reduce((s,r) => s+(parseFloat(typeof r==='object'?r.valor:r)||0), 0);
|
||||
const calcSang = (dados.sangrias || []).reduce((s,r) => s+(parseFloat(r.retirada||r.valor||0)||0), 0);
|
||||
const calcDesp = (dados.despesas || []).reduce((s,r) => s+(parseFloat(r.valor||0)||0), 0);
|
||||
const calcVales = (dados.vales || []).reduce((s,r) => s+(parseFloat(r.valor||0)||0), 0);
|
||||
const calcPixCnpj = (dados.pixcnpj || []).reduce((s,r) => s+(parseFloat(r.valor||0)||0), 0);
|
||||
const calcRecv = (dados.receber || []).reduce((s,r) => s+(parseFloat(r.valor||0)||0), 0);
|
||||
const calcCanc = (dados.cancelamentos || []).reduce((s,r) => s+(parseFloat(r.valor||0)||0), 0);
|
||||
return `
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:4px;background:#f5f5f5;border-radius:6px;padding:8px;margin-bottom:8px;font-size:11px">
|
||||
<div><strong>Total Crédito:</strong> <span id="edit-total-credito">${fmtMR(full.total_cartao_credito||0)}</span></div>
|
||||
<div><strong>Total Débito:</strong> <span id="edit-total-debito">${fmtMR(full.total_cartao_debito||0)}</span></div>
|
||||
<div><strong>Total Alimentação:</strong> <span id="edit-total-alimentacao">${fmtMR(full.total_cartao_alimentacao||0)}</span></div>
|
||||
<div><strong>Total PIX:</strong> <span id="edit-total-pix">${fmtMR(full.total_cartao_pix||0)}</span></div>
|
||||
<div><strong>Total Sangrias:</strong> <span id="edit-total-sangrias">${fmtMR(full.total_sangrias||0)}</span></div>
|
||||
<div><strong>Total Despesas:</strong> <span id="edit-total-despesas">${fmtMR(full.total_despesas||0)}</span></div>
|
||||
<div><strong>Total Vales:</strong> <span id="edit-total-vales">${fmtMR(full.total_vales||0)}</span></div>
|
||||
<div><strong>Total PIX CNPJ:</strong> <span id="edit-total-pixcnpj">${fmtMR(full.total_pixcnpj||0)}</span></div>
|
||||
<div><strong>Total Receber:</strong> <span id="edit-total-receber">${fmtMR(full.total_areceber||0)}</span></div>
|
||||
<div><strong>Total Cancel:</strong> <span id="edit-total-cancel">${fmtMR(full.total_cancelamentos||0)}</span></div>
|
||||
<div><strong>Total Crédito:</strong> <span id="edit-total-credito">${fmtMR(calcCred)}</span></div>
|
||||
<div><strong>Total Débito:</strong> <span id="edit-total-debito">${fmtMR(calcDeb)}</span></div>
|
||||
<div><strong>Total Alimentação:</strong> <span id="edit-total-alimentacao">${fmtMR(calcAli)}</span></div>
|
||||
<div><strong>Total PIX:</strong> <span id="edit-total-pix">${fmtMR(calcPix)}</span></div>
|
||||
<div><strong>Total Sangrias:</strong> <span id="edit-total-sangrias">${fmtMR(calcSang)}</span></div>
|
||||
<div><strong>Total Despesas:</strong> <span id="edit-total-despesas">${fmtMR(calcDesp)}</span></div>
|
||||
<div><strong>Total Vales:</strong> <span id="edit-total-vales">${fmtMR(calcVales)}</span></div>
|
||||
<div><strong>Total PIX CNPJ:</strong> <span id="edit-total-pixcnpj">${fmtMR(calcPixCnpj)}</span></div>
|
||||
<div><strong>Total Receber:</strong> <span id="edit-total-receber">${fmtMR(calcRecv)}</span></div>
|
||||
<div><strong>Total Cancel:</strong> <span id="edit-total-cancel">${fmtMR(calcCanc)}</span></div>
|
||||
</div>`;
|
||||
})();
|
||||
|
||||
const overlay = document.createElement('div');
|
||||
overlay.id = 'modal-edit';
|
||||
@@ -2907,7 +3006,8 @@ function openEditModal(full) {
|
||||
<div style="margin-bottom:12px;background:#f5f5f5;border-radius:6px;padding:8px">
|
||||
<strong style="font-size:12px;color:#333;margin-bottom:4px;display:block">💰 Saldo de Caixa <span style="font-size:10px;color:#888">(apenas Troco é editável)</span></strong>
|
||||
<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:6px">
|
||||
<div><label style="font-size:10px;color:#555">Troco:</label><input type="text" id="edit-troco" value="${fmtMR(full.saldo_troco)}" style="width:100%;padding:5px;border:1px solid #2e7d32;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||
<div><label style="font-size:10px;color:#555">Troco:</label><input type="text" id="edit-troco" value="${fmtMR(full.saldo_troco)}" style="width:100%;padding:5px;border:1px solid #2e7d32;border-radius:4px;text-align:right" oninput="window._recalcEditTotals()" onblur="this.value=fmtBR(this)" /></div>
|
||||
<div><label style="font-size:10px;color:#555">Saldo Esperado:</label><input type="text" id="edit-esperado" value="${fmtMR(full.saldo_esperado)}" style="width:100%;padding:5px;border:1px solid #e65100;border-radius:4px;text-align:right;font-weight:bold" oninput="window._recalcEditTotals()" onblur="this.value=fmtBR(this)" /></div>
|
||||
<div><label style="font-size:10px;color:#888">Crédito:</label><input type="text" id="edit-sld-credito" value="${fmtMR(full.saldo_credito)}" readonly tabindex="-1" style="width:100%;padding:5px;border:1px solid #ddd;border-radius:4px;text-align:right;background:#eee;color:#666" /></div>
|
||||
<div><label style="font-size:10px;color:#888">Débito:</label><input type="text" id="edit-sld-debito" value="${fmtMR(full.saldo_debito)}" readonly tabindex="-1" style="width:100%;padding:5px;border:1px solid #ddd;border-radius:4px;text-align:right;background:#eee;color:#666" /></div>
|
||||
<div><label style="font-size:10px;color:#888">Alimentação:</label><input type="text" id="edit-sld-alimentacao" value="${fmtMR(full.saldo_alimentacao)}" readonly tabindex="-1" style="width:100%;padding:5px;border:1px solid #ddd;border-radius:4px;text-align:right;background:#eee;color:#666" /></div>
|
||||
@@ -2916,14 +3016,23 @@ function openEditModal(full) {
|
||||
<div><label style="font-size:10px;color:#888">À Receber:</label><input type="text" id="edit-sld-areceber" value="${fmtMR(full.saldo_areceber)}" readonly tabindex="-1" style="width:100%;padding:5px;border:1px solid #ddd;border-radius:4px;text-align:right;background:#eee;color:#666" /></div>
|
||||
<div><label style="font-size:10px;color:#888">PIX Cartão:</label><input type="text" id="edit-sld-pixcartao" value="${fmtMR(full.total_cartao_pix)}" readonly tabindex="-1" style="width:100%;padding:5px;border:1px solid #ddd;border-radius:4px;text-align:right;background:#eee;color:#666" /></div>
|
||||
</div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:6px">
|
||||
<div style="background:#e3f2fd;border-radius:4px;padding:6px 8px;text-align:right">
|
||||
<span style="font-size:11px;color:#1565c0">SALDO CAIXA:</span>
|
||||
<span id="edit-saldo-caixa" style="font-size:16px;font-weight:bold;color:#1565c0;margin-left:8px">R$ 0,00</span>
|
||||
</div>
|
||||
<div id="edit-diferenca-box" style="background:#fff3e0;border-radius:4px;padding:6px 8px;text-align:right">
|
||||
<span style="font-size:11px;color:#e65100">DIFERENÇA:</span>
|
||||
<span id="edit-diferenca" style="font-size:16px;font-weight:bold;color:#e65100;margin-left:8px">R$ 0,00</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Contadores -->
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:6px;margin-bottom:12px">
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-bottom:12px">
|
||||
<div><label style="font-size:10px;color:#555">Clientes:</label><input type="number" id="edit-clientes" value="${dados.clientes||full.clientes||0}" min="0" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||
<div><label style="font-size:10px;color:#555">Frango Assado:</label><input type="number" id="edit-frango" value="${dados.frango||full.frango||0}" min="0" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||
<div><label style="font-size:10px;color:#555">Vendas (R$):</label><input type="text" id="edit-vendas" value="${fmtMR(dados.vendas||full.vendas||0)}" style="width:100%;padding:5px;border:1px solid #e65100;border-radius:4px;text-align:right;font-weight:bold" onblur="this.value=fmtBR(this)" /></div>
|
||||
<div><label style="font-size:10px;color:#555">Saldo Esperado:</label><input type="text" id="edit-esperado" value="${fmtMR(full.saldo_esperado)}" style="width:100%;padding:5px;border:1px solid #e65100;border-radius:4px;text-align:right;font-weight:bold" onblur="this.value=fmtBR(this)" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Observações -->
|
||||
@@ -2939,6 +3048,8 @@ function openEditModal(full) {
|
||||
</div>`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
// Calcula totais iniciais após renderizar o DOM
|
||||
setTimeout(() => window._recalcEditTotals(), 50);
|
||||
}
|
||||
|
||||
// Formata campo de dinheiro brasileiro
|
||||
@@ -3125,6 +3236,11 @@ window.salvarEdicaoModal = async function() {
|
||||
total_pixcnpj: pixcnpj_tot,
|
||||
total_areceber: recv_tot,
|
||||
total_cancelamentos: canc_tot,
|
||||
total_cartao_pix: cartPix_tot,
|
||||
|
||||
// Diferença calculada
|
||||
diferenca: p(inp('edit-troco')) + cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot + pixcnpj_tot + vales_tot + recv_tot
|
||||
- p(inp('edit-esperado')) - canc_tot,
|
||||
|
||||
// Fechamento (campos calculados que o formato antigo usava no dados)
|
||||
fechamento_dinheiro: p(inp('edit-troco')) + vales_tot + sang_tot - desp_tot - canc_tot,
|
||||
|
||||
Reference in New Issue
Block a user