import services as S
from collections import Counter

rows = S._cartera_rows_cache()
print("TOTAL filas cartera:", len(rows))

si = [r for r in rows if str(r.get("es_origen") or "").strip().upper() == "SI"]
print("Filas es_origen=SI:", len(si))
print("Valores es_origen:", Counter(str(r.get("es_origen")) for r in rows).most_common(10))

ase = S._asesores(); amap = ase["map"]
cnt_si  = sum(1 for r in si   if S._norm_asesor(r.get("asesor"), amap) == "ALMENDRA PERALTA")
cnt_all = sum(1 for r in rows if S._norm_asesor(r.get("asesor"), amap) == "ALMENDRA PERALTA")
print("Almendra en es_origen=SI :", cnt_si)
print("Almendra en TODA cartera :", cnt_all)
