370 lines
19 KiB
JavaScript
370 lines
19 KiB
JavaScript
|
|
import { auth } from "../../lib/auth";
|
|||
|
|
import { ownerFilter } from "../../lib/authz";
|
|||
|
|
import { getRenovPipeline, getRenovClosed, getSystemUsers, getActividades, getStageDurations } from "../../lib/queries";
|
|||
|
|
import { agg, aggOrd, EJECUTIVOS_RENOV, decorarActividadVentana, ACTAGENDADA_ORDEN, pipeVelFor } from "../../lib/derive";
|
|||
|
|
import LoginPrompt from "../../components/LoginPrompt";
|
|||
|
|
import OwnerControl from "../../components/OwnerControl";
|
|||
|
|
import ErrorNotice from "../../components/ErrorNotice";
|
|||
|
|
import Panel from "../../components/pipeline/Panel";
|
|||
|
|
import TablaPipe from "../../components/pipeline/TablaPipe";
|
|||
|
|
import ExecMatrix from "../../components/pipeline/ExecMatrix";
|
|||
|
|
import VelPanel from "../../components/pipeline/VelPanel";
|
|||
|
|
import SegTabs from "../../components/SegTabs";
|
|||
|
|
import BuscadorOportunidades from "../../components/BuscadorOportunidades";
|
|||
|
|
import FilterChips from "../../components/FilterChips";
|
|||
|
|
import ReportModal from "../../components/ReportModal";
|
|||
|
|
import PanelesCalidad from "../../components/pipeline/PanelesCalidad";
|
|||
|
|
import AccionTable from "../../components/pipeline/AccionTable";
|
|||
|
|
import RepTable from "../../components/pipeline/RepTable";
|
|||
|
|
import { money } from "../../lib/constants";
|
|||
|
|
import { parseFiltParam, applyFilt } from "../../lib/filterState";
|
|||
|
|
|
|||
|
|
const BLOCKER_INFO = {
|
|||
|
|
precio: { label: "Precio / oferta no competitiva", accion: "Evaluar un acelerador puntual: descuento, mes de cortesía o ajuste de instalación." },
|
|||
|
|
aprobacion: { label: "Esperando aprobación interna del cliente", accion: "Escalar con una llamada ejecutivo a gerente para destrabar la firma." },
|
|||
|
|
licitacion: { label: "Proceso de licitación externo", accion: "Fuera de control directo por ahora — mantener la relación." },
|
|||
|
|
};
|
|||
|
|
function classifyBlocker(txt) {
|
|||
|
|
txt = (txt || "").toLowerCase();
|
|||
|
|
if (/licitaci|licitatorio/.test(txt)) return "licitacion";
|
|||
|
|
if (/precio|tarifa|descuento|presupuesto|\bcost[oa]\b|\bcara\b|instalaci[oó]n/.test(txt)) return "precio";
|
|||
|
|
if (/aprobaci|aprobar|aprob[oó]|gerencia|gerente|\bfirma\b|firmar|comit[eé]/.test(txt)) return "aprobacion";
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
function mesSiguiente(m) {
|
|||
|
|
const [y, mm] = m.split("-").map(Number);
|
|||
|
|
const d = new Date(y, mm, 1);
|
|||
|
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export const dynamic = "force-dynamic";
|
|||
|
|
|
|||
|
|
const IND_TABS = [
|
|||
|
|
{ k: "owner", lbl: "Ejecutivo" },
|
|||
|
|
{ k: "cliente", lbl: "Cliente" },
|
|||
|
|
{ k: "linea", lbl: "Línea" },
|
|||
|
|
{ k: "competidor", lbl: "Competidor" },
|
|||
|
|
{ k: "vel", lbl: "Velocidad" },
|
|||
|
|
];
|
|||
|
|
const IND_TITULOS = {
|
|||
|
|
owner: "Por Ejecutivo",
|
|||
|
|
cliente: "Por Cliente",
|
|||
|
|
linea: "Por Línea de Negocio",
|
|||
|
|
competidor: "Por Competidor",
|
|||
|
|
};
|
|||
|
|
const IND_HINTS = {
|
|||
|
|
owner: "Ordenado por MRR en juego",
|
|||
|
|
cliente: "Las cuentas con más MRR por renovar este mes",
|
|||
|
|
linea: "Ordenado por MRR en juego",
|
|||
|
|
competidor: "Contra quién se compite la renovación",
|
|||
|
|
};
|
|||
|
|
const IND_TOP = { owner: undefined, cliente: 7, linea: undefined, competidor: 7 };
|
|||
|
|
const DIM_LABELS = { owner: "Ejecutivo", cliente: "Cliente", linea: "Línea", competidor: "Competidor", tipo: "Momento", actAgendada: "Agendado" };
|
|||
|
|
|
|||
|
|
const ATRASADAS = "__ATRASADAS__";
|
|||
|
|
const MESLBL_CAP = {
|
|||
|
|
"01": "Enero", "02": "Febrero", "03": "Marzo", "04": "Abril", "05": "Mayo", "06": "Junio",
|
|||
|
|
"07": "Julio", "08": "Agosto", "09": "Septiembre", "10": "Octubre", "11": "Noviembre", "12": "Diciembre",
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function currentMonth() {
|
|||
|
|
const d = new Date();
|
|||
|
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
|||
|
|
}
|
|||
|
|
function mesAnterior(m, n) {
|
|||
|
|
const [y, mm] = m.split("-").map(Number);
|
|||
|
|
const d = new Date(y, mm - 1 - n, 1);
|
|||
|
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
|||
|
|
}
|
|||
|
|
function ventanaDeMes(win, hoyIso) {
|
|||
|
|
if (win === ATRASADAS) return { ini: hoyIso, fin: "9999-12-31" };
|
|||
|
|
const [y, m] = win.split("-").map(Number);
|
|||
|
|
const fin = new Date(y, m, 0);
|
|||
|
|
return { ini: `${win}-01`, fin: `${fin.getFullYear()}-${String(fin.getMonth() + 1).padStart(2, "0")}-${String(fin.getDate()).padStart(2, "0")}` };
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export default async function RenovPrevisionPage({ searchParams }) {
|
|||
|
|
const session = await auth();
|
|||
|
|
if (!session?.email) return <LoginPrompt />;
|
|||
|
|
|
|||
|
|
const sp = await searchParams;
|
|||
|
|
const { owner, w: winParam } = sp;
|
|||
|
|
const scope = ownerFilter(session, owner);
|
|||
|
|
const hoy = currentMonth();
|
|||
|
|
const filt = parseFiltParam(sp.f);
|
|||
|
|
const indActive = IND_TABS.some((t) => t.k === sp.ind) ? sp.ind : "owner";
|
|||
|
|
const mze = sp.mze;
|
|||
|
|
|
|||
|
|
let allRows, allUsers, historico, actividades;
|
|||
|
|
try {
|
|||
|
|
[allRows, allUsers, actividades] = await Promise.all([
|
|||
|
|
getRenovPipeline(session.accessToken, scope),
|
|||
|
|
session.isAdmin ? getSystemUsers(session.accessToken) : Promise.resolve([]),
|
|||
|
|
getActividades(session.accessToken, scope, EJECUTIVOS_RENOV),
|
|||
|
|
]);
|
|||
|
|
// Referencia honesta: MRR realmente renovado en los 3 meses cerrados anteriores.
|
|||
|
|
const meses3 = [mesAnterior(hoy, 1), mesAnterior(hoy, 2), mesAnterior(hoy, 3)];
|
|||
|
|
const won3 = await Promise.all(meses3.map((m) => getRenovClosed(session.accessToken, scope, 1, m)));
|
|||
|
|
historico = won3.map((w) => w.reduce((a, o) => a + (o.actual || 0), 0));
|
|||
|
|
} catch (error) {
|
|||
|
|
return <ErrorNotice error={error} />;
|
|||
|
|
}
|
|||
|
|
const owners = allUsers.filter((u) => EJECUTIVOS_RENOV.includes(u.name));
|
|||
|
|
const histProm = historico.length ? historico.reduce((a, b) => a + b, 0) / historico.length : 0;
|
|||
|
|
|
|||
|
|
// Informe de Previsión de Renovación — solo con un único propietario seleccionado. `historico`/
|
|||
|
|
// `histProm` de arriba ya vienen filtrados por `scope` — cuando hay un solo propietario
|
|||
|
|
// seleccionado (condición para que `ownerName` exista), esas consultas ya son de esa persona:
|
|||
|
|
// no hace falta volver a pedirle a Dynamics el histórico.
|
|||
|
|
const ownerName = scope.emails?.length === 1
|
|||
|
|
? session.isAdmin
|
|||
|
|
? allUsers.find((u) => u.email === scope.emails[0])?.name
|
|||
|
|
: session.user?.name
|
|||
|
|
: null;
|
|||
|
|
let renovPrevisionReportContent = null;
|
|||
|
|
if (ownerName) {
|
|||
|
|
const baseOwner = allRows.filter((o) => o.owner === ownerName);
|
|||
|
|
const proxMes = mesSiguiente(hoy);
|
|||
|
|
const atrasadasOwner = baseOwner.filter((o) => !o.mesCierre || o.mesCierre < hoy);
|
|||
|
|
const atrasadasEst = atrasadasOwner.reduce((a, o) => a + o.est, 0);
|
|||
|
|
const pMesOwner = baseOwner.filter((o) => o.mesCierre === hoy);
|
|||
|
|
const pProxOwner = baseOwner.filter((o) => o.mesCierre === proxMes);
|
|||
|
|
const fcMesOwner = pMesOwner.reduce((a, o) => a + o.fc, 0);
|
|||
|
|
const fcProxOwner = pProxOwner.reduce((a, o) => a + o.fc, 0);
|
|||
|
|
const cobMes = histProm ? Math.round((fcMesOwner / histProm) * 100) : null;
|
|||
|
|
const bloqueadas = { precio: [], aprobacion: [], licitacion: [] };
|
|||
|
|
pMesOwner.forEach((o) => {
|
|||
|
|
const cat = classifyBlocker(o.estado);
|
|||
|
|
if (cat) bloqueadas[cat].push(o);
|
|||
|
|
});
|
|||
|
|
const subibles = pMesOwner
|
|||
|
|
.filter((o) => (o.plan === "Plan B - En Negociación" || o.plan === "Plan C - En seguimiento") && !o.estanc && !bloqueadas.precio.includes(o) && !bloqueadas.aprobacion.includes(o))
|
|||
|
|
.sort((a, b) => b.fc - a.fc);
|
|||
|
|
const estancSinBloqueo = pMesOwner.filter((o) => o.estanc && !classifyBlocker(o.estado));
|
|||
|
|
const diagClass = histProm === 0 ? "info" : cobMes >= 100 ? "info" : cobMes >= 70 ? "warn" : "bad";
|
|||
|
|
const lblMesCap = MESLBL_CAP[hoy.slice(5, 7)] || hoy;
|
|||
|
|
const lblProxCap = MESLBL_CAP[proxMes.slice(5, 7)] || proxMes;
|
|||
|
|
|
|||
|
|
renovPrevisionReportContent = (
|
|||
|
|
<>
|
|||
|
|
<div style={{ borderBottom: "3px solid var(--ancla)", paddingBottom: 16, marginBottom: 20, display: "flex", justifyContent: "space-between", alignItems: "flex-end", flexWrap: "wrap", gap: 10 }}>
|
|||
|
|
<div>
|
|||
|
|
<div style={{ fontSize: 11, textTransform: "uppercase", letterSpacing: ".06em", color: "var(--tinta-suave)" }}>Informe de previsión de renovaciones — {lblMesCap}</div>
|
|||
|
|
<h2 style={{ margin: "4px 0 0", color: "var(--ancla)", fontSize: 24 }}>{ownerName}</h2>
|
|||
|
|
</div>
|
|||
|
|
<div style={{ textAlign: "right", fontSize: 12, color: "var(--tinta-suave)" }}>Incluye oportunidades sin Plan de Cierre — el contrato vence igual</div>
|
|||
|
|
</div>
|
|||
|
|
<div className="kpis" style={{ marginBottom: 18 }}>
|
|||
|
|
<div className="kpi"><span className={`n ${atrasadasOwner.length ? "pierde" : ""}`}>{atrasadasOwner.length}</span><span className="l">Ya vencidas y sin cerrar · {money(atrasadasEst)}</span></div>
|
|||
|
|
<div className="kpi"><span className="n">{money(fcMesOwner)}</span><span className="l">Forecast ponderado {lblMesCap}</span></div>
|
|||
|
|
{histProm > 0 && <div className="kpi"><span className={`n ${cobMes < 100 ? "pierde" : ""}`}>{cobMes}%</span><span className="l">vs. promedio renovado últimos 3 meses ({money(histProm)})</span></div>}
|
|||
|
|
<div className="kpi"><span className="n">{money(fcProxOwner)}</span><span className="l">Forecast ponderado {lblProxCap}</span></div>
|
|||
|
|
</div>
|
|||
|
|
<PanelesCalidad p={pMesOwner} />
|
|||
|
|
<div className={`callout ${diagClass}`}>
|
|||
|
|
{histProm === 0 ? (
|
|||
|
|
<><b>{ownerName.split(" ")[0]} no tiene renovaciones ganadas en los 3 meses anteriores</b> — este informe muestra el forecast de {lblMesCap} pero sin un piso histórico propio contra qué compararlo.</>
|
|||
|
|
) : cobMes >= 100 ? (
|
|||
|
|
<><b>El forecast ponderado de {lblMesCap} ({money(fcMesOwner)}) ya iguala o supera lo renovado en promedio los últimos 3 meses ({money(histProm)}).</b> El foco es sostener el ritmo, no solo cubrir el número.</>
|
|||
|
|
) : (
|
|||
|
|
<><b>El forecast ponderado de {lblMesCap} ({money(fcMesOwner)}) queda por debajo del promedio renovado los últimos 3 meses ({money(histProm)}).</b> Así se cierra la brecha, en orden de impacto:</>
|
|||
|
|
)}
|
|||
|
|
</div>
|
|||
|
|
{bloqueadas.precio.length > 0 && (
|
|||
|
|
<div className="panel" style={{ marginBottom: 14 }}>
|
|||
|
|
<h3>1. Palanca de precio — {bloqueadas.precio.length} oport. · {money(bloqueadas.precio.reduce((a, o) => a + o.fc, 0))} ponderado en juego</h3>
|
|||
|
|
<p className="hint">{BLOCKER_INFO.precio.accion}</p>
|
|||
|
|
<AccionTable list={bloqueadas.precio} />
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{bloqueadas.aprobacion.length > 0 && (
|
|||
|
|
<div className="panel" style={{ marginBottom: 14 }}>
|
|||
|
|
<h3>2. Palanca de aprobación interna — {bloqueadas.aprobacion.length} oport. · {money(bloqueadas.aprobacion.reduce((a, o) => a + o.fc, 0))} ponderado en juego</h3>
|
|||
|
|
<p className="hint">{BLOCKER_INFO.aprobacion.accion}</p>
|
|||
|
|
<AccionTable list={bloqueadas.aprobacion} />
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{subibles.length > 0 && (
|
|||
|
|
<div className="panel" style={{ marginBottom: 14 }}>
|
|||
|
|
<h3>3. Subir de plan esta semana — {subibles.length} oport. en Plan B/C activas</h3>
|
|||
|
|
<p className="hint">Sin bloqueo ni estancamiento, por forecast ponderado.</p>
|
|||
|
|
<AccionTable list={subibles} />
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{estancSinBloqueo.length > 0 && (
|
|||
|
|
<div className="panel" style={{ marginBottom: 14 }}>
|
|||
|
|
<h3>4. Reactivar sin motivo claro — {estancSinBloqueo.length} oport. estancadas</h3>
|
|||
|
|
<p className="hint">Sin razón en las notas: necesitan un toque esta semana.</p>
|
|||
|
|
<AccionTable list={estancSinBloqueo} />
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{bloqueadas.licitacion.length > 0 && (
|
|||
|
|
<div className="callout info">
|
|||
|
|
<b>{bloqueadas.licitacion.length} renovación(es) en licitación externa</b> ({money(bloqueadas.licitacion.reduce((a, o) => a + o.fc, 0))} ponderado) — fuera de control directo este mes, mantener la relación.
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{atrasadasOwner.length > 0 && (
|
|||
|
|
<>
|
|||
|
|
<div className="callout bad" style={{ marginTop: 22 }}>
|
|||
|
|
<b>{atrasadasOwner.length} renovaciones ya pasaron su fecha estimada y siguen abiertas</b> ({money(atrasadasEst)} de MRR expuesto)
|
|||
|
|
</div>
|
|||
|
|
<RepTable arr={atrasadasOwner} />
|
|||
|
|
</>
|
|||
|
|
)}
|
|||
|
|
<div className="callout warn" style={{ marginTop: 22 }}>
|
|||
|
|
<b>{lblProxCap}: {money(fcProxOwner)} de forecast ({pProxOwner.length} renovaciones)</b> por vencer el mes siguiente.
|
|||
|
|
</div>
|
|||
|
|
</>
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const futuros = [...new Set(allRows.map((o) => o.mesCierre).filter((m) => m && m >= hoy))].sort();
|
|||
|
|
const atrasadas = allRows.filter((o) => !o.mesCierre || o.mesCierre < hoy);
|
|||
|
|
const win = winParam === ATRASADAS ? ATRASADAS : futuros.includes(winParam) ? winParam : futuros[0] || hoy;
|
|||
|
|
const hoyIso = new Date().toISOString().slice(0, 10);
|
|||
|
|
const { ini, fin: finVentana } = ventanaDeMes(win, hoyIso);
|
|||
|
|
const pWinRaw = win === ATRASADAS ? atrasadas : allRows.filter((o) => o.mesCierre === win);
|
|||
|
|
const pWin = decorarActividadVentana(pWinRaw, actividades, ini, finVentana);
|
|||
|
|
const p = applyFilt(pWin, filt);
|
|||
|
|
const stageDurations = indActive === "vel" ? await getStageDurations(p.map((o) => o.id), session.accessToken) : [];
|
|||
|
|
const winLbl = win === ATRASADAS ? "renovaciones atrasadas (fecha estimada ya vencida)" : MESLBL_CAP[win.slice(5, 7)] || win;
|
|||
|
|
|
|||
|
|
const est = p.reduce((a, o) => a + o.est, 0);
|
|||
|
|
const fc = p.reduce((a, o) => a + o.fc, 0);
|
|||
|
|
const estanc = p.filter((o) => o.estanc);
|
|||
|
|
const sinPlan = p.filter((o) => o.plan === "Sin plan de cierre");
|
|||
|
|
const cob = histProm ? Math.round((fc / histProm) * 100) : null;
|
|||
|
|
|
|||
|
|
const porMes = futuros.map((m) => ({
|
|||
|
|
lbl: MESLBL_CAP[m.slice(5, 7)] || m,
|
|||
|
|
n: allRows.filter((o) => o.mesCierre === m).length,
|
|||
|
|
est: allRows.filter((o) => o.mesCierre === m).reduce((a, o) => a + o.est, 0),
|
|||
|
|
}));
|
|||
|
|
|
|||
|
|
const linkFor = (w) => {
|
|||
|
|
const params = new URLSearchParams();
|
|||
|
|
if (owner) params.set("owner", owner);
|
|||
|
|
params.set("w", w);
|
|||
|
|
return `/renovaciones/prevision?${params.toString()}`;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
return (
|
|||
|
|
<div style={{ padding: 24 }}>
|
|||
|
|
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 12 }}>
|
|||
|
|
<h2>Previsión de Renovaciones</h2>
|
|||
|
|
<div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|||
|
|
<ReportModal
|
|||
|
|
buttonLabel="📈 Informe de Previsión"
|
|||
|
|
disabled={!ownerName}
|
|||
|
|
disabledTitle="Selecciona un solo ejecutivo en Propietario para generar su informe individual."
|
|||
|
|
>
|
|||
|
|
{renovPrevisionReportContent}
|
|||
|
|
</ReportModal>
|
|||
|
|
<OwnerControl owners={owners} current={scope.locked ? [session.email] : scope.emails} locked={scope.locked} lockedLabel={session.email} />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div className="seg-tabs" style={{ marginBottom: 16, flexWrap: "wrap" }}>
|
|||
|
|
{atrasadas.length > 0 && (
|
|||
|
|
<a href={linkFor(ATRASADAS)}>
|
|||
|
|
<button className={win === ATRASADAS ? "on" : ""} type="button">⚠ Atrasadas ({atrasadas.length})</button>
|
|||
|
|
</a>
|
|||
|
|
)}
|
|||
|
|
{futuros.map((m) => (
|
|||
|
|
<a key={m} href={linkFor(m)}>
|
|||
|
|
<button className={win === m ? "on" : ""} type="button">{MESLBL_CAP[m.slice(5, 7)] || m}</button>
|
|||
|
|
</a>
|
|||
|
|
))}
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div className="kpis">
|
|||
|
|
<div className="kpi"><span className="n">{p.length}</span><span className="l">Renovaciones que vencen en {winLbl}</span></div>
|
|||
|
|
<div className="kpi"><span className="n">{money(est)}</span><span className="l">MRR en juego</span></div>
|
|||
|
|
<div className="kpi"><span className="n">{money(fc)}</span><span className="l">Forecast ponderado</span></div>
|
|||
|
|
<div className="kpi">
|
|||
|
|
<span className={`n ${cob != null && cob < 100 ? "pierde" : ""}`}>{cob == null ? "n/d" : `${cob}%`}</span>
|
|||
|
|
<span className="l">vs. promedio renovado últimos 3 meses ({money(histProm)})</span>
|
|||
|
|
</div>
|
|||
|
|
<div className="kpi"><span className="n pierde">{estanc.length}</span><span className="l">En riesgo (estancadas)</span></div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div className={`callout ${cob != null && cob < 100 ? "warn" : "info"}`}>
|
|||
|
|
{win === ATRASADAS ? (
|
|||
|
|
<><b>Estas {p.length} renovaciones ya pasaron su fecha estimada y siguen abiertas.</b> En renovación el
|
|||
|
|
tiempo juega en contra de forma literal: el contrato vence igual, con o sin gestión. </>
|
|||
|
|
) : (
|
|||
|
|
<><b>{winLbl}: {money(est)} de MRR vence este mes</b> en {p.length} contratos, con un forecast ponderado
|
|||
|
|
de {money(fc)}. </>
|
|||
|
|
)}
|
|||
|
|
<b>Acá no se compara contra meta</b> — la meta comercial no incluye renovaciones. La referencia útil es lo
|
|||
|
|
que se renovó de verdad en los 3 meses anteriores ({money(histProm)} en promedio). <b>Forecast ponderado =
|
|||
|
|
Σ (MRR × peso del Plan de Cierre)</b>: A 90% · B 60% · C 30% · sin plan 10%.
|
|||
|
|
</div>
|
|||
|
|
{sinPlan.length > 0 && (
|
|||
|
|
<div className="callout warn">
|
|||
|
|
<b>{sinPlan.length} de estas {p.length} no tienen Plan de Cierre</b> ({money(sinPlan.reduce((a, o) => a + o.est, 0))}).
|
|||
|
|
A diferencia de Previsión de Ventas, acá <b>se cuentan</b> (el contrato vence tenga plan o no) y pesan solo 10% en el ponderado.
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
{porMes.length > 1 && (
|
|||
|
|
<div className="callout warn">
|
|||
|
|
<b>Vencimientos por delante:</b> {porMes.map((m) => `${m.lbl} — ${money(m.est)} (${m.n})`).join(" · ")}.
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
|
|||
|
|
{p.length > 0 && <ExecMatrix arr={p} titulo="Renovaciones por vencer, por ejecutivo" hint="Monto = MRR en juego" activeDim={mze} />}
|
|||
|
|
|
|||
|
|
<div className="sec-div"><span>Indicadores y detalle</span></div>
|
|||
|
|
<BuscadorOportunidades />
|
|||
|
|
<FilterChips dimLabels={DIM_LABELS} />
|
|||
|
|
{pWin.length === 0 ? (
|
|||
|
|
<p>No hay renovaciones en esta ventana.</p>
|
|||
|
|
) : (
|
|||
|
|
<div className="split23">
|
|||
|
|
<div className="split23-ind">
|
|||
|
|
<Panel
|
|||
|
|
title="Por momento de la renovación"
|
|||
|
|
hint="Ya vencido vs. próximo a vencer"
|
|||
|
|
rows={agg(p, "tipo", (o) => o.est)}
|
|||
|
|
cls="alerta"
|
|||
|
|
dimKey="tipo"
|
|||
|
|
/>
|
|||
|
|
<Panel
|
|||
|
|
title="¿Ya se agendó algo?"
|
|||
|
|
hint={`Tarea/Cita/Llamada dentro de ${winLbl}`}
|
|||
|
|
rows={aggOrd(p, "actAgendada", ACTAGENDADA_ORDEN, (o) => o.est)}
|
|||
|
|
cls="alerta"
|
|||
|
|
dimKey="actAgendada"
|
|||
|
|
/>
|
|||
|
|
<div className="panel" style={{ paddingBottom: 4 }}>
|
|||
|
|
<SegTabs tabs={IND_TABS} activeKey={indActive} paramName="ind" />
|
|||
|
|
</div>
|
|||
|
|
{indActive === "vel" ? (
|
|||
|
|
<VelPanel
|
|||
|
|
title="Velocidad de movimiento"
|
|||
|
|
hint={`Días promedio en cada fase ya completada, de las ${p.length} renovaciones que ves ahora`}
|
|||
|
|
vel={pipeVelFor(p, stageDurations)}
|
|||
|
|
/>
|
|||
|
|
) : (
|
|||
|
|
<Panel
|
|||
|
|
title={IND_TITULOS[indActive]}
|
|||
|
|
hint={IND_HINTS[indActive]}
|
|||
|
|
rows={agg(p, indActive, (o) => o.est)}
|
|||
|
|
top={IND_TOP[indActive]}
|
|||
|
|
dimKey={indActive}
|
|||
|
|
/>
|
|||
|
|
)}
|
|||
|
|
</div>
|
|||
|
|
<div>
|
|||
|
|
<div className="panel" style={{ paddingBottom: 6 }}>
|
|||
|
|
<h3>Renovaciones con vencimiento en {winLbl}</h3>
|
|||
|
|
<p className="hint">Forecast = MRR × peso del plan</p>
|
|||
|
|
</div>
|
|||
|
|
<TablaPipe arr={p} tipo="fc" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
)}
|
|||
|
|
</div>
|
|||
|
|
);
|
|||
|
|
}
|