Compare commits
12 Commits
v1.3.60
...
v1.4.9-fix
| Author | SHA1 | Date | |
|---|---|---|---|
| c8016f076d | |||
| b1a9f94231 | |||
| 42aadcca2c | |||
| a8319d96a6 | |||
| bf878545b3 | |||
| 22cda312cf | |||
| d112ad061e | |||
| be917f8fb7 | |||
| cb48afeb9c | |||
| 2b8ff711ed | |||
| 9a4ccabd1b | |||
| 32728eec37 |
@@ -250,25 +250,58 @@ 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::info!("[PATCH] url={} body={:#?}", url, filtered);
|
||||||
|
|
||||||
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()?;
|
||||||
|
|
||||||
if resp.status().is_success() {
|
let status = resp.status();
|
||||||
|
if status.is_success() {
|
||||||
|
// Ler a resposta real do Supabase (retorna o registro atualizado)
|
||||||
|
if let Ok(ret) = resp.json::<serde_json::Value>() {
|
||||||
|
log::info!("[PATCH] sucesso — resposta: {}", ret);
|
||||||
|
} else {
|
||||||
|
log::warn!("[PATCH] sucesso mas não conseguiu ler resposta");
|
||||||
|
}
|
||||||
Ok(serde_json::json!({ "ok": true, "id_fechamento": id_fechamento }))
|
Ok(serde_json::json!({ "ok": true, "id_fechamento": id_fechamento }))
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
|
||||||
let body = resp.text().unwrap_or_default();
|
let body = resp.text().unwrap_or_default();
|
||||||
|
log::error!("[PATCH] HTTP {} body: {}", status.as_u16(), body);
|
||||||
Err(SupabaseError::Api(format!(
|
Err(SupabaseError::Api(format!(
|
||||||
"HTTP {}: {}",
|
"HTTP {}: {}",
|
||||||
status.as_u16(),
|
status.as_u16(),
|
||||||
@@ -504,7 +537,7 @@ pub fn sb_buscar_por_id_fechamento(
|
|||||||
sb.buscar_por_id_fechamento(&id_fechamento)
|
sb.buscar_por_id_fechamento(&id_fechamento)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
pub fn sb_atualizar_fechamento(
|
pub fn sb_atualizar_fechamento(
|
||||||
sb: State<'_, SupabaseClient>,
|
sb: State<'_, SupabaseClient>,
|
||||||
id_fechamento: String,
|
id_fechamento: String,
|
||||||
|
|||||||
+141
-25
@@ -613,7 +613,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)
|
||||||
@@ -2165,24 +2165,27 @@ function buildConsultaModal(recentList) {
|
|||||||
|
|
||||||
const rows = recentList.map((item, i) => {
|
const rows = recentList.map((item, i) => {
|
||||||
const total = (parseFloat(item.fechamento_dinheiro)||0) + (parseFloat(item.fechamento_cartoes)||0) + (parseFloat(item.fechamento_areceber)||0);
|
const total = (parseFloat(item.fechamento_dinheiro)||0) + (parseFloat(item.fechamento_cartoes)||0) + (parseFloat(item.fechamento_areceber)||0);
|
||||||
return `<tr style="cursor:pointer" onclick="openConsultaRegistro(${i})">
|
return `<tr>
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px">${fmtDate(item.data)}</td>
|
<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">${item.operador||'?'}</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">${item.turno||'?'}</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">${fmtMoney(total)}</td>
|
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right;cursor:pointer" onclick="openConsultaRegistro(${i})">${fmtMoney(total)}</td>
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;text-align:right">${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(${i})">${fmtMoney(item.saldo_esperado)}</td>
|
||||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px">${statusBadge(item.status_diferenca)}</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">${syncBadge(item.sync_status)}</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>`;
|
</tr>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
overlay.innerHTML = `
|
overlay.innerHTML = `
|
||||||
<div style="background:#fff;border-radius:10px;padding:20px;max-width:700px;width:95%;max-height:85vh;overflow-y:auto">
|
<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">
|
<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>
|
<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>
|
<button onclick="closeConsultaModal()" style="background:none;border:none;font-size:18px;cursor:pointer">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<p style="font-size:12px;color:#666;margin:0 0 10px">Clique em um registro para ver o relatório e, se necessário, editar campos com senha admin.</p>
|
<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">
|
<table style="width:100%;border-collapse:collapse">
|
||||||
<thead>
|
<thead>
|
||||||
<tr style="background:#f5f5f5">
|
<tr style="background:#f5f5f5">
|
||||||
@@ -2193,6 +2196,7 @@ function buildConsultaModal(recentList) {
|
|||||||
<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">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">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">SYNC</th>
|
||||||
|
<th style="padding:6px 8px;text-align:center;font-size:11px;color:#888">AÇÃO</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>${rows}</tbody>
|
<tbody>${rows}</tbody>
|
||||||
@@ -2204,6 +2208,40 @@ function buildConsultaModal(recentList) {
|
|||||||
window._recentList = recentList;
|
window._recentList = recentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abre a janela de edição completa de um registro pelo índice na lista
|
||||||
|
window.abrirEditaFechamentoIndex = async function(idx) {
|
||||||
|
const item = window._recentList ? window._recentList[idx] : null;
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
||||||
|
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
||||||
|
|
||||||
|
let full = null;
|
||||||
|
try {
|
||||||
|
if (item.id) {
|
||||||
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: item.id }); } catch(e) {}
|
||||||
|
}
|
||||||
|
if (!full && item.uuid) {
|
||||||
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_uuid', { uuid: item.uuid }); } catch(e) {}
|
||||||
|
}
|
||||||
|
if (!full && item.id_fechamento) {
|
||||||
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id_fechamento', { idFechamento: item.id_fechamento }); } catch(e) {}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.warn('Erro buscando registro:', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!full) { alert('Registro não encontrado.'); return; }
|
||||||
|
|
||||||
|
// Adiciona id_fechamento se não vier do banco
|
||||||
|
if (!full.id_fechamento && full.loja && full.data && full.operador) {
|
||||||
|
full.id_fechamento = (full.loja + '_' + full.data + '_' + full.operador).toLowerCase().replace(/ /g, '_');
|
||||||
|
}
|
||||||
|
|
||||||
|
closeConsultaModal();
|
||||||
|
window.abrirEditaFechamento(full);
|
||||||
|
};
|
||||||
|
|
||||||
function closeConsultaModal() {
|
function closeConsultaModal() {
|
||||||
const m = document.getElementById('modal-consulta');
|
const m = document.getElementById('modal-consulta');
|
||||||
if (m) document.body.removeChild(m);
|
if (m) document.body.removeChild(m);
|
||||||
@@ -2634,6 +2672,7 @@ window._recalcEditTotals = function() {
|
|||||||
const el = id => document.getElementById(id);
|
const el = id => document.getElementById(id);
|
||||||
const fmtTot = v => v > 0 ? 'R$ ' + v.toLocaleString('pt-BR', { minimumFractionDigits: 2 }) : '—';
|
const fmtTot = v => v > 0 ? 'R$ ' + v.toLocaleString('pt-BR', { minimumFractionDigits: 2 }) : '—';
|
||||||
|
|
||||||
|
// Atualiza spans do total-box (prefixo "edit-total-") E do resumo rápido (prefixo "tot-")
|
||||||
if (el('edit-total-credito')) el('edit-total-credito').textContent = fmtTot(cartCred_tot);
|
if (el('edit-total-credito')) el('edit-total-credito').textContent = fmtTot(cartCred_tot);
|
||||||
if (el('edit-total-debito')) el('edit-total-debito').textContent = fmtTot(cartDeb_tot);
|
if (el('edit-total-debito')) el('edit-total-debito').textContent = fmtTot(cartDeb_tot);
|
||||||
if (el('edit-total-alimentacao')) el('edit-total-alimentacao').textContent = fmtTot(cartAli_tot);
|
if (el('edit-total-alimentacao')) el('edit-total-alimentacao').textContent = fmtTot(cartAli_tot);
|
||||||
@@ -2641,9 +2680,20 @@ window._recalcEditTotals = function() {
|
|||||||
if (el('edit-total-vales')) el('edit-total-vales').textContent = fmtTot(vales_tot);
|
if (el('edit-total-vales')) el('edit-total-vales').textContent = fmtTot(vales_tot);
|
||||||
if (el('edit-total-despesas')) el('edit-total-despesas').textContent = fmtTot(desp_tot);
|
if (el('edit-total-despesas')) el('edit-total-despesas').textContent = fmtTot(desp_tot);
|
||||||
if (el('edit-total-sangrias')) el('edit-total-sangrias').textContent = fmtTot(sang_tot);
|
if (el('edit-total-sangrias')) el('edit-total-sangrias').textContent = fmtTot(sang_tot);
|
||||||
if (el('edit-total-pixcnpj')) el('edit-total-pixcnpj').textContent = fmtTot(pixcnpj_tot);
|
if (el('edit-total-pixcnpj')) el('edit-total-pixcnpj').textContent = fmtTot(pixcnpj_tot);
|
||||||
if (el('edit-total-receber')) el('edit-total-receber').textContent = fmtTot(recv_tot);
|
if (el('edit-total-receber')) el('edit-total-receber').textContent = fmtTot(recv_tot);
|
||||||
if (el('edit-total-cancel')) el('edit-total-cancel').textContent = fmtTot(canc_tot);
|
if (el('edit-total-cancel')) el('edit-total-cancel').textContent = fmtTot(canc_tot);
|
||||||
|
// Atualiza também os spans do total-box da popup (prefixo "tot-")
|
||||||
|
if (el('tot-credito')) el('tot-credito').textContent = fmtTot(cartCred_tot);
|
||||||
|
if (el('tot-debito')) el('tot-debito').textContent = fmtTot(cartDeb_tot);
|
||||||
|
if (el('tot-ali')) el('tot-ali').textContent = fmtTot(cartAli_tot);
|
||||||
|
if (el('tot-pix')) el('tot-pix').textContent = fmtTot(cartPix_tot);
|
||||||
|
if (el('tot-pixcnpj')) el('tot-pixcnpj').textContent = fmtTot(pixcnpj_tot);
|
||||||
|
if (el('tot-vales')) el('tot-vales').textContent = fmtTot(vales_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-despesas')) el('tot-despesas').textContent = fmtTot(desp_tot);
|
||||||
|
if (el('tot-cancel')) el('tot-cancel').textContent = fmtTot(canc_tot);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modal de edição completo com todas as grades
|
// Modal de edição completo com todas as grades
|
||||||
@@ -2657,7 +2707,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 });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2886,7 +2937,8 @@ function openEditModal(full) {
|
|||||||
// 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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2897,6 +2949,20 @@ function closeEditModal() {
|
|||||||
window._editModalOpen = false;
|
window._editModalOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Janela de edição completa (usa modal interno, não popup) ─────────────────
|
||||||
|
// Reaproveita openEditModal que já tem todas as tabelas editáveis,
|
||||||
|
// grades de cartões/vales/despesas/sangrias/pixcnjp/receber/cancelamentos,
|
||||||
|
// e conexão Tauri funcionando. Apenas pré-preenche o registro e abre.
|
||||||
|
window.abrirEditaFechamento = async function(full) {
|
||||||
|
if (!full) { alert('Registro não fornecido.'); return; }
|
||||||
|
// Garante id_fechamento
|
||||||
|
if (!full.id_fechamento && full.loja && full.data && full.operador) {
|
||||||
|
full.id_fechamento = (full.loja + '_' + full.data + '_' + full.operador).toLowerCase().replace(/ /g, '_');
|
||||||
|
}
|
||||||
|
// Usa o mesmo modal de edição completo que já funciona — só abre com o registro
|
||||||
|
openEditModal(full);
|
||||||
|
};
|
||||||
|
|
||||||
// Salva edições do modal de edição completo
|
// Salva edições do modal de edição completo
|
||||||
window.salvarEdicaoModal = async function() {
|
window.salvarEdicaoModal = async function() {
|
||||||
console.log('[DEBUG] salvarEdicaoModal called');
|
console.log('[DEBUG] salvarEdicaoModal called');
|
||||||
@@ -2968,23 +3034,71 @@ 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,
|
||||||
|
|
||||||
// Lançamentos detalhados
|
// Fechamento (campos calculados que o formato antigo usava no dados)
|
||||||
vales: vales,
|
fechamento_dinheiro: p(inp('edit-troco')) + vales_tot + sang_tot - desp_tot - canc_tot,
|
||||||
despesas: despesas,
|
fechamento_cartoes: cartCred_tot + cartDeb_tot + cartAli_tot + cartPix_tot,
|
||||||
sangrias: sangrias,
|
fechamento_areceber: recv_tot,
|
||||||
cancelamentos: cancelamentos,
|
|
||||||
pixcnpj: pixcnpj,
|
// Lançamentos detalhados (JSONB — gravados no campo `dados`)
|
||||||
receber: receber,
|
// 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'),
|
||||||
@@ -3012,7 +3126,7 @@ window.salvarEdicaoModal = async function() {
|
|||||||
console.log('[DEBUG] salvarEdicaoModal id_fechamento:', id_fechamento, 'updates:', JSON.stringify(updates));
|
console.log('[DEBUG] salvarEdicaoModal id_fechamento:', id_fechamento, 'updates:', JSON.stringify(updates));
|
||||||
|
|
||||||
console.log('[DEBUG] invoking sb_atualizar_fechamento...');
|
console.log('[DEBUG] invoking sb_atualizar_fechamento...');
|
||||||
const result = await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id_fechamento, updates: JSON.stringify(updates) });
|
const result = await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id_fechamento, updates });
|
||||||
console.log('[DEBUG] invoke result:', result);
|
console.log('[DEBUG] invoke result:', result);
|
||||||
closeEditModal();
|
closeEditModal();
|
||||||
closeRelatorioModal();
|
closeRelatorioModal();
|
||||||
@@ -3049,7 +3163,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);
|
||||||
|
|||||||
Reference in New Issue
Block a user