diff --git a/servicios.html b/servicios.html
index fe3a663..cb6c5d6 100644
--- a/servicios.html
+++ b/servicios.html
@@ -95,7 +95,7 @@
Cargando estados...
-
@@ -690,6 +697,12 @@
function getServiceStateInfo(s) {
const raw = s.raw_data || {};
const dbStat = raw.status_operativo;
+ // 🟣 NUEVO: Presupuestos que el chat de WhatsApp deja "aparcados" sin aceptar
+ // llevan la marca budget_mode: true — no son un servicio real todavía, así que
+ // les damos su propio estado en vez de dejarlos caer en "Pendiente de Asignar".
+ if (raw.budget_mode) {
+ return { id: 'presupuesto_pendiente', name: 'Presupuesto Pendiente de Aceptación', color: 'indigo', is_final: false };
+ }
if (!s.assigned_name && (s.automation_status === 'in_progress' || s.automation_status === 'failed')) {
return { id: 'bolsa', name: s.automation_status === 'in_progress' ? 'Buscando Operario' : 'Fallo en Bolsa', color: s.automation_status === 'in_progress' ? 'amber' : 'red', is_final: false };
@@ -734,6 +747,7 @@
let kpiWorking = 0;
let kpiFinished = 0;
let kpiLate = 0;
+ let kpiBudget = 0;
const filteredData = localData.filter(s => {
const raw = s.raw_data || {};
@@ -760,7 +774,8 @@
let category = 'none';
- if (isFinal) { kpiFinished++; category = 'finished'; }
+ if (raw.budget_mode) { kpiBudget++; category = 'budget'; }
+ else if (isFinal) { kpiFinished++; category = 'finished'; }
else if (!s.assigned_to || stateInfo.id === 'bolsa' || stName.includes('asignar')) { kpiUnassigned++; category = 'unassigned'; }
else if (!hasDate) { kpiUnscheduled++; category = 'unscheduled'; }
else if (!isWorking) { kpiPendingStart++; category = 'pending_start'; }
@@ -810,8 +825,9 @@
document.getElementById('kpi-working').innerText = kpiWorking;
document.getElementById('kpi-finished').innerText = kpiFinished;
document.getElementById('kpi-late').innerText = kpiLate;
+ document.getElementById('kpi-budget').innerText = kpiBudget;
- ['unassigned', 'unscheduled', 'pending_start', 'working', 'finished'].forEach(k => {
+ ['unassigned', 'unscheduled', 'pending_start', 'working', 'finished', 'budget'].forEach(k => {
const box = document.getElementById(`box-${k}`);
if (box) {
if (activeKpiFilter === k) box.classList.add('ring-2', 'ring-blue-500', 'bg-blue-50');
@@ -856,6 +872,8 @@ const grid = document.getElementById('servicesGrid');
shortStatusName = 'ESPERA CIA/PRT';
} else if (shortStatusName.toLowerCase().includes('esperando al cliente')) {
shortStatusName = 'ESPERA CLIENTE'; // Resumen para Esperando al cliente
+ } else if (shortStatusName.toLowerCase().includes('presupuesto')) {
+ shortStatusName = 'PTE. ACEPTAR PPTO.';
}
let iconEstado = 'tag';
@@ -865,6 +883,7 @@ const grid = document.getElementById('servicesGrid');
if(stateInfo.name.toLowerCase().includes('incidencia') || stateInfo.name.toLowerCase().includes('pausa')) iconEstado = 'alert-triangle';
// 🛑 NUEVA REGLA: Icono de "Edificio" para el estado de Compañía/Perito
if(stateInfo.name.toLowerCase().includes('compañía') || stateInfo.name.toLowerCase().includes('perito')) iconEstado = 'building';
+ if (stateInfo.name.toLowerCase().includes('presupuesto')) iconEstado = 'receipt';
const inProgressBadge = s.automation_status === 'in_progress' ? ` En Bolsa` : '';