feat: paso 4 ventas en automation + fixes varios

- 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>
This commit is contained in:
Lizandro Guarnizo
2026-07-11 14:29:39 -05:00
co-authored by Claude Sonnet 4.6
parent 21eb99d18d
commit 73062af8bc
7 changed files with 249 additions and 68 deletions
+3 -1
View File
@@ -178,6 +178,7 @@ function renderTabla() {
<th class="pb-2 font-medium pr-3">IDRECEP.</th>
<th class="pb-2 font-medium pr-3">Factura</th>
<th class="pb-2 font-medium pr-3">Paciente</th>
<th class="pb-2 font-medium pr-3">Contrato</th>
<th class="pb-2 font-medium pr-3">Exámenes</th>
<th class="pb-2 font-medium pr-3">Estado</th>
<th class="pb-2 font-medium"></th>
@@ -217,7 +218,8 @@ function filaHtml(item) {
<td class="py-2 pr-3 font-mono text-gray-600">${id}</td>
<td class="py-2 pr-3 text-gray-600">${escHtml(String(item.factura || '-'))}</td>
<td class="py-2 pr-3 text-gray-600">${escHtml(String(item.paciente || '-'))}</td>
<td class="py-2 pr-3 text-gray-500 max-w-[200px] truncate" title="${escAttr(examsStr)}">${escHtml(examsStr)}</td>
<td class="py-2 pr-3"><span class="px-1.5 py-0.5 bg-emerald-100 text-emerald-700 rounded text-xs font-mono">${escHtml(String(item.contrato || '-'))}</span></td>
<td class="py-2 pr-3 text-gray-500 max-w-[180px] truncate" title="${escAttr(examsStr)}">${escHtml(examsStr)}</td>
<td id="estado-${id}" class="py-2 pr-3">${badgeHtml}</td>
<td class="py-2 flex gap-1 items-center">
<button onclick="verDetalle(${id})" title="Ver JSON" class="px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded text-xs"><i class="fas fa-code"></i></button>