fix: editTableHTML has local fmtNum; removes all fmtCell calls from openEditModal
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 14:45:36 +00:00
parent 292d0b85d9
commit 3e94789cb0
+16 -20
View File
@@ -2516,12 +2516,16 @@ function askPassword() {
// Monta HTML de uma grade editável dentro do modal // Monta HTML de uma grade editável dentro do modal
function editTableHTML(id, headers, rows, numericCols) { function editTableHTML(id, headers, rows, numericCols) {
const fmtNum = v => {
const n = parseFloat(v);
return isNaN(n) ? '' : 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
};
const hdr = headers.map((h,i) => `<th style="padding:2px 4px;text-align:${numericCols.includes(i)?'right':'left'};font-size:10px;white-space:nowrap">${h}</th>`).join(''); const hdr = headers.map((h,i) => `<th style="padding:2px 4px;text-align:${numericCols.includes(i)?'right':'left'};font-size:10px;white-space:nowrap">${h}</th>`).join('');
const body = rows.map((row, ri) => { const body = rows.map((row, ri) => {
const cells = row.map((val, ci) => { const cells = row.map((val, ci) => {
const isNum = numericCols.includes(ci); const isNum = numericCols.includes(ci);
const displayVal = (val !== null && val !== undefined && val !== '') const displayVal = (val !== null && val !== undefined && val !== '')
? (isNum ? fmtMoney(val) : val) ? (isNum ? fmtNum(val) : val)
: ''; : '';
return `<td style="padding:1px 2px"><input data-tbl="${id}" data-row="${ri}" data-col="${ci}" value="${displayVal}" ${isNum ? `style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} /></td>`; return `<td style="padding:1px 2px"><input data-tbl="${id}" data-row="${ri}" data-col="${ci}" value="${displayVal}" ${isNum ? `style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} /></td>`;
}).join(''); }).join('');
@@ -2595,15 +2599,7 @@ function openEditModal(full) {
return 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 }); return 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
}; };
// helper para fmt table cell // helper inline para fmt table cell (já em editTableHTML)
const fmtCell = (v, isNum) => {
if (v === null || v === undefined || v === '') return '';
if (isNum) {
const n = parseFloat(v);
return isNaN(n) ? '' : 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
}
return v;
};
const editedInfo = full.edited_at const editedInfo = full.edited_at
? `<div style="background:#fff8e1;border-radius:4px;padding:6px 10px;font-size:11px;color:#666;margin-bottom:8px"> ? `<div style="background:#fff8e1;border-radius:4px;padding:6px 10px;font-size:11px;color:#666;margin-bottom:8px">
@@ -2612,10 +2608,10 @@ function openEditModal(full) {
: ''; : '';
// --- Cartões --- // --- Cartões ---
const cartCred_rows = (dados.cartoes?.credito || full.cartoes_credito || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]); const cartCred_rows = (dados.cartoes?.credito || full.cartoes_credito || []).map(r => [typeof r === 'object' ? r.valor : r]);
const cartDeb_rows = (dados.cartoes?.debito || full.cartoes_debito || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]); const cartDeb_rows = (dados.cartoes?.debito || full.cartoes_debito || []).map(r => [typeof r === 'object' ? r.valor : r]);
const cartAli_rows = (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]); const cartAli_rows = (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).map(r => [typeof r === 'object' ? r.valor : r]);
const cartPix_rows = (dados.cartoes?.pix || full.cartoes_pix || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]); const cartPix_rows = (dados.cartoes?.pix || full.cartoes_pix || []).map(r => [typeof r === 'object' ? r.valor : r]);
const cartCredHTML = editTableHTML('credito', ['Valor (R$)'], cartCred_rows.length ? cartCred_rows : [['']], [0]); const cartCredHTML = editTableHTML('credito', ['Valor (R$)'], cartCred_rows.length ? cartCred_rows : [['']], [0]);
const cartDebHTML = editTableHTML('debito', ['Valor (R$)'], cartDeb_rows.length ? cartDeb_rows : [['']], [0]); const cartDebHTML = editTableHTML('debito', ['Valor (R$)'], cartDeb_rows.length ? cartDeb_rows : [['']], [0]);
@@ -2623,27 +2619,27 @@ function openEditModal(full) {
const cartPixHTML = editTableHTML('pix', ['Valor (R$)'], cartPix_rows.length ? cartPix_rows : [['']], [0]); const cartPixHTML = editTableHTML('pix', ['Valor (R$)'], cartPix_rows.length ? cartPix_rows : [['']], [0]);
// --- Vales --- // --- Vales ---
const vales_rows = (full.vales || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true), r.obs||r.Obs||'']); const vales_rows = (full.vales || []).map(r => [r.nome||r.Nome||'', r.valor, r.obs||r.Obs||'']);
const valesHTML = editTableHTML('vales', ['Nome', 'Valor (R$)', 'Obs'], vales_rows.length ? vales_rows : [['','','']], [1]); const valesHTML = editTableHTML('vales', ['Nome', 'Valor (R$)', 'Obs'], vales_rows.length ? vales_rows : [['','','']], [1]);
// --- Despesas --- // --- Despesas ---
const despesas_rows = (full.despesas || []).map(r => [r.desc||r.Desc||'', r.obs||r.Obs||'', fmtCell(r.valor, true)]); const despesas_rows = (full.despesas || []).map(r => [r.desc||r.Desc||'', r.obs||r.Obs||'', r.valor]);
const despesasHTML = editTableHTML('despesas', ['Descrição', 'Obs', 'Valor (R$)'], despesas_rows.length ? despesas_rows : [['','','']], [2]); const despesasHTML = editTableHTML('despesas', ['Descrição', 'Obs', 'Valor (R$)'], despesas_rows.length ? despesas_rows : [['','','']], [2]);
// --- Sangrias --- // --- Sangrias ---
const sangrias_rows = (full.sangrias || []).map(r => [r.hora||r.Hora||'', fmtCell(r.retirada, true), r.gerente||r.Gerente||'']); const sangrias_rows = (full.sangrias || []).map(r => [r.hora||r.Hora||'', r.retirada, r.gerente||r.Gerente||'']);
const sangriasHTML = editTableHTML('sangrias', ['Hora', 'Valor (R$)', 'Gerente'], sangrias_rows.length ? sangrias_rows : [['','','']], [1]); const sangriasHTML = editTableHTML('sangrias', ['Hora', 'Valor (R$)', 'Gerente'], sangrias_rows.length ? sangrias_rows : [['','','']], [1]);
// --- Cancelamentos --- // --- Cancelamentos ---
const cancel_rows = (full.cancelamentos || []).map(r => [r.numero||r.Numero||'', fmtCell(r.valor, true), r.motivo||r.Motivo||'']); const cancel_rows = (full.cancelamentos || []).map(r => [r.numero||r.Numero||'', r.valor, r.motivo||r.Motivo||'']);
const cancelHTML = editTableHTML('cancelamentos', ['Número', 'Valor (R$)', 'Motivo'], cancel_rows.length ? cancel_rows : [['','','']], [1]); const cancelHTML = editTableHTML('cancelamentos', ['Número', 'Valor (R$)', 'Motivo'], cancel_rows.length ? cancel_rows : [['','','']], [1]);
// --- PIX CNPJ --- // --- PIX CNPJ ---
const pixcnpj_rows = (full.pixcnpj || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true)]); const pixcnpj_rows = (full.pixcnpj || []).map(r => [r.nome||r.Nome||'', r.valor]);
const pixcnpjHTML = editTableHTML('pixcnpj', ['Nome', 'Valor (R$)'], pixcnpj_rows.length ? pixcnpj_rows : [['','']], [1]); const pixcnpjHTML = editTableHTML('pixcnpj', ['Nome', 'Valor (R$)'], pixcnpj_rows.length ? pixcnpj_rows : [['','']], [1]);
// --- A Receber --- // --- A Receber ---
const receber_rows = (full.receber || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true)]); const receber_rows = (full.receber || []).map(r => [r.nome||r.Nome||'', r.valor]);
const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]); const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]);
// --- Totais (só leitura formatado) --- // --- Totais (só leitura formatado) ---