Fix param validation errors and add TNS config section
- terceros/transaccion: return clear error when required params (doc_num, num_factura) are missing instead of passing empty dict to Firebird causing Column unknown error - transaccion: remove prefijo from 'por factura' query; parse num_factura as int when digit - automation: add /preview endpoint to show patient/reception counts before sending; update UI with preview step and disabled run button until preview loads - config: add TNS credentials section (tns_empresa, tns_usuario, tns_password, api_sucursal) with test-connection button - config: add POST /config/test-tns endpoint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
3755a51562
commit
b4a7271d8d
+58
-19
@@ -53,23 +53,51 @@
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<h4 class="font-medium text-gray-800"><i class="fas fa-cloud mr-2 text-blue-500"></i>API de Envío</h4>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">URL Base de la API</label>
|
||||
<input type="text" name="config_api_url"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'api_url')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm"
|
||||
placeholder="https://api.ejemplo.com">
|
||||
<h4 class="font-medium text-gray-800"><i class="fas fa-key mr-2 text-orange-500"></i>Credenciales TNS</h4>
|
||||
<p class="text-xs text-gray-500 -mt-2">Acceso a <strong>api.tns.co</strong> — portal de envío RIPS</p>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Código Empresa</label>
|
||||
<input type="text" name="config_tns_empresa"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'tns_empresa')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm"
|
||||
placeholder="Ej: 9002787299">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Código Sucursal</label>
|
||||
<input type="text" name="config_api_sucursal"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'api_sucursal')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm"
|
||||
placeholder="Ej: 81080">
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Método HTTP</label>
|
||||
<select name="config_api_method"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm">
|
||||
<option value="POST" {% if (configs|selectattr('key', 'equalto', 'api_method')|map(attribute='value')|first) == 'POST' %}selected{% endif %}>POST</option>
|
||||
<option value="PUT" {% if (configs|selectattr('key', 'equalto', 'api_method')|map(attribute='value')|first) == 'PUT' %}selected{% endif %}>PUT</option>
|
||||
</select>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Usuario TNS</label>
|
||||
<input type="text" name="config_tns_usuario"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'tns_usuario')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm"
|
||||
placeholder="Ej: DOCUXER">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Contraseña TNS</label>
|
||||
<input type="password" name="config_tns_password"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'tns_password')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" onclick="testTNS()"
|
||||
class="px-4 py-2 bg-orange-50 text-orange-700 border border-orange-200 rounded-lg hover:bg-orange-100 text-sm font-medium">
|
||||
<i class="fas fa-satellite-dish mr-1"></i> Probar conexión TNS
|
||||
</button>
|
||||
<span id="tns-status" class="text-sm ml-3"></span>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<h4 class="font-medium text-gray-800"><i class="fas fa-clock mr-2 text-blue-500"></i>API General</h4>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Timeout (seg)</label>
|
||||
<input type="number" name="config_api_timeout"
|
||||
@@ -77,12 +105,6 @@
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">API Key (Bearer token)</label>
|
||||
<input type="text" name="config_api_key"
|
||||
value="{{ configs|selectattr('key', 'equalto', 'api_key')|map(attribute='value')|first }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 text-sm">
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
@@ -112,6 +134,23 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function testTNS() {
|
||||
const form = document.querySelector('form');
|
||||
const status = document.getElementById('tns-status');
|
||||
status.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Probando...';
|
||||
|
||||
const data = new FormData();
|
||||
data.append('empresa', form.querySelector('[name="config_tns_empresa"]').value);
|
||||
data.append('usuario', form.querySelector('[name="config_tns_usuario"]').value);
|
||||
data.append('password', form.querySelector('[name="config_tns_password"]').value);
|
||||
|
||||
const resp = await fetch('/config/test-tns', { method: 'POST', body: data });
|
||||
const result = await resp.json();
|
||||
status.innerHTML = result.success
|
||||
? '<span class="text-green-600"><i class="fas fa-check-circle"></i> ' + (result.message || 'Conexión exitosa') + '</span>'
|
||||
: '<span class="text-red-600"><i class="fas fa-times-circle"></i> ' + result.message + '</span>';
|
||||
}
|
||||
|
||||
async function testFirebird() {
|
||||
const btn = event.target;
|
||||
const status = document.getElementById('fb-status');
|
||||
|
||||
Reference in New Issue
Block a user