Initial commit - dashboard leads

This commit is contained in:
Panchito
2026-08-18 11:48:08 -05:00
commit e90dae89b6
5148 changed files with 714437 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
# diag_matri_51_perdida.py
# Busca la matricula #51: revisa TODAS las de agosto (incluso ANU/RET) para ver
# cual pudo aparecer/desaparecer. Va directo a SQL Server (fresco, sin cache).
from datetime import datetime
import services as S
import leads_logic as L
ANO, MES = 2026, 8
ase = S._asesores(); amap = ase["map"]
# TODAS las matriculas de agosto (sin excluir estado), directo de traer_matriculas
todas = []
for m in S.get_dm().traer_matriculas():
fm = L._to_date(m.get("fch_matricula"))
if not (fm and fm.year==ANO and fm.month==MES): continue
todas.append(m)
print(f"=== TODAS las matriculas de agosto {ANO} (cualquier estado): {len(todas)} ===\n")
from collections import Counter
est = Counter(str(m.get("estado_matricula") or "").strip().upper() for m in todas)
print("Por estado:", dict(est))
# las que cuentan (no ANU, asesor de los 8)
cuentan = 0
no_asesor = 0
anu = 0
for m in todas:
e = str(m.get("estado_matricula") or "").strip().upper()
if e == "ANU":
anu += 1; continue
v = S._norm_asesor(m.get("dsc_vendedor"), amap)
if not v:
no_asesor += 1
print(f" [FUERA 8] mat={m.get('num_matricula')} asesor='{m.get('dsc_vendedor')}' est={e} "
f"grupo={L.grupo_programa_curso(m.get('dsc_programa'))}")
continue
cuentan += 1
print(f"\nCuentan (no ANU + asesor de los 8): {cuentan}")
print(f"Anuladas (ANU): {anu}")
print(f"Con asesor fuera de los 8: {no_asesor}")
# mostrar TODAS con su estado para ver si hay algo raro (RET, SUS, etc.)
print(f"\n=== Detalle: matriculas con estado != ALU/PRE (posibles casos raros) ===")
for m in todas:
e = str(m.get("estado_matricula") or "").strip().upper()
if e not in ("ALU","PRE"):
v = S._norm_asesor(m.get("dsc_vendedor"), amap)
fm = L._to_date(m.get("fch_matricula"))
print(f" mat={m.get('num_matricula')} est={e} asesor={v or m.get('dsc_vendedor')} "
f"{str(fm)[:10]} grupo={L.grupo_programa_curso(m.get('dsc_programa'))}")