Actualizar backend/modules/cobranza/logic.py

This commit is contained in:
2026-07-03 15:28:29 -05:00
parent 27787b97be
commit 2f8fae01ca

View File

@@ -96,9 +96,10 @@ class CobranzaLogic:
for d in datos_brutos:
mat = d.get('MATRICULA', '')
alumno = d.get('ALUMNO', '')
num_cuota = d.get('NUM_CUOTA', '-')
fch_venc = d.get('FCH_VENC', '-')
num_cuota = d.get('NUM_CUOTA', '-')
fch_venc = d.get('FCH_VENC', '-')
programa = d.get('PROGRAMA', '-') # programa detallado del alumno
cta_ant = float(d.get('CTA_COB_ANT', 0.0))
cta_cur = float(d.get('CTA_COB_MES_CURSO', 0.0))
cta_tot = float(d.get('TOTAL_CTA_COB', 0.0))
@@ -106,24 +107,24 @@ class CobranzaLogic:
cob_cur = float(d.get('COB_MES_CURSO', 0.0))
cob_tot = float(d.get('TOTAL_COBRADO', 0.0))
saldo = float(d.get('SALDO', 0.0))
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_saldo += saldo
r1 = (cob_ant / cta_ant) * 100 if cta_ant > 0 else 0.0
r2 = (cob_cur / cta_cur) * 100 if cta_cur > 0 else 0.0
r3 = (cob_tot / cta_tot) * 100 if cta_tot > 0 else 0.0
avance_ant = f"{r1:.0f}%" if cta_ant > 0 else ""
avance_cur = f"{r2:.0f}%" if cta_cur > 0 else ""
avance_tot = f"{r3:.0f}%" if cta_tot > 0 else ""
fila = [
mat, alumno, num_cuota, fch_venc,
mat, alumno, num_cuota, fch_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}"
f"S/ {saldo:,.0f}",
programa # índice [14]: PROGRAMA (extra, al final; no altera columnas previas)
]
sheet_data.append(fila)
@@ -132,11 +133,12 @@ class CobranzaLogic:
r_tot_3 = (t_cob_tot / t_cta_tot) * 100 if t_cta_tot > 0 else 0.0
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}",
"" # índice [14]: PROGRAMA vacío en la fila total
]
sheet_data.append(fila_total)
return sheet_data