fix: buildPrintHTML usa sys_total correto
This commit is contained in:
@@ -322,13 +322,12 @@ impl ReciboData {
|
||||
out.extend(escpos::divider());
|
||||
|
||||
// ── DIFERENÇA ──
|
||||
// Diferença = TOTAL SISTEMA - saldo_esperado - cancelamentos
|
||||
// Usa o valor calculado pelo frontend (já correto)
|
||||
out.extend(escpos::line_bold("DIFERENCA"));
|
||||
let diff = self.sys_total - self.saldo_esperado - self.cancelamentos;
|
||||
let diff_str = if diff >= 0.0 {
|
||||
format!("+{}", self.fmt_money(diff))
|
||||
let diff_str = if self.diferenca >= 0.0 {
|
||||
format!("+{}", self.fmt_money(self.diferenca))
|
||||
} else {
|
||||
self.fmt_money(diff)
|
||||
self.fmt_money(self.diferenca)
|
||||
};
|
||||
out.extend(escpos::title(&diff_str));
|
||||
|
||||
@@ -528,8 +527,10 @@ pub fn caminho_impressora() -> Option<String> {
|
||||
|
||||
#[tauri::command]
|
||||
pub fn imprimir_recibo(data: String) -> Result<usize, String> {
|
||||
eprintln!("[DEBUG RECIBO JSON] {}", &data[..data.len().min(500)]);
|
||||
let r: ReciboData =
|
||||
serde_json::from_str(&data).map_err(|e| format!("Erro ao analisar dados: {}", e))?;
|
||||
eprintln!("[DEBUG DIFERENCA] self.diferenca={}", r.diferenca);
|
||||
let bytes = r.to_escpos();
|
||||
log::info!("Imprimindo recibo: {} bytes ESC/POS", bytes.len());
|
||||
PRINTER.imprimir_bytes(&bytes)
|
||||
|
||||
Reference in New Issue
Block a user