diff --git a/backend/modules/cobranza/logic.py b/backend/modules/cobranza/logic.py index 1e6487a..97252e4 100644 --- a/backend/modules/cobranza/logic.py +++ b/backend/modules/cobranza/logic.py @@ -11,12 +11,15 @@ class CobranzaLogic: return self.processor.obtener_lista_sectoristas(ano, mes) def obtener_datos_tabla(self, ano, mes, sectorista="TODOS", agrupacion="SEDE", - sede_filtro="TODOS", prog_filtro="TODOS", venc_hasta=None): + sede_filtro="TODOS", prog_filtro="TODOS", venc_hasta=None, + mats_retirar=None): datos_brutos = self.processor.obtener_datos_procesados(ano, mes, sectorista, agrupacion, - sede_filtro, prog_filtro, venc_hasta) - + sede_filtro, prog_filtro, venc_hasta, + mats_retirar) + sheet_data = [] t_cta_ant = t_cta_cur = t_cta_tot = t_cob_ant = t_cob_cur = t_cob_tot = t_saldo = 0.0 + t_saldo_ret = 0.0 for d in datos_brutos: grupo = d.get('GRUPO', '') @@ -34,15 +37,17 @@ class CobranzaLogic: cob_tot = float(d.get('TOTAL_COBRADO', 0.0)) r3 = float(d.get('RATIO_3', 0.0)) saldo = float(d.get('SALDO', 0.0)) + saldo_ret = float(d.get('SALDO_RETIRAR', 0.0)) opciones = d.get('OPCIONES', ' ≡ ▼ ') - + t_cta_ant += cta_ant t_cta_cur += cta_cur t_cta_tot += cta_tot t_cob_ant += cob_ant t_cob_cur += cob_cur - t_cob_tot += cob_tot + t_cob_tot += cob_tot t_saldo += saldo + t_saldo_ret += saldo_ret avance_ant = f"{r1:.0f}%" if cta_ant > 0 else "" avance_cur = f"{r2:.0f}%" if cta_cur > 0 else "" @@ -50,19 +55,19 @@ class CobranzaLogic: if agrupacion == "PROGRAMA": fila = [ - grupo, frecuencia, num_cuota, fecha_venc, + grupo, frecuencia, num_cuota, fecha_venc, f"S/ {cta_ant:,.0f}", f"S/ {cob_ant:,.0f}", avance_ant, f"S/ {cta_cur:,.0f}", f"S/ {cob_cur:,.0f}", avance_cur, f"S/ {cta_tot:,.0f}", f"S/ {cob_tot:,.0f}", avance_tot, - f"S/ {saldo:,.0f}", opciones + f"S/ {saldo:,.0f}", f"S/ {saldo_ret:,.0f}", opciones ] else: fila = [ - grupo, + grupo, f"S/ {cta_ant:,.0f}", f"S/ {cob_ant:,.0f}", avance_ant, f"S/ {cta_cur:,.0f}", f"S/ {cob_cur:,.0f}", avance_cur, f"S/ {cta_tot:,.0f}", f"S/ {cob_tot:,.0f}", avance_tot, - f"S/ {saldo:,.0f}", opciones + f"S/ {saldo:,.0f}", f"S/ {saldo_ret:,.0f}", opciones ] sheet_data.append(fila) @@ -72,11 +77,11 @@ class CobranzaLogic: if agrupacion == "PROGRAMA": fila_total = [ - "TOTAL GENERAL", "-", "-", "-", + "TOTAL GENERAL", "-", "-", "-", f"S/ {t_cta_ant:,.0f}", f"S/ {t_cob_ant:,.0f}", f"{r_tot_1:.0f}%", f"S/ {t_cta_cur:,.0f}", f"S/ {t_cob_cur:,.0f}", f"{r_tot_2:.0f}%", - f"S/ {t_cta_tot:,.0f}", f"S/ {t_cob_tot:,.0f}", f"{r_tot_3:.0f}%", - f"S/ {t_saldo:,.0f}", "" + f"S/ {t_cta_tot:,.0f}", f"S/ {t_cob_tot:,.0f}", f"{r_tot_3:.0f}%", + f"S/ {t_saldo:,.0f}", f"S/ {t_saldo_ret:,.0f}", "" ] else: fila_total = [ @@ -84,7 +89,7 @@ class CobranzaLogic: f"S/ {t_cta_ant:,.0f}", f"S/ {t_cob_ant:,.0f}", f"{r_tot_1:.0f}%", f"S/ {t_cta_cur:,.0f}", f"S/ {t_cob_cur:,.0f}", f"{r_tot_2:.0f}%", f"S/ {t_cta_tot:,.0f}", f"S/ {t_cob_tot:,.0f}", f"{r_tot_3:.0f}%", - f"S/ {t_saldo:,.0f}", "" + f"S/ {t_saldo:,.0f}", f"S/ {t_saldo_ret:,.0f}", "" ] sheet_data.append(fila_total) return sheet_data