Actualizar backend/core/data_manager.py

This commit is contained in:
2026-10-05 16:41:00 -05:00
parent a755781877
commit 6a584471e6

View File

@@ -707,13 +707,16 @@ class DataManager:
if not mats: if not mats:
return {} return {}
corte_venc = "CAST(GETDATE() AS DATE)" corte_venc = "CAST(GETDATE() AS DATE)"
ini_mes = "CAST(GETDATE() AS DATE)"
if ano and mes: if ano and mes:
try: try:
_a, _m = int(ano), int(mes) _a, _m = int(ano), int(mes)
_na, _nm = (_a + 1, 1) if _m == 12 else (_a, _m + 1) _na, _nm = (_a + 1, 1) if _m == 12 else (_a, _m + 1)
corte_venc = f"CAST('{_na:04d}-{_nm:02d}-01' AS DATE)" corte_venc = f"CAST('{_na:04d}-{_nm:02d}-01' AS DATE)"
ini_mes = f"CAST('{_a:04d}-{_m:02d}-01' AS DATE)"
except Exception: except Exception:
corte_venc = "CAST(GETDATE() AS DATE)" corte_venc = "CAST(GETDATE() AS DATE)"
ini_mes = "CAST(GETDATE() AS DATE)"
try: try:
conn = self.get_connection() conn = self.get_connection()
cursor = conn.cursor() cursor = conn.cursor()
@@ -742,14 +745,33 @@ class DataManager:
AND c.cod_tipo_cuota = 'ARM' AND c.cod_tipo_cuota = 'ARM'
AND c.cod_estado <> 'CAN' AND c.cod_estado <> 'CAN'
AND c.fch_vencimiento < {corte_venc}) AS num_cuotas_vencidas, AND c.fch_vencimiento < {corte_venc}) AS num_cuotas_vencidas,
(SELECT MIN(c.fch_vencimiento) STUFF((SELECT ' - ' + CONVERT(varchar(10), c.fch_vencimiento, 103)
FROM sgede_cronograma_matricula c FROM sgede_cronograma_matricula c
WHERE c.cod_localidad = m.cod_localidad WHERE c.cod_localidad = m.cod_localidad
AND c.num_matricula = m.num_matricula AND c.num_matricula = m.num_matricula
AND c.num_refinanciamiento = m.num_refinanciamiento AND c.num_refinanciamiento = m.num_refinanciamiento
AND c.cod_tipo_cuota = 'ARM' AND c.cod_tipo_cuota = 'ARM'
AND c.cod_estado <> 'CAN' AND c.cod_estado <> 'CAN'
AND c.fch_vencimiento < {corte_venc}) AS fch_venc_mas_antigua, AND c.fch_vencimiento < {corte_venc}
ORDER BY c.fch_vencimiento
FOR XML PATH('')), 1, 3, '') AS fch_venc_mas_antigua,
ISNULL((SELECT SUM(c.imp_total - ISNULL(c.imp_dscto,0) - ISNULL(c.imp_total_pagado,0))
FROM sgede_cronograma_matricula c
WHERE c.cod_localidad = m.cod_localidad
AND c.num_matricula = m.num_matricula
AND c.num_refinanciamiento = m.num_refinanciamiento
AND c.cod_tipo_cuota = 'ARM'
AND c.cod_estado <> 'CAN'
AND c.fch_vencimiento < {ini_mes}), 0) AS monto_venc_ant,
ISNULL((SELECT SUM(c.imp_total - ISNULL(c.imp_dscto,0) - ISNULL(c.imp_total_pagado,0))
FROM sgede_cronograma_matricula c
WHERE c.cod_localidad = m.cod_localidad
AND c.num_matricula = m.num_matricula
AND c.num_refinanciamiento = m.num_refinanciamiento
AND c.cod_tipo_cuota = 'ARM'
AND c.cod_estado <> 'CAN'
AND c.fch_vencimiento >= {ini_mes}
AND c.fch_vencimiento < {corte_venc}), 0) AS monto_venc_cur,
(SELECT SUM(c.imp_total_pagado) (SELECT SUM(c.imp_total_pagado)
FROM sgede_cronograma_matricula c FROM sgede_cronograma_matricula c
WHERE c.cod_localidad = m.cod_localidad WHERE c.cod_localidad = m.cod_localidad
@@ -786,15 +808,19 @@ class DataManager:
_mult = _tc if _moneda == "DOL" else 1.0 _mult = _tc if _moneda == "DOL" else 1.0
_pag = float(f.get("imp_total_pagado") or 0) * _mult _pag = float(f.get("imp_total_pagado") or 0) * _mult
_inv = float(f.get("inv_neta") or 0) * _mult _inv = float(f.get("inv_neta") or 0) * _mult
_mva = float(f.get("monto_venc_ant") or 0) * _mult
_mvc = float(f.get("monto_venc_cur") or 0) * _mult
out[str(f.get("num_matricula", "")).strip()] = { out[str(f.get("num_matricula", "")).strip()] = {
"dsc_vendedor": str(f.get("dsc_vendedor") or "").strip(), "dsc_vendedor": str(f.get("dsc_vendedor") or "").strip(),
"cod_detalle": str(f.get("cod_detalle") or "").strip(), "cod_detalle": str(f.get("cod_detalle") or "").strip(),
"dsc_alumno": str(f.get("dsc_alumno") or "").strip(), "dsc_alumno": str(f.get("dsc_alumno") or "").strip(),
"num_cuotas_pagadas": int(f.get("num_cuotas_pagadas") or 0), "num_cuotas_pagadas": int(f.get("num_cuotas_pagadas") or 0),
"num_cuotas_vencidas": int(f.get("num_cuotas_vencidas") or 0), "num_cuotas_vencidas": int(f.get("num_cuotas_vencidas") or 0),
"fch_venc_mas_antigua": str(f.get("fch_venc_mas_antigua") or "")[:10], "fch_venc_mas_antigua": str(f.get("fch_venc_mas_antigua") or ""),
"imp_total_pagado": round(_pag, 2), "imp_total_pagado": round(_pag, 2),
"inv_neta": round(_inv, 2), "inv_neta": round(_inv, 2),
"monto_venc_ant": round(_mva, 2) if _mva > 0 else 0,
"monto_venc_cur": round(_mvc, 2) if _mvc > 0 else 0,
} }
return out return out
except Exception as e: except Exception as e: