fix: ventas page uses same SQL as automation (FACTURA_DIAN + FECHAFACT)

- 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>
This commit is contained in:
Lizandro Guarnizo
2026-07-28 17:28:05 -05:00
co-authored by Claude Sonnet 4.6
parent c0e66989ca
commit 22e42463c7
2 changed files with 83 additions and 79 deletions
+1 -12
View File
@@ -11,18 +11,9 @@
<h3 class="font-semibold text-gray-800"><i class="fas fa-cog mr-2 text-emerald-500"></i>Parámetros</h3>
</div>
<div class="p-5 space-y-4">
<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Consulta SQL</label>
<select id="f-query" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm">
<option value="">Seleccionar consulta...</option>
{% for q in queries %}
<option value="{{ q.id }}">{{ q.name }}</option>
{% endfor %}
</select>
</div>
<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Factura <span class="text-gray-400">(opcional)</span></label>
<input id="f-factura" type="text" placeholder="Ej: LHXC03404"
<input id="f-factura" type="text" placeholder="Ej: CMXC309"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm">
</div>
<div class="grid grid-cols-2 gap-3">
@@ -126,7 +117,6 @@ let formParams = {};
function getParams() {
return {
query_id: document.getElementById('f-query').value,
factura: document.getElementById('f-factura').value,
fecha_inicio: document.getElementById('f-fi').value,
fecha_fin: document.getElementById('f-ff').value,
@@ -135,7 +125,6 @@ function getParams() {
async function cargarRegistros() {
formParams = getParams();
if (!formParams.query_id) { showToast('Selecciona una consulta SQL', 'warning'); return; }
if (!formParams.fecha_inicio || !formParams.fecha_fin) { showToast('Ingresa las fechas', 'warning'); return; }
document.getElementById('tabla-wrap').innerHTML = `