Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e4340adca | |||
| c01133f39c | |||
| a6b295a6d0 | |||
| f850831e98 | |||
| e70f31e00f | |||
| 79e1dbd645 | |||
| cce8f3df60 | |||
| 318d44e934 |
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"identifier": "default",
|
||||
"description": "Default capabilities for Fechamento de Caixa",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"shell:allow-open",
|
||||
"dialog:allow-message",
|
||||
"dialog:allow-confirm",
|
||||
"dialog:allow-ask",
|
||||
"dialog:allow-save",
|
||||
"dialog:allow-open",
|
||||
"fs:default",
|
||||
"fs:allow-app-read",
|
||||
"fs:allow-app-write",
|
||||
"fs:allow-appdata-read",
|
||||
"fs:allow-appdata-write",
|
||||
"fs:allow-appconfig-read",
|
||||
"fs:allow-appconfig-write",
|
||||
"fs:allow-applocaldata-read",
|
||||
"fs:allow-applocaldata-write"
|
||||
]
|
||||
}
|
||||
@@ -156,9 +156,10 @@ impl ReciboData {
|
||||
out.extend(escpos::divider());
|
||||
|
||||
// ── SANGRIAS ──
|
||||
if !self.sangrias_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("SANGRIAS"));
|
||||
for linha in &self.sangrias_arr {
|
||||
if linha.retirada.is_some() || linha.valor.is_some() {
|
||||
if linha.retirada.unwrap_or(0.0) > 0.0 || linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let label = linha.label();
|
||||
let obs = linha.obs();
|
||||
out.extend(escpos::kv(&label, &linha.fmt_v()));
|
||||
@@ -167,13 +168,21 @@ impl ReciboData {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Total sangrias
|
||||
let total_sangrias: f64 = self.sangrias_arr.iter()
|
||||
.map(|l| l.retirada.unwrap_or(0.0) + l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
if total_sangrias > 0.0 {
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_sangrias)));
|
||||
}
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
// ── DESPESAS ──
|
||||
if !self.despesas_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("DESPESAS"));
|
||||
for linha in &self.despesas_arr {
|
||||
if linha.valor.is_some() {
|
||||
if linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let label = linha.label();
|
||||
let obs = linha.obs();
|
||||
out.extend(escpos::kv(&label, &linha.fmt_v()));
|
||||
@@ -182,18 +191,30 @@ impl ReciboData {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Total despesas
|
||||
let total_despesas: f64 = self.despesas_arr.iter()
|
||||
.map(|l| l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_despesas)));
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
// ── PIX CNPJ ──
|
||||
if !self.pixcnpj_arr.is_empty() || self.pixcnpj > 0.0 {
|
||||
if !self.pixcnpj_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("PIX CNPJ"));
|
||||
for linha in &self.pixcnpj_arr {
|
||||
if linha.valor.is_some() {
|
||||
if linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let label = linha.nome.clone().unwrap_or_else(|| "PIX CNPJ".to_string());
|
||||
out.extend(escpos::kv(&label, &linha.fmt_v()));
|
||||
}
|
||||
}
|
||||
// Total PIX CNPJ
|
||||
let total_pixcnpj: f64 = self.pixcnpj_arr.iter()
|
||||
.map(|l| l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
if total_pixcnpj > 0.0 {
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_pixcnpj)));
|
||||
}
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
@@ -201,7 +222,7 @@ impl ReciboData {
|
||||
if !self.vales_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("VALES"));
|
||||
for linha in &self.vales_arr {
|
||||
if linha.valor.is_some() {
|
||||
if linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let label = linha.label();
|
||||
let obs = linha.obs();
|
||||
out.extend(escpos::kv(&label, &linha.fmt_v()));
|
||||
@@ -210,6 +231,13 @@ impl ReciboData {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Total vales
|
||||
let total_vales: f64 = self.vales_arr.iter()
|
||||
.map(|l| l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
if total_vales > 0.0 {
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_vales)));
|
||||
}
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
@@ -217,11 +245,18 @@ impl ReciboData {
|
||||
if !self.receber_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("A RECEBER"));
|
||||
for linha in &self.receber_arr {
|
||||
if linha.valor.is_some() {
|
||||
if linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let label = linha.label();
|
||||
out.extend(escpos::kv(&label, &linha.fmt_v()));
|
||||
}
|
||||
}
|
||||
// Total a receber
|
||||
let total_receber: f64 = self.receber_arr.iter()
|
||||
.map(|l| l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
if total_receber > 0.0 {
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_receber)));
|
||||
}
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
@@ -229,7 +264,7 @@ impl ReciboData {
|
||||
if !self.cancelamentos_arr.is_empty() {
|
||||
out.extend(escpos::line_bold("CANCELAMENTOS"));
|
||||
for linha in &self.cancelamentos_arr {
|
||||
if linha.valor.is_some() {
|
||||
if linha.numero.is_some() || linha.valor.unwrap_or(0.0) > 0.0 {
|
||||
let num = linha.numero.clone().unwrap_or_default();
|
||||
out.extend(escpos::kv(&num, &linha.fmt_v()));
|
||||
if let Some(ref m) = linha.motivo {
|
||||
@@ -239,6 +274,13 @@ impl ReciboData {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Total cancelamentos
|
||||
let total_cancel: f64 = self.cancelamentos_arr.iter()
|
||||
.map(|l| l.valor.unwrap_or(0.0))
|
||||
.sum();
|
||||
if total_cancel > 0.0 {
|
||||
out.extend(escpos::kv("Total:", &self.fmt_money(total_cancel)));
|
||||
}
|
||||
out.extend(escpos::divider());
|
||||
}
|
||||
|
||||
@@ -277,7 +319,7 @@ impl ReciboData {
|
||||
|
||||
// ── DIFERENÇA ──
|
||||
out.extend(escpos::line_bold("DIFERENCA"));
|
||||
let diff = self.sys_total - self.saldo_esperado;
|
||||
let diff = self.diferenca;
|
||||
let diff_str = if diff >= 0.0 {
|
||||
format!("+{}", self.fmt_money(diff))
|
||||
} else {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Fechamento de Caixa — O Frangão",
|
||||
"title": "Fechamento de Caixa \u2014 O Frang\u00e3o",
|
||||
"width": 1100,
|
||||
"height": 780,
|
||||
"minWidth": 900,
|
||||
@@ -22,13 +22,18 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
"csp": null,
|
||||
"capabilities": [
|
||||
"default"
|
||||
]
|
||||
},
|
||||
"withGlobalTauri": true
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": ["nsis"],
|
||||
"targets": [
|
||||
"nsis"
|
||||
],
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
@@ -37,7 +42,9 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"windows": {
|
||||
"webviewInstallMode": { "type": "embedBootstrapper" }
|
||||
"webviewInstallMode": {
|
||||
"type": "embedBootstrapper"
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"../src/*": "./"
|
||||
|
||||
+74
-21
@@ -384,7 +384,7 @@
|
||||
|
||||
<!-- SALDO DE CAIXA -->
|
||||
<div class="section">
|
||||
<div class="section-header">🖥️ Saldo de Caixa (Valores do Sistema)</div>
|
||||
<div class="section-header">🖥️ Fechamento de Caixa</div>
|
||||
<div class="sys-grid">
|
||||
<div class="sys-row"><span class="lbl">Troco (+)</span><input type="text" id="sys-troco" class="editable" placeholder="0,00" /></div>
|
||||
<div class="sys-row"><span class="lbl">Crédito (+)</span><input type="text" id="sys-credito" readonly tabindex="-1" /></div>
|
||||
@@ -415,7 +415,7 @@
|
||||
|
||||
<!-- FECHAMENTO (VALORES CONTADOS) -->
|
||||
<div class="section">
|
||||
<div class="section-header">🛒 Fechamento (Valores Contados)</div>
|
||||
<div class="section-header">🛒 Saldo de Caixa</div>
|
||||
<div class="fech-grid">
|
||||
<div class="fech-item"><div class="fech-item-label">Dinheiro</div><input type="text" id="f-fech-dinheiro" placeholder="0,00" /></div>
|
||||
<div class="fech-item"><div class="fech-item-label">Cartões</div><input type="text" id="f-fech-cartoes" placeholder="0,00" /></div>
|
||||
@@ -1290,7 +1290,10 @@ function buildConfirmHTML(data) {
|
||||
// ─── Print Preview Window ──────────────────────────────────────────────────
|
||||
function buildPrintHTML(data) {
|
||||
const fmt = v => 'R$ ' + (v || 0).toFixed(2).replace('.', ',');
|
||||
const diferenca = (data.fechamento || 0) - (data.saldo_esperado || 0);
|
||||
// Usa a diferenca ja calculada pelo tauriRecibo (sys_total - saldo_esperado),
|
||||
// igual ao modal de confirmacao — nao recalcula de fechamento.
|
||||
const diferenca = data.diferenca !== undefined ? data.diferenca
|
||||
: ((data.sys_total || 0) - (data.saldo_esperado || 0));
|
||||
const diffStr = diferenca >= 0 ? `+${fmt(diferenca)}` : fmt(diferenca);
|
||||
const diffColor = diferenca === 0 ? '#2e7d32' : (diferenca > 0 ? '#e65100' : '#c0272d');
|
||||
|
||||
@@ -1520,7 +1523,7 @@ async function tauriRecibo() {
|
||||
|
||||
// Tenta ESC/POS via Tauri primeiro; se falhar, abre preview
|
||||
try {
|
||||
return await window.__TAURI__.core.invoke('imprimir_recibo', { estado: JSON.stringify(data) });
|
||||
return await window.__TAURI__.core.invoke('imprimir_recibo', { data: JSON.stringify(data) });
|
||||
} catch(e) {
|
||||
console.warn('ESC/POS falhou, abrindo preview:', e);
|
||||
openPrintPreview(data);
|
||||
@@ -1539,13 +1542,17 @@ async function tauriCarregarRascunho() {
|
||||
|
||||
// ─── Confirm Modal ────────────────────────────────────────────────────────
|
||||
function openConfirmModal() {
|
||||
console.log('[DEBUG] openConfirmModal chamado');
|
||||
const operador = val('f-operador').trim();
|
||||
const turno = val('f-turno').trim();
|
||||
const loja = val('f-loja').trim();
|
||||
console.log('[DEBUG] openConfirmModal campos:', {operador, turno, loja});
|
||||
if (!operador || !turno || !loja) {
|
||||
console.log('[DEBUG] openConfirmModal: campos faltando, alert');
|
||||
alert('⚠️ Preencha Operador, Turno e Loja antes de enviar.');
|
||||
return;
|
||||
}
|
||||
console.log('[DEBUG] openConfirmModal: campos OK, montando modal');
|
||||
// Build summary
|
||||
const cartCred = estado.cartoes.credito.reduce((s,r) => s+(r.valor||0), 0);
|
||||
const cartDeb = estado.cartoes.debito.reduce((s,r) => s+(r.valor||0), 0);
|
||||
@@ -1559,7 +1566,8 @@ function openConfirmModal() {
|
||||
const pixcnpj = estado.pixcnpj.reduce((s,r) => s+(parseNum(r.valor||0)||0), 0);
|
||||
const fechamento = parseNum(val('f-fech-dinheiro')) + parseNum(val('f-fech-cartoes')) + parseNum(val('f-fech-receber'));
|
||||
const saldoEsp = parseNum(val('f-saldo-esperado'));
|
||||
const diferenca = (parseNum(val('sys-troco')) || 0) - saldoEsp;
|
||||
const sysTotal = (parseNum(val('sys-troco')) || 0) + cartCred + cartDeb + cartAli + cartPix + vales + receber + pixcnpj;
|
||||
const diferenca = sysTotal - saldoEsp;
|
||||
const diffClass = diferenca === 0 ? '#2e7d32' : (diferenca > 0 ? '#e65100' : '#c0272d');
|
||||
document.getElementById('confirm-summary').innerHTML =
|
||||
`<div style="margin-bottom:6px"><strong>📅 Data:</strong> ${estado.data} <strong>👤 Operador:</strong> ${operador} <strong>⏰ Turno:</strong> ${turno} <strong>🏪 Loja:</strong> ${loja}</div>
|
||||
@@ -1573,11 +1581,13 @@ function openConfirmModal() {
|
||||
<div>💳 Débito: <strong>${fmt(cartDeb)}</strong></div>
|
||||
<div>💳 Alimentação: <strong>${fmt(cartAli)}</strong></div>
|
||||
<div>❌ Cancelamentos: <strong>${fmt(cancelamentos)}</strong></div>
|
||||
<div>📋 Fechamento: <strong>${fmt(fechamento)}</strong></div>
|
||||
<div>📋 Fechamento (contado): <strong>${fmt(fechamento)}</strong></div>
|
||||
<div>🖥️ Total Sistema: <strong>${fmt(sysTotal)}</strong></div>
|
||||
<hr style="border:none;border-top:1px dashed #b3d9f7;margin:6px 0">
|
||||
<div>🎯 Saldo Esperado: <strong>${fmt(saldoEsp)}</strong></div>
|
||||
<div>🎯 Saldo Esperado (contado): <strong>${fmt(saldoEsp)}</strong></div>
|
||||
<div style="margin-top:4px">📐 Diferença: <strong style="color:${diffClass}">${fmt(diferenca)}</strong></div>
|
||||
<div style="margin-top:4px;font-size:10px;color:#888">ID: ${estado.loja}_${estado.data}_${estado.operador}</div>`;
|
||||
console.log('[DEBUG] openConfirmModal: tentando abrir modal');
|
||||
document.getElementById('modal-confirm').classList.add('open');
|
||||
}
|
||||
|
||||
@@ -1646,6 +1656,11 @@ document.getElementById('confirm-send').addEventListener('click', async () => {
|
||||
|
||||
// ─── Buttons ───────────────────────────────────────────────────────────────
|
||||
document.getElementById('btn-enviar').addEventListener('click', () => {
|
||||
console.log('[DEBUG] btn-enviar clicado');
|
||||
const operador = document.getElementById('f-operador')?.value;
|
||||
const turno = document.getElementById('f-turno')?.value;
|
||||
const loja = document.getElementById('f-loja')?.value;
|
||||
console.log('[DEBUG] operador:', operador, 'turno:', turno, 'loja:', loja);
|
||||
openConfirmModal();
|
||||
});
|
||||
|
||||
@@ -1669,22 +1684,52 @@ document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||
if (!confirm('Limpar rascunho? Esta acção não pode ser revertida.')) return;
|
||||
localStorage.removeItem(LS_KEY);
|
||||
// Reseta estado e re-renderiza sem reload
|
||||
estado = newEstado();
|
||||
estado.loja = val('f-loja') || 'União';
|
||||
estado.data = val('f-data') || new Date().toISOString().split('T')[0];
|
||||
estado = {
|
||||
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'
|
||||
};
|
||||
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('sys-troco', '');
|
||||
calcular();
|
||||
renderAllTables();
|
||||
syncUI();
|
||||
showToast('Rascunho limpo.', 'info');
|
||||
});
|
||||
|
||||
document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
const btnAnterior = document.getElementById('btn-anterior');
|
||||
if (btnAnterior) {
|
||||
btnAnterior.addEventListener('click', async () => {
|
||||
console.log('[DEBUG] btn-anterior clicado');
|
||||
const loja = val('f-loja') || 'União';
|
||||
console.log('[DEBUG] btn-anterior loja:', loja);
|
||||
|
||||
// Salva rascunho atual antes de tudo
|
||||
await tauriSaveLocal();
|
||||
|
||||
// Calcula dia anterior
|
||||
const prevDate = new Date(estado.data);
|
||||
prevDate.setDate(prevDate.getDate() - 1);
|
||||
const prevDateStr = prevDate.toISOString().split('T')[0];
|
||||
|
||||
// Confirmação explícita antes de trocar de dia
|
||||
const confirmMsg = `ATENÇÃO: vai carregar o fechamento de ${prevDateStr}.\n\nO formulário atual será LIMPO caso não tenha enviado.\n\nContinuar?`;
|
||||
if (!confirm(confirmMsg)) {
|
||||
console.log('[DEBUG] btn-anterior cancelado pelo usuário');
|
||||
return;
|
||||
}
|
||||
|
||||
// Carrega lista de fechamentos recentes do Supabase com uuid
|
||||
let recentList = [];
|
||||
try {
|
||||
recentList = await window.__TAURI__.core.invoke('sb_listar_recentes', { loja, limite: 20 });
|
||||
console.log('[DEBUG] sb_listar_recentes retornou:', recentList?.length, 'itens');
|
||||
} catch(e) {
|
||||
console.warn('sb_listar_recentes falhou:', e);
|
||||
}
|
||||
@@ -1701,6 +1746,7 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
});
|
||||
dateList.sort().reverse();
|
||||
}
|
||||
console.log('[DEBUG] dateList:', dateList);
|
||||
|
||||
let selectedDate = null;
|
||||
let selectedId = null;
|
||||
@@ -1718,11 +1764,10 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
|
||||
// Se não escolheu data, usa dia anterior automático (sem id — carrega por data)
|
||||
if (!selectedDate) {
|
||||
const d = new Date(estado.data); d.setDate(d.getDate() - 1);
|
||||
selectedDate = d.toISOString().split('T')[0];
|
||||
selectedDate = prevDateStr;
|
||||
}
|
||||
console.log('[DEBUG] selectedDate:', selectedDate, 'selectedId:', selectedId);
|
||||
|
||||
await tauriSaveLocal();
|
||||
setVal('f-data', selectedDate);
|
||||
estado.data = selectedDate;
|
||||
estado.uuid = crypto.randomUUID ? crypto.randomUUID() : Date.now().toString();
|
||||
@@ -1732,24 +1777,27 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
// Tenta Supabase primeiro (com id se disponível), senão local
|
||||
let rascunho = null;
|
||||
if (selectedId) {
|
||||
// Usa sb_buscar_por_id para buscar por id numérico do Supabase
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: selectedId });
|
||||
console.log('[DEBUG] sb_buscar_por_id retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_buscar_por_id falhou:', e); }
|
||||
}
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] sb_carregar_rascunho retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_carregar_rascunho falhou:', e); }
|
||||
}
|
||||
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] carregar_rascunho local retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('carregar_rascunho local falhou:', e); }
|
||||
}
|
||||
|
||||
if (rascunho) {
|
||||
console.log('[DEBUG] rascunho carregado com sucesso');
|
||||
if (rascunho.operador) { setVal('f-operador', rascunho.operador); estado.operador = rascunho.operador; }
|
||||
if (rascunho.turno) { setVal('f-turno', rascunho.turno); estado.turno = rascunho.turno; }
|
||||
if (rascunho.saldo_troco) setVal('sys-troco', fmtNum(rascunho.saldo_troco));
|
||||
@@ -1774,26 +1822,31 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
estado.cancelamentos = rascunho.cancelamentos.map(c => ({ numero: c.numero || '', valor: parseNum(c.valor) || 0, motivo: c.motivo || '' }));
|
||||
}
|
||||
if (rascunho.cartoes) {
|
||||
estado.cartoes.credito = (rascunho.cartoes.credito || []).map(v => ({ valor: parseNum(v) || 0 }));
|
||||
estado.cartoes.debito = (rascunho.cartoes.debito || []).map(v => ({ valor: parseNum(v) || 0 }));
|
||||
estado.cartoes.alimentacao = (rascunho.cartoes.alimentacao || []).map(v => ({ valor: parseNum(v) || 0 }));
|
||||
estado.cartoes.pix = (rascunho.cartoes.pix || []).map(v => ({ valor: parseNum(v) || 0 }));
|
||||
const norm = (arr) => Array.isArray(arr) ? arr.map(v => ({ valor: (typeof v === 'object' && v !== null) ? (parseNum(v.valor) || 0) : (parseNum(v) || 0) })) : [];
|
||||
estado.cartoes.credito = norm(rascunho.cartoes.credito);
|
||||
estado.cartoes.debito = norm(rascunho.cartoes.debito);
|
||||
estado.cartoes.alimentacao = norm(rascunho.cartoes.alimentacao);
|
||||
estado.cartoes.pix = norm(rascunho.cartoes.pix);
|
||||
}
|
||||
} else {
|
||||
console.log('[DEBUG] nenhum rascunho encontrado para esta data');
|
||||
estado.despesas = []; estado.sangrias = []; estado.pixcnpj = [];
|
||||
estado.vales = []; estado.receber = []; estado.cancelamentos = [];
|
||||
estado.cartoes = { credito: [], debito: [], alimentacao: [], pix: [] };
|
||||
setVal('sys-troco', ''); setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
||||
}
|
||||
|
||||
// Marcar que este é um rascunho carregado (não novo)
|
||||
estado.sync_status = rascunho ? 'loaded' : 'local';
|
||||
|
||||
PRE_FILL_TABLES.forEach(ensureOneRow);
|
||||
Object.keys(TABLES).forEach(renderTable);
|
||||
updateTotals();
|
||||
scheduleSave();
|
||||
});
|
||||
console.log('[DEBUG] btn-anterior concluído');
|
||||
});
|
||||
} else {
|
||||
console.error('[DEBUG] btn-anterior NÃO encontrado no DOM!');
|
||||
}
|
||||
|
||||
document.getElementById('f-obs').addEventListener('input', e => { estado.observacoes = e.target.value; scheduleSave(); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user