Compare commits
26 Commits
v1.4.2-fix
...
v1.8.2
| Author | SHA1 | Date | |
|---|---|---|---|
| cc45ed9df7 | |||
| 378a589572 | |||
| 50b0ba4498 | |||
| 7154901ce3 | |||
| 8b24a06496 | |||
| 3058908b37 | |||
| 9b1d45ae50 | |||
| fbed0e57c2 | |||
| 362a76961b | |||
| 7a3a4b221b | |||
| 94bb8840ea | |||
| dba7eb3856 | |||
| 7b3b7a9f1d | |||
| 5641de21f8 | |||
| d77ad55fbd | |||
| 4a5cae8f2f | |||
| 313c740470 | |||
| d21cb0a98d | |||
| 16bee1eacb | |||
| c8016f076d | |||
| b1a9f94231 | |||
| 42aadcca2c | |||
| a8319d96a6 | |||
| bf878545b3 | |||
| 22cda312cf | |||
| d112ad061e |
@@ -250,21 +250,44 @@ impl SupabaseClient {
|
|||||||
|
|
||||||
/// Atualiza campos específicos de um fechamento pelo id_fechamento.
|
/// Atualiza campos específicos de um fechamento pelo id_fechamento.
|
||||||
pub fn atualizar_fechamento(&self, id_fechamento: &str, updates: &serde_json::Value) -> Result<Value, SupabaseError> {
|
pub fn atualizar_fechamento(&self, id_fechamento: &str, updates: &serde_json::Value) -> Result<Value, SupabaseError> {
|
||||||
|
// Campos que o frontend envia mas NÃO existem como colunas na tabela.
|
||||||
|
// Arrays e objetos são guardados no JSONB `dados` — não em colunas escalar.
|
||||||
|
static BLOCKED: &[&str] = &[
|
||||||
|
"id", "uuid", "criado_em", "atualizado_em", "enviado_por",
|
||||||
|
"ip_origem", "user_agent", "id_fechamento",
|
||||||
|
// arrays e objetos que existem dentro do JSONB `dados`
|
||||||
|
"vales", "despesas", "sangrias", "cancelamentos",
|
||||||
|
"pixcnpj", "receber",
|
||||||
|
"cartoes_credito", "cartoes_debito",
|
||||||
|
"cartoes_alimentacao", "cartoes_pix",
|
||||||
|
];
|
||||||
|
|
||||||
|
let map = updates.as_object().cloned().unwrap_or_default();
|
||||||
|
|
||||||
|
// Remove campos bloqueados
|
||||||
|
let filtered: serde_json::Map<String, serde_json::Value> = map
|
||||||
|
.into_iter()
|
||||||
|
.filter(|(k, _)| !BLOCKED.contains(&k.as_str()))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if filtered.is_empty() {
|
||||||
|
return Err(SupabaseError::Api("Nenhum campo para atualizar".into()));
|
||||||
|
}
|
||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/rest/v1/fechamentos_web?id_fechamento=eq.{}",
|
"{}/rest/v1/fechamentos_web?id_fechamento=eq.{}",
|
||||||
self.base_url,
|
self.base_url,
|
||||||
urlencoding::encode(id_fechamento)
|
urlencoding::encode(id_fechamento)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Log do que está sendo enviado (debug)
|
log::info!("[PATCH] url={} body={:#?}", url, filtered);
|
||||||
log::info!("[PATCH] url={} body={}", url, updates);
|
|
||||||
|
|
||||||
let resp = self
|
let resp = self
|
||||||
.http
|
.http
|
||||||
.patch(&url)
|
.patch(&url)
|
||||||
.headers(self.headers(true))
|
.headers(self.headers(true))
|
||||||
.header("Prefer", "return=representation")
|
.header("Prefer", "return=representation")
|
||||||
.json(updates)
|
.json(&filtered)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
@@ -289,7 +312,7 @@ impl SupabaseClient {
|
|||||||
pub fn listar_recentes(&self, loja: &str, limite: i64) -> Result<Vec<Value>, SupabaseError> {
|
pub fn listar_recentes(&self, loja: &str, limite: i64) -> Result<Vec<Value>, SupabaseError> {
|
||||||
let loja_normalized = sem_acento(&loja.to_lowercase());
|
let loja_normalized = sem_acento(&loja.to_lowercase());
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/rest/v1/fechamentos_web?loja=eq.{}&order=data.desc,atualizado_em.desc&limit={}&select=id,id_fechamento,data,operador,turno,saldo_troco,saldo_esperado,fechamento_dinheiro,fechamento_cartoes,fechamento_areceber,diferenca,status_diferenca,observacoes,atualizado_em,dados",
|
"{}/rest/v1/fechamentos_web?loja=eq.{}&order=data.desc,atualizado_em.desc&limit={}&select=id,id_fechamento,data,operador,turno,saldo_troco,saldo_credito,saldo_debito,saldo_alimentacao,saldo_vales,saldo_areceber,saldo_esperado,total_pixcnpj,total_cartao_credito,total_cartao_debito,total_cartao_alimentacao,total_cartao_pix,total_cancelamentos,fechamento_dinheiro,fechamento_cartoes,fechamento_areceber,diferenca,status_diferenca,observacoes,atualizado_em,dados",
|
||||||
self.base_url,
|
self.base_url,
|
||||||
urlencoding::encode(&loja_normalized),
|
urlencoding::encode(&loja_normalized),
|
||||||
limite,
|
limite,
|
||||||
|
|||||||
+431
-121
@@ -543,7 +543,8 @@
|
|||||||
<div class="cfg-section">
|
<div class="cfg-section">
|
||||||
<div class="cfg-section-title">🔐 Senha Admin (editar dias anteriores)</div>
|
<div class="cfg-section-title">🔐 Senha Admin (editar dias anteriores)</div>
|
||||||
<div style="display:flex;gap:6px;margin-top:4px">
|
<div style="display:flex;gap:6px;margin-top:4px">
|
||||||
<input type="password" id="cfg-admin-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Deixe em branco se não quiser senha">
|
<input type="password" id="cfg-admin-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Senha fixa (ou deixe em branco)">
|
||||||
|
<input type="password" id="cfg-dynamic-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Dinâmica: 10+dia+mes (ex: 1217)">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -613,7 +614,7 @@ const fmt = v => 'R$ ' + (parseFloat(v) || 0).toLocaleString('pt-BR', { minimumF
|
|||||||
const parseNum = v => {
|
const parseNum = v => {
|
||||||
// Already a number? Return directly (don't treat '.' as thousand separator)
|
// Already a number? Return directly (don't treat '.' as thousand separator)
|
||||||
if (typeof v === 'number') return isNaN(v) ? 0 : v;
|
if (typeof v === 'number') return isNaN(v) ? 0 : v;
|
||||||
const s = String(v || '0').trim();
|
const s = String(v || '0').trim().replace(/^R\$\s*/, ''); // strip currency prefix first
|
||||||
if (!s) return 0;
|
if (!s) return 0;
|
||||||
// Brazilian format: 1.234,56 → 1234.56
|
// Brazilian format: 1.234,56 → 1234.56
|
||||||
// Strategy: if string has comma, treat as BRL (decimal comma)
|
// Strategy: if string has comma, treat as BRL (decimal comma)
|
||||||
@@ -1233,6 +1234,7 @@ function loadConfig() {
|
|||||||
}
|
}
|
||||||
function saveConfig() {
|
function saveConfig() {
|
||||||
config.admin_password = document.getElementById('cfg-admin-password').value.trim();
|
config.admin_password = document.getElementById('cfg-admin-password').value.trim();
|
||||||
|
config.dynamic_password = document.getElementById('cfg-dynamic-password').value.trim();
|
||||||
try { localStorage.setItem(CFG_KEY, JSON.stringify(config)); } catch(e) {}
|
try { localStorage.setItem(CFG_KEY, JSON.stringify(config)); } catch(e) {}
|
||||||
buildDatalists();
|
buildDatalists();
|
||||||
}
|
}
|
||||||
@@ -1246,6 +1248,7 @@ function openConfig() {
|
|||||||
renderCfgList('clientes', 'cfg-clientes-list');
|
renderCfgList('clientes', 'cfg-clientes-list');
|
||||||
renderCfgList('vales_nomes', 'cfg-vales-list');
|
renderCfgList('vales_nomes', 'cfg-vales-list');
|
||||||
document.getElementById('cfg-admin-password').value = config.admin_password || '';
|
document.getElementById('cfg-admin-password').value = config.admin_password || '';
|
||||||
|
document.getElementById('cfg-dynamic-password').value = config.dynamic_password || '';
|
||||||
}
|
}
|
||||||
function closeConfig() { document.getElementById('modal-config').classList.remove('open'); }
|
function closeConfig() { document.getElementById('modal-config').classList.remove('open'); }
|
||||||
function renderCfgList(key, containerId) {
|
function renderCfgList(key, containerId) {
|
||||||
@@ -1871,12 +1874,28 @@ function buildReciboData() {
|
|||||||
const valesTotal = estado.vales.reduce((s,r) => s+(parseNum(r.valor||0)||0), 0);
|
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 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 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
|
// 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
|
// Diferença = saldo de caixa (sistema) - saldo_esperado - cancelamentos
|
||||||
const diferenca = sysTotal - saldoEsp - cancelTotal;
|
const diferenca = sysTotal - saldoEsperado - cancelTotal;
|
||||||
return {
|
return {
|
||||||
uuid: estado.uuid,
|
uuid: estado.uuid,
|
||||||
id_local: estado.id_local,
|
id_local: estado.id_local,
|
||||||
@@ -1885,14 +1904,14 @@ function buildReciboData() {
|
|||||||
data: estado.data,
|
data: estado.data,
|
||||||
operador: estado.operador,
|
operador: estado.operador,
|
||||||
turno: estado.turno,
|
turno: estado.turno,
|
||||||
saldo_troco: parseNum(val('sys-troco')),
|
saldo_troco: saldoTroco,
|
||||||
saldo_esperado: saldoEsp,
|
saldo_esperado: saldoEsperado,
|
||||||
fechamento: fechamentoCounted,
|
fechamento: fechamentoCounted,
|
||||||
diferenca: diferenca,
|
diferenca: diferenca,
|
||||||
sys_total: sysTotal,
|
sys_total: sysTotal,
|
||||||
fechamento_dinheiro: parseNum(val('f-fech-dinheiro')),
|
fechamento_dinheiro: fechamentoDinheiro,
|
||||||
fechamento_cartoes: parseNum(val('f-fech-cartoes')),
|
fechamento_cartoes: fechamentoCartoes,
|
||||||
fechamento_receber: parseNum(val('f-fech-receber')),
|
fechamento_receber: fechamentoReceber,
|
||||||
// Flat totals for ReciboData struct (Rust) — must be numbers
|
// Flat totals for ReciboData struct (Rust) — must be numbers
|
||||||
credito: cartCred,
|
credito: cartCred,
|
||||||
debito: cartDeb,
|
debito: cartDeb,
|
||||||
@@ -2086,31 +2105,55 @@ document.getElementById('btn-recibo').addEventListener('click', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('btn-limpar').addEventListener('click', () => {
|
document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||||
if (!confirm('Limpar rascunho? Esta acção não pode ser revertida.')) return;
|
const overlay = document.createElement('div');
|
||||||
localStorage.removeItem(LS_KEY);
|
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
|
||||||
estado = {
|
overlay.id = 'clear-modal';
|
||||||
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
overlay.innerHTML = `
|
||||||
loja: estado.loja, data: estado.data, operador: '', turno: '',
|
<div style="background:#fff;border-radius:10px;padding:28px;width:340px;text-align:center">
|
||||||
saldo_troco: 0, fechamento: 0, saldo_esperado: 0, diferenca: 0,
|
<div style="font-size:20px;margin-bottom:12px">⚠️ Limpar Rascunho</div>
|
||||||
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
<div style="font-size:13px;color:#555;margin-bottom:20px;line-height:1.5">Tem certeza?<br>Irá <strong>apagar todas as informações</strong> lançadas para iniciar uma nova.</div>
|
||||||
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
<div style="display:flex;gap:10px;justify-content:center">
|
||||||
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
<button id="clear-cancel-btn" style="padding:9px 20px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">Cancelar</button>
|
||||||
observacoes: '', id_local: null, sync_status: 'local'
|
<button id="clear-ok-btn" style="padding:9px 20px;background:#c0272d;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">Apagar tudo</button>
|
||||||
};
|
</div>
|
||||||
setVal('f-operador', ''); setVal('f-turno', '');
|
</div>`;
|
||||||
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
document.body.appendChild(overlay);
|
||||||
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
document.getElementById('clear-cancel-btn').addEventListener('click', () => overlay.remove());
|
||||||
setVal('sys-troco', '');
|
document.getElementById('clear-ok-btn').addEventListener('click', () => {
|
||||||
updateTotals();
|
overlay.remove();
|
||||||
renderAllTables();
|
localStorage.removeItem(LS_KEY);
|
||||||
syncUI();
|
estado = {
|
||||||
showToast('Rascunho limpo.', 'info');
|
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
||||||
|
loja: estado.loja, data: estado.data, operador: '', turno: '',
|
||||||
|
saldo_troco: 0, fechamento: 0, saldo_esperado: 0, diferenca: 0,
|
||||||
|
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
||||||
|
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
||||||
|
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
||||||
|
observacoes: '', id_local: null, sync_status: 'local'
|
||||||
|
};
|
||||||
|
estado.sangrias = []; estado.despesas = []; estado.pixcnpj = [];
|
||||||
|
estado.vales = []; estado.receber = []; estado.cancelamentos = [];
|
||||||
|
estado.cartoes = { credito: [], debito: [], alimentacao: [], pix: [] };
|
||||||
|
estado.fechamento_contado = { dinheiro: 0, cartoes: 0, receber: 0 };
|
||||||
|
setVal('f-operador', ''); setVal('f-turno', '');
|
||||||
|
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
||||||
|
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
||||||
|
setVal('f-vendas', ''); setVal('f-clientes', ''); setVal('f-frango', '');
|
||||||
|
setVal('sys-troco', ''); setVal('sys-total', '');
|
||||||
|
setVal('sys-credito', ''); setVal('sys-debito', '');
|
||||||
|
setVal('sys-alimentacao', ''); setVal('sys-pixcnpj', '');
|
||||||
|
Object.keys(TABLES).forEach(renderTable);
|
||||||
|
updateTotals();
|
||||||
|
syncUI();
|
||||||
|
showToast('Rascunho limpo.', 'info');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ─── Dia Anterior — seleção + consulta + edição de registros do Supabase ───
|
// ─── Dia Anterior — seleção + consulta + edição de registros do Supabase ───
|
||||||
const btnAnterior = document.getElementById('btn-anterior');
|
const btnAnterior = document.getElementById('btn-anterior');
|
||||||
if (btnAnterior) {
|
if (btnAnterior) {
|
||||||
btnAnterior.addEventListener('click', async () => {
|
btnAnterior.addEventListener('click', async () => {
|
||||||
|
if (!await askPassword()) return;
|
||||||
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
||||||
|
|
||||||
let recentList = [];
|
let recentList = [];
|
||||||
@@ -2151,11 +2194,6 @@ function buildConsultaModal(recentList) {
|
|||||||
return `${day}/${m}/${y}`;
|
return `${day}/${m}/${y}`;
|
||||||
};
|
};
|
||||||
const fmtMoney = v => v != null ? `R$ ${parseFloat(v).toFixed(2).replace('.', ',')}` : 'R$ 0,00';
|
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 => {
|
const statusBadge = s => {
|
||||||
if (s === 'ok') return '<span style="color:#2e7d32;font-weight:bold">✓ OK</span>';
|
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>';
|
if (s === 'sobrando') return '<span style="color:#e65100;font-weight:bold">⚠ SOBRANDO</span>';
|
||||||
@@ -2163,49 +2201,136 @@ function buildConsultaModal(recentList) {
|
|||||||
return s || '?';
|
return s || '?';
|
||||||
};
|
};
|
||||||
|
|
||||||
const rows = recentList.map((item, i) => {
|
// Calcula saldo de caixa real (mesma fórmula do relatório)
|
||||||
const total = (parseFloat(item.fechamento_dinheiro)||0) + (parseFloat(item.fechamento_cartoes)||0) + (parseFloat(item.fechamento_areceber)||0);
|
// SALDO CAIXA = soma dos campos individuais (total do sistema no relatório)
|
||||||
return `<tr>
|
// Lê do top-level E do JSON dados (compatibilidade com registros antigos)
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtDate(item.data)}</td>
|
// SALDO CAIXA = soma dos campos individuais (total do sistema no relatório)
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${item.operador||'?'}</td>
|
// Prioriza top-level, só usa dados.dados se top-level for 0/missing (compat old records)
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${item.turno||'?'}</td>
|
const f = (item, dados, field) => parseFloat(item[field]||dados[field]||0);
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtMoney(total)}</td>
|
const calcSaldoCaixa = item => {
|
||||||
<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>
|
const dados = item.dados || {};
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${statusBadge(item.status_diferenca)}</td>
|
return f(item,dados,'saldo_troco')
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${i})">${syncBadge(item.sync_status)}</td>
|
+ f(item,dados,'saldo_credito')
|
||||||
<td style="padding:4px 6px;border-bottom:1px solid #eee;text-align:center">
|
+ f(item,dados,'saldo_debito')
|
||||||
<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>
|
+ f(item,dados,'saldo_alimentacao')
|
||||||
</td>
|
+ f(item,dados,'saldo_vales')
|
||||||
</tr>`;
|
+ f(item,dados,'saldo_areceber')
|
||||||
}).join('');
|
+ f(item,dados,'total_pixcnpj')
|
||||||
|
+ f(item,dados,'total_cartao_pix');
|
||||||
|
};
|
||||||
|
const calcCancelamentos = item => {
|
||||||
|
const dados = item.dados || {};
|
||||||
|
return (parseFloat(item.total_cancelamentos)||0)
|
||||||
|
+ (parseFloat(dados.total_cancelamentos)||0)
|
||||||
|
+ (parseFloat(dados.cancelamentos)||0); // old format: array of cancelamentos
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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="8" 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 canc = calcCancelamentos(item);
|
||||||
|
const diff = saldoCaixa - (parseFloat(item.saldo_esperado)||0) - canc;
|
||||||
|
const diffClass = Math.abs(diff) <= 4.50 ? '#2e7d32' : diff > 0 ? '#e65100' : '#c0272d';
|
||||||
|
const diffLabel = Math.abs(diff) <= 4.50 ? `✓ OK (${diff===0?'0':(diff>0?'+':'-')+Math.abs(diff).toFixed(2).replace('.',',')})` : diff > 0 ? `+R$ ${diff.toFixed(2).replace('.',',')} SOBRANDO` : `-R$ ${Math.abs(diff).toFixed(2).replace('.',',')} FALTANDO`;
|
||||||
|
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:right;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${fmtMoney(canc)}</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 = `
|
overlay.innerHTML = `
|
||||||
<div style="background:#fff;border-radius:10px;padding:20px;max-width:780px;width:95%;max-height:85vh;overflow-y:auto">
|
<div style="background:#fff;border-radius:10px;padding:20px;max-width:900px;width:95%;max-height:85vh;overflow-y:auto">
|
||||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
|
<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 Anteriores</h2>
|
<h2 style="margin:0;font-size:16px">📅 Consultar Fechamentos</h2>
|
||||||
<button onclick="closeConsultaModal()" style="background:none;border:none;font-size:18px;cursor:pointer">✕</button>
|
<div style="display:flex;gap:6px;align-items:center;flex-wrap:wrap">
|
||||||
|
<span style="font-size:12px;color:#555">De:</span>
|
||||||
|
<input type="date" id="consulta-busca-de" value="" max="${ultimoDia}" style="padding:6px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px" />
|
||||||
|
<span style="font-size:12px;color:#555">Até:</span>
|
||||||
|
<input type="date" id="consulta-busca-ate" value="" max="${ultimoDia}" style="padding:6px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px" />
|
||||||
|
<select id="consulta-busca-turno" style="padding:6px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px;background:#fff">
|
||||||
|
<option value="">Todos turnos</option>
|
||||||
|
<option value="manha">Manhã</option>
|
||||||
|
<option value="tarde">Tarde</option>
|
||||||
|
<option value="integral">Integral</option>
|
||||||
|
</select>
|
||||||
|
<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">Mostrando últimos 5 dias</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:right;font-size:11px;color:#888">CANCEL.</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>
|
</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">FECHAMENTO</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>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.body.appendChild(overlay);
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
// Função de busca por período
|
||||||
|
window._filtrarConsulta = () => {
|
||||||
|
const de = document.getElementById('consulta-busca-de')?.value;
|
||||||
|
const ate = document.getElementById('consulta-busca-ate')?.value;
|
||||||
|
const turno = document.getElementById('consulta-busca-turno')?.value || '';
|
||||||
|
const tbody = document.getElementById('consulta-tbody');
|
||||||
|
const info = document.getElementById('consulta-info');
|
||||||
|
if (!tbody) return;
|
||||||
|
let filtrados = [...recentList];
|
||||||
|
if (de) filtrados = filtrados.filter(item => item.data >= de);
|
||||||
|
if (ate) filtrados = filtrados.filter(item => item.data <= ate);
|
||||||
|
if (turno) filtrados = filtrados.filter(item => (item.turno||'').toLowerCase() === turno);
|
||||||
|
if (de || ate || turno) {
|
||||||
|
tbody.innerHTML = renderRows(filtrados);
|
||||||
|
const label = `${filtrados.length} registro${filtrados.length!==1?'s':''}${de&&ate?` de ${fmtDate(de)} a ${fmtDate(ate)}`:de?` a partir de ${fmtDate(de)}`:ate?` até ${fmtDate(ate)}`:''}`;
|
||||||
|
if (info) info.textContent = label;
|
||||||
|
} else {
|
||||||
|
tbody.innerHTML = renderRows(cincoDias);
|
||||||
|
if (info) info.textContent = 'Mostrando últimos 5 dias';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Enter na busca
|
||||||
|
['consulta-busca-de','consulta-busca-ate'].forEach(id => {
|
||||||
|
document.getElementById(id)?.addEventListener('keydown', e => { if (e.key === 'Enter') window._filtrarConsulta(); });
|
||||||
|
});
|
||||||
|
|
||||||
window._recentList = recentList;
|
window._recentList = recentList;
|
||||||
|
window._consultaAll = recentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abre a janela de edição completa de um registro pelo índice na lista
|
// Abre a janela de edição completa de um registro pelo índice na lista
|
||||||
@@ -2523,25 +2648,26 @@ window.toggleEditConsulta = async function() {
|
|||||||
// Se já está editando, apenas fecha
|
// Se já está editando, apenas fecha
|
||||||
if (window._editModalOpen) { closeEditModal(); return; }
|
if (window._editModalOpen) { closeEditModal(); return; }
|
||||||
|
|
||||||
// Pede senha admin primeiro — sempre, para proteger edições
|
// Pede senha — sempre, uma vez (aceita fixa ou dinâmica)
|
||||||
const pw = config.admin_password;
|
if (!await askPassword()) return;
|
||||||
if (pw) {
|
|
||||||
const ok = await askPassword();
|
|
||||||
if (!ok) return;
|
|
||||||
} else {
|
|
||||||
// Sem senha configurada — avisa e abre mesmo assim (primeiro uso)
|
|
||||||
const ok = await askPassword(); // mostra diálogo vazio para o admin configurar mentalmente
|
|
||||||
if (!ok) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
openEditModal(full);
|
openEditModal(full);
|
||||||
closeRelatorioModal();
|
closeRelatorioModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pede senha admin — retorna Promise<boolean>
|
// Calcula senha dinâmica do dia: dia e mês como 2 dígitos cada, concatenados
|
||||||
|
// ex: 17/12 → "1712"
|
||||||
|
function getDynamicPw() {
|
||||||
|
const d = new Date();
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||||
|
return day + month;
|
||||||
|
}
|
||||||
|
|
||||||
function askPassword() {
|
function askPassword() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const pw = config.admin_password;
|
const fixedPw = config.admin_password;
|
||||||
|
const dynPw = getDynamicPw();
|
||||||
const overlay = document.createElement('div');
|
const overlay = document.createElement('div');
|
||||||
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
|
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
|
||||||
overlay.id = 'pw-modal';
|
overlay.id = 'pw-modal';
|
||||||
@@ -2566,7 +2692,7 @@ function askPassword() {
|
|||||||
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
||||||
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
||||||
const val = document.getElementById('pw-input').value;
|
const val = document.getElementById('pw-input').value;
|
||||||
if (val === pw) {
|
if (val === fixedPw || val === dynPw) {
|
||||||
document.getElementById('pw-modal').remove();
|
document.getElementById('pw-modal').remove();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -2693,7 +2819,35 @@ window._recalcEditTotals = function() {
|
|||||||
if (el('tot-areceber')) el('tot-areceber').textContent = fmtTot(recv_tot);
|
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-sangrias')) el('tot-sangrias').textContent = fmtTot(sang_tot);
|
||||||
if (el('tot-despesas')) el('tot-despesas').textContent = fmtTot(desp_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
|
// Modal de edição completo com todas as grades
|
||||||
@@ -2707,7 +2861,8 @@ function openEditModal(full) {
|
|||||||
// helper para fmt dinheiro
|
// helper para fmt dinheiro
|
||||||
const fmtMR = v => {
|
const fmtMR = v => {
|
||||||
const n = parseFloat(v||0);
|
const n = parseFloat(v||0);
|
||||||
if (isNaN(n) || n === 0) return '';
|
if (isNaN(n)) return '';
|
||||||
|
if (n === 0) return 'R$ 0,00';
|
||||||
return 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
return 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2754,20 +2909,32 @@ function openEditModal(full) {
|
|||||||
const receber_rows = (dados.receber || []).map(r => [r.nome||'', r.valor||0]);
|
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]);
|
const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]);
|
||||||
|
|
||||||
// --- Totais (só leitura formatado) ---
|
// --- Totais (só leitura formatado) — calcula dos dados reais ---
|
||||||
const totaisInfo = `
|
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 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 Crédito:</strong> <span id="edit-total-credito">${fmtMR(calcCred)}</span></div>
|
||||||
<div><strong>Total Débito:</strong> <span id="edit-total-debito">${fmtMR(full.total_cartao_debito||0)}</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(full.total_cartao_alimentacao||0)}</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(full.total_cartao_pix||0)}</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(full.total_sangrias||0)}</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(full.total_despesas||0)}</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(full.total_vales||0)}</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(full.total_pixcnpj||0)}</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(full.total_areceber||0)}</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(full.total_cancelamentos||0)}</span></div>
|
<div><strong>Total Cancel:</strong> <span id="edit-total-cancel">${fmtMR(calcCanc)}</span></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
})();
|
||||||
|
|
||||||
const overlay = document.createElement('div');
|
const overlay = document.createElement('div');
|
||||||
overlay.id = 'modal-edit';
|
overlay.id = 'modal-edit';
|
||||||
@@ -2899,7 +3066,8 @@ function openEditModal(full) {
|
|||||||
<div style="margin-bottom:12px;background:#f5f5f5;border-radius:6px;padding:8px">
|
<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>
|
<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 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">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">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>
|
<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>
|
||||||
@@ -2908,14 +3076,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">À 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><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>
|
||||||
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- Contadores -->
|
<!-- 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">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">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">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>
|
</div>
|
||||||
|
|
||||||
<!-- Observações -->
|
<!-- Observações -->
|
||||||
@@ -2931,12 +3108,15 @@ function openEditModal(full) {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
document.body.appendChild(overlay);
|
document.body.appendChild(overlay);
|
||||||
|
// Calcula totais iniciais após renderizar o DOM
|
||||||
|
setTimeout(() => window._recalcEditTotals(), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formata campo de dinheiro brasileiro
|
// Formata campo de dinheiro brasileiro
|
||||||
function fmtBR(inp) {
|
function fmtBR(inp) {
|
||||||
const v = parseNum(inp.value);
|
const v = parseNum(inp.value);
|
||||||
if (isNaN(v) || v === 0) return '';
|
if (isNaN(v)) return '';
|
||||||
|
if (v === 0) return 'R$ 0,00';
|
||||||
return 'R$ ' + v.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
return 'R$ ' + v.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2957,6 +3137,81 @@ window.abrirEditaFechamento = async function(full) {
|
|||||||
if (!full.id_fechamento && full.loja && full.data && full.operador) {
|
if (!full.id_fechamento && full.loja && full.data && full.operador) {
|
||||||
full.id_fechamento = (full.loja + '_' + full.data + '_' + full.operador).toLowerCase().replace(/ /g, '_');
|
full.id_fechamento = (full.loja + '_' + full.data + '_' + full.operador).toLowerCase().replace(/ /g, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Atualiza estado com o registro carregado para que buildReciboData funcione corretamente
|
||||||
|
const dados = full.dados || {};
|
||||||
|
estado = {
|
||||||
|
uuid: full.uuid || crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
||||||
|
id_local: full.id_local || null,
|
||||||
|
id: full.id || null,
|
||||||
|
loja: full.loja || estado.loja,
|
||||||
|
data: full.data || estado.data,
|
||||||
|
operador: full.operador || '',
|
||||||
|
turno: full.turno || 'manha',
|
||||||
|
saldo_troco: parseNum(full.saldo_troco || 0),
|
||||||
|
fechamento: parseNum(full.fechamento_dinheiro || 0) + parseNum(full.fechamento_cartoes || 0) + parseNum(full.fechamento_areceber || 0),
|
||||||
|
saldo_esperado: parseNum(full.saldo_esperado || 0),
|
||||||
|
diferenca: parseNum(full.diferenca || 0),
|
||||||
|
clientes: parseInt(full.clientes || 0),
|
||||||
|
frango: parseInt(full.frango || 0),
|
||||||
|
vendas: parseNum(full.vendas || 0),
|
||||||
|
observacoes: full.observacoes || '',
|
||||||
|
sync_status: full.sync_status || 'synced',
|
||||||
|
// Cartões
|
||||||
|
cartoes: {
|
||||||
|
credito: (dados.cartoes?.credito || full.cartoes_credito || []).map(v => ({ valor: parseNum(v) || 0 })),
|
||||||
|
debito: (dados.cartoes?.debito || full.cartoes_debito || []).map(v => ({ valor: parseNum(v) || 0 })),
|
||||||
|
alimentacao: (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).map(v => ({ valor: parseNum(v) || 0 })),
|
||||||
|
pix: (dados.cartoes?.pix || full.cartoes_pix || []).map(v => ({ valor: parseNum(v) || 0 })),
|
||||||
|
},
|
||||||
|
// Demais arrays
|
||||||
|
vales: (dados.vales || full.vales || []).map(r => ({ nome: r.nome||'', valor: parseNum(r.valor)||0, obs: r.obs||'' })),
|
||||||
|
despesas: (dados.despesas || full.despesas || []).map(r => ({ desc: r.desc||'', obs: r.obs||'', valor: parseNum(r.valor)||0 })),
|
||||||
|
sangrias: (dados.sangrias || full.sangrias || []).map(r => ({ hora: r.hora||'', retirada: parseNum(r.retirada||r.valor)||0, gerente: r.gerente||'' })),
|
||||||
|
cancelamentos: (dados.cancelamentos || full.cancelamentos || []).map(r => ({ numero: r.numero||'', valor: parseNum(r.valor)||0, motivo: r.motivo||'' })),
|
||||||
|
pixcnpj: (dados.pixcnpj || full.pixcnpj || []).map(r => ({ nome: r.nome||'', valor: parseNum(r.valor)||0 })),
|
||||||
|
receber: (dados.receber || full.receber || []).map(r => ({ nome: r.nome||'', valor: parseNum(r.valor)||0 })),
|
||||||
|
fechamento_contado: {
|
||||||
|
dinheiro: parseNum(full.fechamento_dinheiro || 0),
|
||||||
|
cartoes: parseNum(full.fechamento_cartoes || 0),
|
||||||
|
receber: parseNum(full.fechamento_areceber || 0),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Preenche os campos do formulário principal para que o botão Recibo funcione
|
||||||
|
setVal('sys-troco', fmtNum(estado.saldo_troco));
|
||||||
|
setVal('sys-credito', fmtNum(estado.saldo_credito));
|
||||||
|
setVal('sys-debito', fmtNum(estado.saldo_debito));
|
||||||
|
setVal('sys-alimentacao', fmtNum(estado.saldo_alimentacao));
|
||||||
|
setVal('sys-pixcnpj', fmtNum(estado.total_pixcnpj));
|
||||||
|
setVal('f-saldo-esperado', estado.saldo_esperado || '');
|
||||||
|
setVal('f-obs', estado.observacoes || '');
|
||||||
|
setVal('f-operador', estado.operador || '');
|
||||||
|
setVal('f-turno', estado.turno || '');
|
||||||
|
setVal('f-clientes', estado.clientes || '');
|
||||||
|
setVal('f-frango', estado.frango || '');
|
||||||
|
setVal('f-vendas', estado.vendas || '');
|
||||||
|
setVal('f-loja', estado.loja || '');
|
||||||
|
setVal('f-data', estado.data || '');
|
||||||
|
setVal('f-fech-dinheiro', estado.fechamento_contado?.dinheiro || '');
|
||||||
|
setVal('f-fech-cartoes', estado.fechamento_contado?.cartoes || '');
|
||||||
|
setVal('f-fech-receber', estado.fechamento_contado?.receber || '');
|
||||||
|
|
||||||
|
// Renderiza todas as grades
|
||||||
|
renderTable('tbl-sangrias', estado.sangrias);
|
||||||
|
renderTable('tbl-despesas', estado.despesas);
|
||||||
|
renderTable('tbl-vales', estado.vales);
|
||||||
|
renderTable('tbl-pix', estado.pixcnpj);
|
||||||
|
renderTable('tbl-receber', estado.receber);
|
||||||
|
renderTable('tbl-cancelamentos', estado.cancelamentos);
|
||||||
|
renderTable('tbl-cartao-credito', estado.cartoes.credito);
|
||||||
|
renderTable('tbl-cartao-debito', estado.cartoes.debito);
|
||||||
|
renderTable('tbl-cartao-alimentacao',estado.cartoes.alimentacao);
|
||||||
|
renderTable('tbl-cartao-pix', estado.cartoes.pix);
|
||||||
|
|
||||||
|
// Atualiza totais
|
||||||
|
updateTotals();
|
||||||
|
|
||||||
// Usa o mesmo modal de edição completo que já funciona — só abre com o registro
|
// Usa o mesmo modal de edição completo que já funciona — só abre com o registro
|
||||||
openEditModal(full);
|
openEditModal(full);
|
||||||
};
|
};
|
||||||
@@ -3032,23 +3287,76 @@ window.salvarEdicaoModal = async function() {
|
|||||||
saldo_debito: cartDeb_tot,
|
saldo_debito: cartDeb_tot,
|
||||||
saldo_alimentacao: cartAli_tot,
|
saldo_alimentacao: cartAli_tot,
|
||||||
saldo_vales: vales_tot,
|
saldo_vales: vales_tot,
|
||||||
total_pixcnpj: pixcnpj_tot,
|
|
||||||
saldo_areceber: recv_tot,
|
saldo_areceber: recv_tot,
|
||||||
|
|
||||||
// Totais
|
// Totais
|
||||||
total_vales: vales_tot,
|
total_vales: vales_tot,
|
||||||
total_despesas: desp_tot,
|
total_despesas: desp_tot,
|
||||||
total_sangrias: sang_tot,
|
total_sangrias: sang_tot,
|
||||||
total_areceber: recv_tot,
|
total_pixcnpj: pixcnpj_tot,
|
||||||
|
total_areceber: recv_tot,
|
||||||
total_cancelamentos: canc_tot,
|
total_cancelamentos: canc_tot,
|
||||||
|
total_cartao_pix: cartPix_tot,
|
||||||
|
|
||||||
// Lançamentos detalhados
|
// Diferença calculada
|
||||||
vales: vales,
|
diferenca: p(inp('edit-troco')) + cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot + pixcnpj_tot + vales_tot + recv_tot
|
||||||
despesas: despesas,
|
- p(inp('edit-esperado')) - canc_tot,
|
||||||
sangrias: sangrias,
|
|
||||||
cancelamentos: cancelamentos,
|
// Fechamento (campos calculados que o formato antigo usava no dados)
|
||||||
pixcnpj: pixcnpj,
|
fechamento_dinheiro: p(inp('edit-troco')) + vales_tot + sang_tot - desp_tot - canc_tot,
|
||||||
receber: receber,
|
fechamento_cartoes: cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot,
|
||||||
|
fechamento_areceber: recv_tot,
|
||||||
|
|
||||||
|
// Lançamentos detalhados (JSONB — gravados no campo `dados`)
|
||||||
|
// Merge completo com dados existentes para preservar campos antigos (fc, fd, fr,
|
||||||
|
// uuid, id_local, sync_status, fechamento, etc.) e sobrepor com valores atuais.
|
||||||
|
dados: (() => {
|
||||||
|
const existing = full.dados;
|
||||||
|
const base = {
|
||||||
|
cartoes,
|
||||||
|
vales,
|
||||||
|
despesas,
|
||||||
|
sangrias,
|
||||||
|
cancelamentos,
|
||||||
|
pixcnpj,
|
||||||
|
receber,
|
||||||
|
clientes: parseInt(inp('edit-clientes') || '0'),
|
||||||
|
frango: parseInt(inp('edit-frango') || '0'),
|
||||||
|
vendas: p(inp('edit-vendas')),
|
||||||
|
// Campos que o formato antigo gravava no dados
|
||||||
|
credito: cartCred_tot,
|
||||||
|
debito: cartDeb_tot,
|
||||||
|
alimentacao: cartAli_tot,
|
||||||
|
fc: cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot,
|
||||||
|
fd: sang_tot,
|
||||||
|
fr: vales_tot,
|
||||||
|
fechamento: p(inp('edit-troco')) + vales_tot + sang_tot - desp_tot - canc_tot,
|
||||||
|
saldo_troco: p(inp('edit-troco')),
|
||||||
|
total_vales: vales_tot,
|
||||||
|
total_despesas: desp_tot,
|
||||||
|
total_sangrias: sang_tot,
|
||||||
|
total_pixcnpj: pixcnpj_tot,
|
||||||
|
total_areceber: recv_tot,
|
||||||
|
total_cancelamentos: canc_tot,
|
||||||
|
total_cartao_credito: cartCred_tot,
|
||||||
|
total_cartao_debito: cartDeb_tot,
|
||||||
|
total_cartao_alimentacao: cartAli_tot,
|
||||||
|
total_cartao_pix: cartPix_tot,
|
||||||
|
saldo_esperado: p(inp('edit-esperado')),
|
||||||
|
observacoes: inp('edit-obs') || '',
|
||||||
|
data: inp('edit-data') || full.data || '',
|
||||||
|
loja: inp('edit-loja') || full.loja || '',
|
||||||
|
turno: inp('edit-turno') || full.turno || '',
|
||||||
|
operador: inp('edit-operador') || full.operador || '',
|
||||||
|
};
|
||||||
|
if (typeof existing === 'string') {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(existing);
|
||||||
|
return { ...parsed, ...base };
|
||||||
|
} catch { return base; }
|
||||||
|
}
|
||||||
|
return { ...(existing || {}), ...base };
|
||||||
|
})(),
|
||||||
|
|
||||||
// Contadores
|
// Contadores
|
||||||
clientes: parseInt(inp('edit-clientes') || '0'),
|
clientes: parseInt(inp('edit-clientes') || '0'),
|
||||||
@@ -3113,7 +3421,9 @@ window.salvarEdicaoConsulta = async function() {
|
|||||||
frango: parseInt(inp('edit-frango') || '0'),
|
frango: parseInt(inp('edit-frango') || '0'),
|
||||||
vendas: p(inp('edit-vendas')),
|
vendas: p(inp('edit-vendas')),
|
||||||
saldo_esperado: p(inp('edit-esperado')),
|
saldo_esperado: p(inp('edit-esperado')),
|
||||||
observacoes: inp('edit-obs')
|
observacoes: inp('edit-obs'),
|
||||||
|
edited_at: new Date().toISOString(),
|
||||||
|
edited_by: full.operador || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
||||||
@@ -3240,26 +3550,26 @@ window.printRelatorio = function() {
|
|||||||
<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: 14px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
body { font-family: 'Courier New', monospace; font-size: 18px; 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: 20px; font-weight: bold; }
|
.header h1 { font-size: 24px; font-weight: bold; }
|
||||||
.header h2 { font-size: 15px; font-weight: normal; }
|
.header h2 { font-size: 18px; font-weight: normal; }
|
||||||
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
||||||
.section-title { font-weight: bold; font-size: 14px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
.section-title { font-weight: bold; font-size: 17px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||||
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 13px; font-weight: bold; }
|
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 16px; font-weight: bold; }
|
||||||
.row.total-row { font-weight: bold; }
|
.row.total-row { font-weight: bold; }
|
||||||
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; font-weight: bold; }
|
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 16px; margin-top: 4px; font-weight: bold; }
|
||||||
.cart-table th { font-weight: bold; border-bottom: 2px solid #000; padding: 2px; width: 25%; }
|
.cart-table th { font-weight: bold; border-bottom: 2px solid #000; padding: 2px; width: 25%; }
|
||||||
.cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
|
.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: 2px solid #000; }
|
.cart-table tr.total-row { font-weight: bold; border-top: 2px solid #000; }
|
||||||
.subtotal { font-size: 13px; margin-top: 4px; }
|
.subtotal { font-size: 16px; margin-top: 4px; }
|
||||||
.subtotal .row { padding: 2px 0; }
|
.subtotal .row { padding: 2px 0; }
|
||||||
.diff-ok { color: #2e7d32; font-weight: bold; }
|
.diff-ok { color: #2e7d32; font-weight: bold; }
|
||||||
.diff-bad { color: #c0272d; font-weight: bold; }
|
.diff-bad { color: #c0272d; font-weight: bold; }
|
||||||
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
.obs { font-size: 13px; 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: 13px; color: #555; margin-top: 8px; }
|
||||||
@media print { body { background: #fff; font-weight: bold !important; } }
|
@media print { body { background: #fff; font-weight: bold !important; font-size: 18px !important; } }
|
||||||
</style>
|
</style>
|
||||||
</head><body>
|
</head><body>
|
||||||
${buildPrintHTML(data)}
|
${buildPrintHTML(data)}
|
||||||
|
|||||||
Reference in New Issue
Block a user