Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a8881d41d | |||
| 3b3eb1a4cc | |||
| c7109b1017 | |||
| f45d1e8170 |
@@ -279,7 +279,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",
|
"{}/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",
|
||||||
self.base_url,
|
self.base_url,
|
||||||
urlencoding::encode(&loja_normalized),
|
urlencoding::encode(&loja_normalized),
|
||||||
limite,
|
limite,
|
||||||
|
|||||||
+107
-74
@@ -564,7 +564,7 @@
|
|||||||
<p style="font-size:13px;color:#444;margin-bottom:14px">
|
<p style="font-size:13px;color:#444;margin-bottom:14px">
|
||||||
Tem certeza que deseja <strong>enviar este fechamento e encerrar o caixa?</strong>
|
Tem certeza que deseja <strong>enviar este fechamento e encerrar o caixa?</strong>
|
||||||
</p>
|
</p>
|
||||||
<div id="confirm-summary" style="border:1px solid #b3d9f7;border-radius:8px;padding:12px;background:#f0f7ff;font-size:12px;font-family:monospace">
|
<div id="confirm-summary" style="border:1px solid #b3d9f7;border-radius:8px;padding:14px;background:#f0f7ff;font-size:14px;font-family:Arial,sans-serif;line-height:1.6">
|
||||||
</div>
|
</div>
|
||||||
<p style="font-size:11px;color:#888;margin-top:10px">
|
<p style="font-size:11px;color:#888;margin-top:10px">
|
||||||
Após enviar, <strong>não dá pra editar este fechamento</strong> sem a senha do Filipe.
|
Após enviar, <strong>não dá pra editar este fechamento</strong> sem a senha do Filipe.
|
||||||
@@ -1386,26 +1386,26 @@ function buildConfirmHTML(data) {
|
|||||||
<title>Fechamento de Caixa</title>
|
<title>Fechamento de Caixa</title>
|
||||||
<style>
|
<style>
|
||||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
body { font-family: 'Courier New', monospace; font-size: 15px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
||||||
.header { text-align: center; margin-bottom: 8px; }
|
.header { text-align: center; margin-bottom: 8px; }
|
||||||
.header h1 { font-size: 18px; font-weight: bold; }
|
.header h1 { font-size: 20px; font-weight: bold !important; }
|
||||||
.header h2 { font-size: 14px; font-weight: normal; }
|
.header h2 { font-size: 16px; font-weight: bold !important; }
|
||||||
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
|
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
||||||
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
|
.section-title { font-weight: bold !important; font-size: 14px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||||
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
|
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; font-weight: bold !important; }
|
||||||
.row.total-row { font-weight: bold; }
|
.row.total-row { font-weight: bold !important; }
|
||||||
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
|
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; font-weight: bold !important; }
|
||||||
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
|
.cart-table th { font-weight: bold !important; border-bottom: 2px solid #000; padding: 3px; font-size: 13px; width: 25%; }
|
||||||
.cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
|
.cart-table td { padding: 3px 5px; text-align: right; font-weight: bold !important; font-size: 13px; }
|
||||||
.cart-table td:first-child { text-align: left; }
|
.cart-table td:first-child { text-align: left; }
|
||||||
.cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; }
|
.cart-table tr.total-row { font-weight: bold !important; border-top: 2px solid #000; }
|
||||||
.subtotal { font-size: 12px; margin-top: 4px; }
|
.subtotal { font-size: 13px; margin-top: 4px; }
|
||||||
.subtotal .row { padding: 1px 0; }
|
.subtotal .row { padding: 1px 0; font-weight: bold !important; }
|
||||||
.diff-ok { color: #2e7d32; font-weight: bold; }
|
.diff-ok { color: #2e7d32; font-weight: bold !important; }
|
||||||
.diff-bad { color: #c0272d; font-weight: bold; }
|
.diff-bad { color: #c0272d; font-weight: bold !important; }
|
||||||
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
.obs { font-size: 12px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: bold !important; }
|
||||||
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
|
.footer { text-align: center; font-size: 12px; color: #555; margin-top: 8px; font-weight: bold !important; }
|
||||||
@media print { body { background: #fff; font-weight: bold !important; } }
|
@media print { body { background: #fff; font-weight: bold !important; font-size: 15px !important; } }
|
||||||
</head><body>
|
</head><body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>${data.loja}</h1>
|
<h1>${data.loja}</h1>
|
||||||
@@ -1604,26 +1604,26 @@ function buildPrintHTML(data) {
|
|||||||
<title>Fechamento de Caixa</title>
|
<title>Fechamento de Caixa</title>
|
||||||
<style>
|
<style>
|
||||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
body { font-family: 'Courier New', monospace; font-size: 15px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
||||||
.header { text-align: center; margin-bottom: 8px; }
|
.header { text-align: center; margin-bottom: 8px; }
|
||||||
.header h1 { font-size: 18px; font-weight: bold; }
|
.header h1 { font-size: 20px; font-weight: bold !important; }
|
||||||
.header h2 { font-size: 14px; font-weight: normal; }
|
.header h2 { font-size: 16px; font-weight: bold !important; }
|
||||||
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
|
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
||||||
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
|
.section-title { font-weight: bold !important; font-size: 14px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||||
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
|
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; font-weight: bold !important; }
|
||||||
.row.total-row { font-weight: bold; }
|
.row.total-row { font-weight: bold !important; }
|
||||||
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
|
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; font-weight: bold !important; }
|
||||||
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
|
.cart-table th { font-weight: bold !important; border-bottom: 2px solid #000; padding: 3px; font-size: 13px; width: 25%; }
|
||||||
.cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
|
.cart-table td { padding: 3px 5px; text-align: right; font-weight: bold !important; font-size: 13px; }
|
||||||
.cart-table td:first-child { text-align: left; }
|
.cart-table td:first-child { text-align: left; }
|
||||||
.cart-table tr.total-row { font-weight: bold; border-top: 1px dashed #000; }
|
.cart-table tr.total-row { font-weight: bold !important; border-top: 2px solid #000; }
|
||||||
.subtotal { font-size: 12px; margin-top: 4px; }
|
.subtotal { font-size: 13px; margin-top: 4px; }
|
||||||
.subtotal .row { padding: 1px 0; }
|
.subtotal .row { padding: 1px 0; font-weight: bold !important; }
|
||||||
.diff-ok { color: #2e7d32; font-weight: bold; }
|
.diff-ok { color: #2e7d32; font-weight: bold !important; }
|
||||||
.diff-bad { color: #c0272d; font-weight: bold; }
|
.diff-bad { color: #c0272d; font-weight: bold !important; }
|
||||||
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
.obs { font-size: 12px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: bold !important; }
|
||||||
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
|
.footer { text-align: center; font-size: 12px; color: #555; margin-top: 8px; font-weight: bold !important; }
|
||||||
@media print { body { background: #fff; font-weight: bold !important; } }
|
@media print { body { background: #fff; font-weight: bold !important; font-size: 15px !important; } }
|
||||||
</style>
|
</style>
|
||||||
</head><body>
|
</head><body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@@ -1853,9 +1853,11 @@ function triggerWindowPrint() {
|
|||||||
window.print();
|
window.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Recibo 80mm via Tauri (ESC/POS USB) ─────────────────────────────────
|
// ─── buildReciboData — lê do FORMULÁRIO principal (não do estado carregado do BD) ───
|
||||||
// ─── Recibo 80mm via Tauri (ESC/POS USB) ─────────────────────────────────
|
// Importante: quando editing, o estado estápopulado pelo abrirFechamentoEdicao, não do BD
|
||||||
// Build data object shared by both ESC/POS and preview
|
|
||||||
|
// ─── buildReciboData — lê do FORMULÁRIO principal ───────────────────────────
|
||||||
|
// usado tanto para novo fechamento quanto para edição
|
||||||
function buildReciboData() {
|
function buildReciboData() {
|
||||||
const cartCred = estado.cartoes.credito.reduce((s,r) => s+(r.valor||0), 0);
|
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);
|
const cartDeb = estado.cartoes.debito.reduce((s,r) => s+(r.valor||0), 0);
|
||||||
@@ -1876,6 +1878,7 @@ function buildReciboData() {
|
|||||||
return {
|
return {
|
||||||
uuid: estado.uuid,
|
uuid: estado.uuid,
|
||||||
id_local: estado.id_local,
|
id_local: estado.id_local,
|
||||||
|
id: estado.id,
|
||||||
loja: estado.loja,
|
loja: estado.loja,
|
||||||
data: estado.data,
|
data: estado.data,
|
||||||
operador: estado.operador,
|
operador: estado.operador,
|
||||||
@@ -1899,7 +1902,7 @@ function buildReciboData() {
|
|||||||
vales: valesTotal,
|
vales: valesTotal,
|
||||||
areceber: receberTotal,
|
areceber: receberTotal,
|
||||||
cancelamentos: cancelTotal,
|
cancelamentos: cancelTotal,
|
||||||
// Full arrays for preview
|
// Full arrays for preview / Supabase
|
||||||
despesas_arr: estado.despesas.map(r => ({ desc: r.desc||'', obs: r.obs||'', valor: r.valor||0 })),
|
despesas_arr: estado.despesas.map(r => ({ desc: r.desc||'', obs: r.obs||'', valor: r.valor||0 })),
|
||||||
sangrias_arr: estado.sangrias.map(r => ({ hora: r.hora||'', retirada: parseNum(r.retirada)||0, gerente: r.gerente||'' })),
|
sangrias_arr: estado.sangrias.map(r => ({ hora: r.hora||'', retirada: parseNum(r.retirada)||0, gerente: r.gerente||'' })),
|
||||||
pixcnpj_arr: estado.pixcnpj.map(r => ({ nome: r.nome||'', valor: r.valor||0 })),
|
pixcnpj_arr: estado.pixcnpj.map(r => ({ nome: r.nome||'', valor: r.valor||0 })),
|
||||||
@@ -1910,10 +1913,22 @@ function buildReciboData() {
|
|||||||
cartoes_debito: estado.cartoes.debito.map(r => r.valor || 0),
|
cartoes_debito: estado.cartoes.debito.map(r => r.valor || 0),
|
||||||
cartoes_alimentacao: estado.cartoes.alimentacao.map(r => r.valor || 0),
|
cartoes_alimentacao: estado.cartoes.alimentacao.map(r => r.valor || 0),
|
||||||
cartoes_pix: estado.cartoes.pix.map(r => r.valor || 0),
|
cartoes_pix: estado.cartoes.pix.map(r => r.valor || 0),
|
||||||
|
total_cartao_credito: cartCred,
|
||||||
|
total_cartao_debito: cartDeb,
|
||||||
|
total_cartao_alimentacao: cartAli,
|
||||||
|
total_cartao_pix: cartPix,
|
||||||
|
total_pixcnpj: pixCnpjTotal,
|
||||||
|
total_sangrias: sangriasTotal,
|
||||||
|
total_despesas: despesasTotal,
|
||||||
|
total_vales: valesTotal,
|
||||||
|
total_areceber: receberTotal,
|
||||||
|
total_cancelamentos: cancelTotal,
|
||||||
observacoes: estado.observacoes,
|
observacoes: estado.observacoes,
|
||||||
clientes: estado.clientes,
|
clientes: estado.clientes,
|
||||||
frango: estado.frango,
|
frango: estado.frango,
|
||||||
vendas: estado.vendas || 0,
|
vendas: estado.vendas || 0,
|
||||||
|
edited_at: new Date().toISOString(),
|
||||||
|
edited_by: config.admin_user || 'admin',
|
||||||
sync_status: estado.sync_status,
|
sync_status: estado.sync_status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2374,6 +2389,10 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
const dados = full.dados || full;
|
const dados = full.dados || full;
|
||||||
if (!dados) { alert('Dados detalhados não encontrados neste registro.'); return; }
|
if (!dados) { alert('Dados detalhados não encontrados neste registro.'); return; }
|
||||||
|
|
||||||
|
// IDs do registro — CRÍTICO para o salvamento via Supabase
|
||||||
|
estado.uuid = full.uuid || null;
|
||||||
|
estado.id = full.id || full.uuid || null;
|
||||||
|
|
||||||
// Preenche o estado global com todos os campos do JSONB
|
// Preenche o estado global com todos os campos do JSONB
|
||||||
estado.loja = dados.loja || full.loja || '';
|
estado.loja = dados.loja || full.loja || '';
|
||||||
estado.data = dados.data || full.data || '';
|
estado.data = dados.data || full.data || '';
|
||||||
@@ -2448,7 +2467,7 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
renderTable('tbl-cartao-pix', estado.cartoes.pix);
|
renderTable('tbl-cartao-pix', estado.cartoes.pix);
|
||||||
|
|
||||||
// Recalcula totais
|
// Recalcula totais
|
||||||
calcAll();
|
updateTotals();
|
||||||
|
|
||||||
// Rola para o topo do formulário
|
// Rola para o topo do formulário
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
@@ -2464,11 +2483,15 @@ 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 (se configurada)
|
// Pede senha admin primeiro — sempre, para proteger edições
|
||||||
const pw = config.admin_password;
|
const pw = config.admin_password;
|
||||||
if (pw) {
|
if (pw) {
|
||||||
const ok = await askPassword();
|
const ok = await askPassword();
|
||||||
if (!ok) return;
|
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);
|
||||||
@@ -2817,25 +2840,26 @@ function openEditModal(full) {
|
|||||||
<div id="tbl-edit-cancelamentos" data-numeric="[1]">${cancelHTML}</div>
|
<div id="tbl-edit-cancelamentos" data-numeric="[1]">${cancelHTML}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Saldo de Caixa (editável) -->
|
<!-- Saldo de Caixa (SÓ TROCO é editável — restante é soma automática) -->
|
||||||
<div style="margin-bottom:12px">
|
<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</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 #ccc;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" onblur="this.value=fmtBR(this)" /></div>
|
||||||
<div><label style="font-size:10px;color:#555">Crédito:</label><input type="text" id="edit-sld-credito" value="${fmtMR(full.saldo_credito)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" 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:#555">Débito:</label><input type="text" id="edit-sld-debito" value="${fmtMR(full.saldo_debito)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></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:#555">Alimentação:</label><input type="text" id="edit-sld-alimentacao" value="${fmtMR(full.saldo_alimentacao)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></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:#555">Vales:</label><input type="text" id="edit-sld-vales" value="${fmtMR(full.saldo_vales)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
<div><label style="font-size:10px;color:#888">Vales:</label><input type="text" id="edit-sld-vales" value="${fmtMR(full.saldo_vales)}" 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:#555">PIX CNPJ:</label><input type="text" id="edit-sld-pixcnpj" value="${fmtMR(full.total_pixcnpj)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
<div><label style="font-size:10px;color:#888">PIX CNPJ:</label><input type="text" id="edit-sld-pixcnpj" value="${fmtMR(full.total_pixcnpj)}" 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:#555">À Receber:</label><input type="text" id="edit-sld-areceber" value="${fmtMR(full.saldo_areceber)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></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:#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:#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>
|
</div>
|
||||||
|
|
||||||
<!-- Contadores -->
|
<!-- Contadores -->
|
||||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-bottom:12px">
|
<div style="display:grid;grid-template-columns:1fr 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">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><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>
|
||||||
|
|
||||||
@@ -2970,10 +2994,12 @@ window.salvarEdicaoModal = async function() {
|
|||||||
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const id = inp('edit-id') || full.id;
|
// Usa uuid (string) — que é o id externo do registro no Supabase
|
||||||
if (!id) { alert('ID do registro não encontrado.'); return; }
|
const uuid = full.uuid || full.id;
|
||||||
|
if (!uuid) { alert('UUID do registro não encontrado.'); return; }
|
||||||
|
console.log('[DEBUG] salvarEdicaoModal uuid:', uuid, 'updates:', JSON.stringify(updates));
|
||||||
|
|
||||||
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id, updates });
|
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id: uuid, updates: JSON.stringify(updates) });
|
||||||
closeEditModal();
|
closeEditModal();
|
||||||
closeRelatorioModal();
|
closeRelatorioModal();
|
||||||
alert('✅ Atualizado com sucesso!');
|
alert('✅ Atualizado com sucesso!');
|
||||||
@@ -3059,10 +3085,10 @@ function consultaToPrintData(full) {
|
|||||||
const vales_arr = (dados.vales || []).map(v => ({ nome: v.nome || '', obs: v.obs || '', valor: parseFloat(v.valor || 0) }));
|
const vales_arr = (dados.vales || []).map(v => ({ nome: v.nome || '', obs: v.obs || '', valor: parseFloat(v.valor || 0) }));
|
||||||
const receber_arr = (dados.receber || []).map(r => ({ nome: r.nome || '', valor: parseFloat(r.valor || 0) }));
|
const receber_arr = (dados.receber || []).map(r => ({ nome: r.nome || '', valor: parseFloat(r.valor || 0) }));
|
||||||
const cancelamentos_arr = (dados.cancelamentos || []).map(c => ({ numero: c.numero || '', valor: parseFloat(c.valor || 0), motivo: c.motivo || '' }));
|
const cancelamentos_arr = (dados.cancelamentos || []).map(c => ({ numero: c.numero || '', valor: parseFloat(c.valor || 0), motivo: c.motivo || '' }));
|
||||||
const cartoes_credito = (full.cartoes_credito || []).map(v => parseFloat(v || 0));
|
const cartoes_credito = (dados.cartoes?.credito || full.cartoes_credito || []).map(v => parseFloat(typeof v === 'object' ? (v.valor ?? 0) : (v || 0)));
|
||||||
const cartoes_debito = (full.cartoes_debito || []).map(v => parseFloat(v || 0));
|
const cartoes_debito = (dados.cartoes?.debito || full.cartoes_debito || []).map(v => parseFloat(typeof v === 'object' ? (v.valor ?? 0) : (v || 0)));
|
||||||
const cartoes_alimentacao = (full.cartoes_alimentacao || []).map(v => parseFloat(v || 0));
|
const cartoes_alimentacao = (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).map(v => parseFloat(typeof v === 'object' ? (v.valor ?? 0) : (v || 0)));
|
||||||
const cartoes_pix = (full.cartoes_pix || []).map(v => parseFloat(v || 0));
|
const cartoes_pix = (dados.cartoes?.pix || full.cartoes_pix || []).map(v => parseFloat(typeof v === 'object' ? (v.valor ?? 0) : (v || 0)));
|
||||||
const totalSangrias = sangrias_arr.reduce((s, r) => s + r.retirada + r.valor, 0);
|
const totalSangrias = sangrias_arr.reduce((s, r) => s + r.retirada + r.valor, 0);
|
||||||
const totalDespesas = despesas_arr.reduce((s, r) => s + r.valor, 0);
|
const totalDespesas = despesas_arr.reduce((s, r) => s + r.valor, 0);
|
||||||
const totalPixCnpj = pixcnpj_arr.reduce((s, r) => s + r.valor, 0);
|
const totalPixCnpj = pixcnpj_arr.reduce((s, r) => s + r.valor, 0);
|
||||||
@@ -3126,27 +3152,31 @@ function consultaToPrintData(full) {
|
|||||||
|
|
||||||
// Imprime o relatório — usa iframe como openPrintPreview (Tauri não bloqueia)
|
// Imprime o relatório — usa iframe como openPrintPreview (Tauri não bloqueia)
|
||||||
window.printRelatorio = function() {
|
window.printRelatorio = function() {
|
||||||
|
const full = window._currentConsulta;
|
||||||
|
if (!full) return;
|
||||||
|
const data = consultaToPrintData(full);
|
||||||
|
|
||||||
let html = `<!DOCTYPE html>
|
let html = `<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Fechamento de Caixa</title>
|
<title>Fechamento de Caixa</title>
|
||||||
<style>
|
<style>
|
||||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
body { font-family: 'Courier New', monospace; font-size: 13px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
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; }
|
||||||
.header { text-align: center; margin-bottom: 8px; }
|
.header { text-align: center; margin-bottom: 8px; }
|
||||||
.header h1 { font-size: 18px; font-weight: bold; }
|
.header h1 { font-size: 20px; font-weight: bold; }
|
||||||
.header h2 { font-size: 14px; font-weight: normal; }
|
.header h2 { font-size: 15px; font-weight: normal; }
|
||||||
hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
|
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
||||||
.section-title { font-weight: bold; font-size: 13px; border-top: 1px dashed #000; padding-top: 3px; margin-top: 6px; }
|
.section-title { font-weight: bold; font-size: 14px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||||
.row { display: flex; justify-content: space-between; padding: 1px 0; font-size: 12px; font-weight: bold; }
|
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 13px; font-weight: bold; }
|
||||||
.row.total-row { font-weight: bold; }
|
.row.total-row { font-weight: bold; }
|
||||||
.cart-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; font-weight: bold; }
|
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; font-weight: bold; }
|
||||||
.cart-table th { font-weight: bold; border-bottom: 1px solid #000; padding: 2px; }
|
.cart-table th { font-weight: bold; border-bottom: 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: 1px dashed #000; }
|
.cart-table tr.total-row { font-weight: bold; border-top: 2px solid #000; }
|
||||||
.subtotal { font-size: 12px; margin-top: 4px; }
|
.subtotal { font-size: 13px; margin-top: 4px; }
|
||||||
.subtotal .row { padding: 1px 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: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
||||||
@@ -3226,8 +3256,11 @@ async function salvarEdicaoSupabase() {
|
|||||||
// Remove campos que não devem ir no PATCH
|
// Remove campos que não devem ir no PATCH
|
||||||
delete data.uuid;
|
delete data.uuid;
|
||||||
delete data.id_local;
|
delete data.id_local;
|
||||||
|
// Usa o id numérico se disponível, senão usa uuid
|
||||||
|
const id = estado.id || estado.uuid;
|
||||||
|
console.log('[DEBUG] salvando id:', id, 'data:', JSON.stringify(data));
|
||||||
const result = await window.__TAURI__.core.invoke('sb_atualizar_fechamento', {
|
const result = await window.__TAURI__.core.invoke('sb_atualizar_fechamento', {
|
||||||
uuid: estado.uuid,
|
id: id,
|
||||||
updates: JSON.stringify(data)
|
updates: JSON.stringify(data)
|
||||||
});
|
});
|
||||||
console.log('[DEBUG] sb_atualizar_fechamento result:', result);
|
console.log('[DEBUG] sb_atualizar_fechamento result:', result);
|
||||||
|
|||||||
Reference in New Issue
Block a user