- Hardcode _SQL_VENTAS and _SQL_VENTAS_BY_FACTURA matching automation.py
- Remove stored query selector from UI — ventas always queries CMXC by billing date
- send-one now fetches factura directly by PREFIJO+NUM_FACTURA (no date range requery)
- Remove query_id dependency from all endpoints and JS formParams
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _query_rows now always filters by PREFIJO='CMXC' (unless user specifies another prefix in the factura field)
- Removed redundant first column IDRECEP from ventas table (factura_key and factura were identical)
- Renamed header to just Factura
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _agrupar now keys by PREFIJO-NUM_FACTURA so all services of a factura are grouped together
- _is_sent checks by factura key instead of idrecepcion
- send-one and send endpoints accept/return factura_key instead of idrecepcion
- ventas.html JS updated: factura_key used throughout (filaHtml, marcarFila, enviarUno, enviarTodosPendientes, verDetalle)
- DOM element IDs sanitized with _safeId() to handle dashes in keys like CMXC-309
- onclick handlers now pass string keys with proper quoting
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Automation: agrega Paso 4 (Ventas/Crear) con fetch _SQL_VENTAS,
filtro por excluded_ventas_set, loop de envío y log de actividad
- Automation: _guardar_envio ahora almacena idrecepcion y contrato
para que /ventas reconozca registros enviados por automation
- Contratos: corrige NameError en toggle_excluir (faltaba request: Request)
- Ventas: agrega check if not q en send_one y send para evitar TypeError
- Ventas HTML: agrega columna Contrato en la tabla de facturas
- json_generator: normaliza etnia >2 chars a '99' (ej: 999 → 99)
- json_generator: agrega campo ciudadExp usando el mismo cod_ciudad
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- generar_factura_venta en json_generator.py con mapeo completo del JSON
- Queries default tipo 'ventas' (por fecha y por número) filtradas a contrato 040
- Ruta /ventas con preview, send-one y send masivo
- Template ventas.html con tabla, resumen y modal JSON
- Link en navegación lateral
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>