Actualizar contabilidad.html

This commit is contained in:
2026-03-01 14:47:27 +00:00
parent a26b56418a
commit 948ea5c4dd

View File

@@ -313,15 +313,16 @@
if (data.ok) { if (data.ok) {
showToast("Cobro actualizado"); showToast("Cobro actualizado");
// Actualizar el array local para que los KPIs se recalculen sin recargar de BD // Actualizar el array local usando la nueva regla de negocio
const fIndex = allFinancials.findIndex(f => f.scraped_id === scrapedId); const fIndex = allFinancials.findIndex(f => f.scraped_id === scrapedId);
if (fIndex > -1) { if (fIndex > -1) {
allFinancials[fIndex].amount = parseFloat(amount || 0); allFinancials[fIndex].amount = parseFloat(amount || 0);
allFinancials[fIndex].payment_method = method; allFinancials[fIndex].payment_method = method;
allFinancials[fIndex].is_paid = data.is_paid; // Si nos manda el backend que está pagado o si no es pendiente, es TRUE
allFinancials[fIndex].is_paid = method !== 'Pendiente';
} }
// Refrescar lista visualmente // Refrescar lista y KPIs visualmente
renderList(); renderList();
} else { } else {
showToast("Error al guardar."); showToast("Error al guardar.");