Actualizar backend/modules/cobranza/processor.py
This commit is contained in:
@@ -416,6 +416,15 @@ class CobranzaProcessor:
|
||||
mapa_programa = {}
|
||||
mapa_sectorista = {} # <-- NUEVO MAPA PARA CORREGIR ASESORES
|
||||
|
||||
# Sectorista puede venir con varios separados por coma (multi). Vacío/TODOS = todos.
|
||||
_sec_set = {s.strip() for s in str(sectorista_filtro or "TODOS").split(",") if s.strip()}
|
||||
_sec_all = (not _sec_set) or ("TODOS" in _sec_set)
|
||||
# Sede/Programa filtro también multi (coma). Vacío/TODOS = todos.
|
||||
_sede_set = {s.strip().upper() for s in str(sede_filtro or "TODOS").split(",") if s.strip()}
|
||||
_sede_all = (not _sede_set) or ("TODOS" in _sede_set)
|
||||
_prog_set = {p.strip().upper() for p in str(prog_filtro or "TODOS").split(",") if p.strip()}
|
||||
_prog_all = (not _prog_set) or ("TODOS" in _prog_set)
|
||||
|
||||
for fila in cronograma_raw:
|
||||
sectorista_str = str(fila.get('dsc_sectorista', ''))
|
||||
sectorista_clean = sectorista_str.strip()
|
||||
@@ -426,7 +435,7 @@ class CobranzaProcessor:
|
||||
mapa_sectorista[idx] = sectorista_clean if sectorista_clean and sectorista_clean not in [",", "None"] else "SIN ASESOR"
|
||||
|
||||
if sectorista_clean in [",", "", "None"] or sectorista_str == " , ": continue
|
||||
if sectorista_filtro != "TODOS" and sectorista_clean != sectorista_filtro: continue
|
||||
if not _sec_all and sectorista_clean not in _sec_set: continue
|
||||
|
||||
if idx: indices_cronograma.add(idx)
|
||||
|
||||
@@ -450,11 +459,11 @@ class CobranzaProcessor:
|
||||
# Filtro por SEDE y PROGRAMA (REPLACE_META) — se aplica en cualquier
|
||||
# agrupación cuando se pide (usado sobre todo en ASESOR).
|
||||
_prog = fila.get('dsc_programa', '')
|
||||
if str(sede_filtro).upper() not in ("TODOS", "", "NONE"):
|
||||
if str(self.clasificar_sede_meta(_prog)).upper() != str(sede_filtro).upper():
|
||||
if not _sede_all:
|
||||
if str(self.clasificar_sede_meta(_prog)).upper() not in _sede_set:
|
||||
continue
|
||||
if str(prog_filtro).upper() not in ("TODOS", "", "NONE"):
|
||||
if str(self.clasificar_filtro_programa(_prog)).upper() != str(prog_filtro).upper():
|
||||
if not _prog_all:
|
||||
if str(self.clasificar_filtro_programa(_prog)).upper() not in _prog_set:
|
||||
continue
|
||||
|
||||
# Filtro por F. Vencimiento (<=). Sin fecha => se incluye siempre.
|
||||
@@ -511,11 +520,11 @@ class CobranzaProcessor:
|
||||
|
||||
# Mismo filtro SEDE/PROGRAMA (REPLACE_META) que en el cronograma.
|
||||
_progF = fila.get('dsc_programa', '')
|
||||
if str(sede_filtro).upper() not in ("TODOS", "", "NONE"):
|
||||
if str(self.clasificar_sede_meta(_progF)).upper() != str(sede_filtro).upper():
|
||||
if not _sede_all:
|
||||
if str(self.clasificar_sede_meta(_progF)).upper() not in _sede_set:
|
||||
continue
|
||||
if str(prog_filtro).upper() not in ("TODOS", "", "NONE"):
|
||||
if str(self.clasificar_filtro_programa(_progF)).upper() != str(prog_filtro).upper():
|
||||
if not _prog_all:
|
||||
if str(self.clasificar_filtro_programa(_progF)).upper() not in _prog_set:
|
||||
continue
|
||||
|
||||
# Filtro por F. Vencimiento (<=). En facturas la fecha es fch_vencimiento_cuota.
|
||||
@@ -674,10 +683,14 @@ class CobranzaProcessor:
|
||||
mapa_tc = {}
|
||||
mapa_programa_frec = {}
|
||||
|
||||
# Sectorista multi (coma). Vacío/TODOS = todos.
|
||||
_sec_set = {s.strip() for s in str(sectorista_filtro or "TODOS").split(",") if s.strip()}
|
||||
_sec_all = (not _sec_set) or ("TODOS" in _sec_set)
|
||||
|
||||
for fila in cronograma_raw:
|
||||
sectorista_str = str(fila.get('dsc_sectorista', '')).strip()
|
||||
if sectorista_str in [",", ""] or fila.get('dsc_sectorista') == " , ": continue
|
||||
if sectorista_filtro != "TODOS" and sectorista_str != sectorista_filtro: continue
|
||||
if not _sec_all and sectorista_str not in _sec_set: continue
|
||||
|
||||
prog = str(fila.get('dsc_det_programa', '')).strip()
|
||||
if not prog or prog == "None": prog = "SIN PROGRAMA"
|
||||
|
||||
Reference in New Issue
Block a user