feat: excluir_ventas independiente por contrato

- Nueva columna excluir_ventas en tabla contratos (migración automática)
- load_excluded_ventas_set() para filtrar en /ventas
- Toggle independiente en /contratos para RDA y Ventas por separado
- Modal edición con checkbox excluir_ventas
- 040 marcado excluir_rda=1, excluir_ventas=0 en seed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-11 11:56:28 -05:00
co-authored by Claude Sonnet 4.6
parent af71968c7f
commit f103d536c7
4 changed files with 125 additions and 63 deletions
+10 -2
View File
@@ -9,6 +9,7 @@ from app.services.firebird_service import get_firebird_from_config
from app.services.json_generator import generar_factura_venta
from app.services.api_client import get_tns_token, TNS_BASE
from app.utils.activity import log_activity, get_ip
from app.routes.contratos import load_excluded_ventas_set
router = APIRouter(prefix="/ventas", tags=["ventas"])
@@ -141,7 +142,11 @@ async def preview_ventas(
if not rows:
return JSONResponse({"success": False, "message": "Sin datos"})
grupos = _agrupar(rows)
excluded_ventas = load_excluded_ventas_set()
grupos_all = _agrupar(rows)
grupos = {k: v for k, v in grupos_all.items()
if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas}
items = []
for key, grupo_rows in grupos.items():
enviado = _is_sent(key)
@@ -245,7 +250,10 @@ async def send_ventas(
if not rows:
return JSONResponse({"success": False, "message": "Sin datos"})
grupos = _agrupar(rows)
excluded_ventas = load_excluded_ventas_set()
grupos_all = _agrupar(rows)
grupos = {k: v for k, v in grupos_all.items()
if str(v[0].get("CODCONTRATO") or "").strip() not in excluded_ventas}
if solo_pendientes == "1":
grupos = {k: v for k, v in grupos.items() if not _is_sent(k)}