Compare commits

...

1 Commits

Author SHA1 Message Date
root 4a157d27cb fix: vendas no buildPrintHTML e consultaToPrintData, fmtMoneyInput R$, auto-migration no Rust
Build Fechamento de Caixa / build (macos-14, app) (push) Has been cancelled
Build Fechamento de Caixa / build (ubuntu-22.04, deb) (push) Has been cancelled
Build Fechamento de Caixa / build (windows-2022, msi) (push) Has been cancelled
2026-06-30 02:52:18 +00:00
2 changed files with 54 additions and 1 deletions
+42
View File
@@ -397,6 +397,48 @@ impl SupabaseClient {
}
}
/// Tenta forçar PostgREST a recarregar schema com novas colunas (vendas, edited_at, edited_by).
/// Estratégia: INSERT com novas colunas → se PGRST204, espera 1.5s → retry.
/// Fire-and-forget — falha não bloqueia.
pub fn run_migration(&self) {
let payload = serde_json::json!({
"id_fechamento": "_mig_probe_1900",
"loja": "_probe_",
"data": "1900-01-01",
"operador": "_probe_",
"vendas": 0,
"edited_at": null,
"edited_by": null
});
let r1 = self.http
.post(&format!("{}/rest/v1/fechamentos_web", self.base_url))
.headers(self.headers(true))
.header("Prefer", "resolution=merge-duplicates")
.json(&payload)
.send();
if let Ok(resp) = r1 {
if resp.status().as_u16() == 400 {
std::thread::sleep(std::time::Duration::from_millis(1500));
let _ = self.http
.post(&format!("{}/rest/v1/fechamentos_web", self.base_url))
.headers(self.headers(true))
.header("Prefer", "resolution=merge-duplicates")
.json(&serde_json::json!({
"id_fechamento": "_mig_probe_1900",
"vendas": 0,
"edited_at": null,
"edited_by": null
}))
.send();
}
}
// Limpa probe
let _ = self.http
.delete(&format!("{}/rest/v1/fechamentos_web?id_fechamento=eq._mig_probe_1900", self.base_url))
.headers(self.headers(true))
.send();
}
/// Verifica se está online.
pub fn health_check(&self) -> bool {
let url = format!("{}/rest/v1/?limit=0", self.base_url);
+12 -1
View File
@@ -433,7 +433,7 @@
<div style="display:flex;gap:12px">
<div style="flex:1">
<label style="font-size:12px;color:#666">Vendas (R$)</label>
<input type="number" id="f-vendas" min="0" step="0.01" placeholder="0,00" style="width:100%;padding:8px;border:1px solid var(--border);border-radius:var(--radius);font-size:15px" />
<input type="text" id="f-vendas" placeholder="0,00" style="width:100%;padding:8px;border:1px solid var(--border);border-radius:var(--radius);font-size:15px;text-align:right" onblur="fmtMoneyInput(this)" onfocus="unfmtMoneyInput(this)" />
</div>
</div>
</div>
@@ -638,6 +638,14 @@ const fmtNum = v => {
// Always 2 decimal places for money
return n.toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
};
const fmtMoneyInput = el => {
const raw = parseNum(el.value);
if (raw > 0) el.value = fmtNum(raw);
};
const unfmtMoneyInput = el => {
const raw = parseNum(el.value);
if (raw > 0) el.value = raw.toString();
};
// Format time: 4 digits → HH:MM
function fmtTime(v) {
@@ -1686,6 +1694,7 @@ ${cancLines.map(l => `<div class="row"><span>${l.label}</span><span>${fmt(l.valo
<div class="section-title">CONTADORES</div>
<div class="row"><span>Clientes:</span><span>${data.clientes || 0}</span></div>
<div class="row"><span>Frango Assado:</span><span>${data.frango || 0}</span></div>
<div class="row"><span>Vendas:</span><span>${fmt(data.vendas || 0)}</span></div>
${data.observacoes ? `<div class="obs">${data.observacoes}</div>` : ''}
@@ -1904,6 +1913,7 @@ function buildReciboData() {
observacoes: estado.observacoes,
clientes: estado.clientes,
frango: estado.frango,
vendas: estado.vendas || 0,
sync_status: estado.sync_status,
};
}
@@ -2703,6 +2713,7 @@ function consultaToPrintData(full) {
observacoes: full.observacoes || '',
clientes: full.clientes || 0,
frango: full.frango || 0,
vendas: dados.vendas ?? full.vendas ?? 0,
};
}