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

This commit is contained in:
root
2026-06-30 02:52:18 +00:00
parent a0f2f91131
commit 4a157d27cb
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);