fix: salvar edicao com id numerico, relatorio cartoes detalhado
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-28 13:44:08 +00:00
parent a11db54ffc
commit de5d5aaafb
2 changed files with 9 additions and 15 deletions
+6 -6
View File
@@ -247,11 +247,11 @@ impl SupabaseClient {
} }
} }
/// Atualiza campos específicos de um fechamento pelo id (PATCH). /// Atualiza campos específicos de um fechamento pelo id numérico (PATCH).
pub fn atualizar_fechamento(&self, uuid: &str, updates: &serde_json::Value) -> Result<Value, SupabaseError> { pub fn atualizar_fechamento(&self, id: i64, updates: &serde_json::Value) -> Result<Value, SupabaseError> {
let url = format!( let url = format!(
"{}/rest/v1/fechamentos_web?id=eq.{}", "{}/rest/v1/fechamentos_web?id=eq.{}",
self.base_url, uuid self.base_url, id
); );
let resp = self let resp = self
@@ -262,7 +262,7 @@ impl SupabaseClient {
.send()?; .send()?;
if resp.status().is_success() { if resp.status().is_success() {
Ok(serde_json::json!({ "ok": true, "uuid": uuid })) Ok(serde_json::json!({ "ok": true, "id": id }))
} else { } else {
let status = resp.status(); let status = resp.status();
let body = resp.text().unwrap_or_default(); let body = resp.text().unwrap_or_default();
@@ -462,10 +462,10 @@ pub fn sb_buscar_por_id_fechamento(
#[tauri::command] #[tauri::command]
pub fn sb_atualizar_fechamento( pub fn sb_atualizar_fechamento(
sb: State<'_, SupabaseClient>, sb: State<'_, SupabaseClient>,
uuid: String, id: i64,
updates: serde_json::Value, updates: serde_json::Value,
) -> Result<serde_json::Value, SupabaseError> { ) -> Result<serde_json::Value, SupabaseError> {
sb.atualizar_fechamento(&uuid, &updates) sb.atualizar_fechamento(id, &updates)
} }
#[tauri::command] #[tauri::command]
+3 -9
View File
@@ -2422,16 +2422,10 @@ window.salvarEdicaoConsulta = async function() {
if (!hasTauri) { alert('Tauri não disponível.'); return; } if (!hasTauri) { alert('Tauri não disponível.'); return; }
try { try {
let uuid = full.uuid; const id = full.id;
if (!uuid && full.id_fechamento) { if (!id) { alert('ID do registro não encontrado. Não é possível atualizar.'); return; }
// Buscar uuid pelo id_fechamento primeiro
const found = await window.__TAURI__.core.invoke('sb_buscar_por_id_fechamento', { idFechamento: full.id_fechamento });
if (found && found.uuid) uuid = found.uuid;
}
if (!uuid) { alert('UUID do registro não encontrado. Não é possível atualizar.'); return; } await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id, updates });
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { uuid, updates });
alert('✅ Atualizado com sucesso!'); alert('✅ Atualizado com sucesso!');
closeRelatorioModal(); closeRelatorioModal();
} catch(e) { } catch(e) {