diff --git a/contabilidad.html b/contabilidad.html
index 727a27f..56e0987 100644
--- a/contabilidad.html
+++ b/contabilidad.html
@@ -517,6 +517,33 @@
loadBudgets();
}
+
+ async function deleteBudget(id, status) {
+ // Protección en el lado del cliente (Frontend)
+ if (status === 'accepted' || status === 'converted') {
+ return showToast("⚠️ Para borrar el presupuesto, primero debes rechazarlo/anularlo.");
+ }
+
+ if (!confirm("¿Seguro que quieres borrar este presupuesto definitivamente?")) return;
+
+ try {
+ const res = await fetch(`${API_URL}/budgets/${id}`, {
+ method: 'DELETE',
+ headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
+ });
+ const data = await res.json();
+
+ if (data.ok) {
+ showToast("🗑️ Presupuesto eliminado");
+ loadBudgets();
+ } else {
+ showToast("❌ " + (data.error || "Error al borrar"));
+ }
+ } catch (e) {
+ showToast("❌ Error de conexión");
+ }
+ }
+
// ==========================================
// LÓGICA DE CONVERSIÓN A SERVICIO (MODAL)
// ==========================================