feat: configurable vehicle compatibility source (TecDoc / QWEN / Both)

Backend:
- Added GET/PUT /pos/api/config/vehicle-compat-source endpoints
- Added get_compat_source() helper reading from tenant_config
- create_item() now respects config: runs TecDoc and/or QWEN accordingly
- auto_match_item_vehicles() respects config: runs only configured source

Frontend:
- Added 'Compatibilidad de Vehiculos' section in config.html
- Added loadVehicleCompatSource() / saveVehicleCompatSource() in config.js
- Regenerated config.min.js
This commit is contained in:
2026-05-01 06:52:06 +00:00
parent 5421c47ffc
commit af7b010e55
6 changed files with 232 additions and 42 deletions

View File

@@ -580,6 +580,49 @@ const Config = (() => {
}
}
// -------------------------------------------------------------------------
// Vehicle Compatibility Source
// -------------------------------------------------------------------------
async function loadVehicleCompatSource() {
try {
var res = await fetch(API + '/vehicle-compat-source', { headers: headers() });
if (!res.ok) return;
var d = await res.json();
var sel = document.getElementById('cfg-compat-source');
if (sel) sel.value = d.source || 'both';
} catch (e) {
console.error('Config.loadVehicleCompatSource:', e);
}
}
async function saveVehicleCompatSource() {
var sel = document.getElementById('cfg-compat-source');
var btn = document.getElementById('btn-save-compat-source');
if (!sel) return;
if (btn) { btn.disabled = true; btn.textContent = 'Guardando...'; }
try {
var res = await fetch(API + '/vehicle-compat-source', {
method: 'PUT',
headers: headers(),
body: JSON.stringify({ source: sel.value })
});
if (!res.ok) {
var err = await res.json().catch(function() { return { error: res.statusText }; });
throw new Error(err.error || 'Save failed');
}
toast('Fuente de compatibilidad actualizada');
} catch (e) {
toast(e.message, 'error');
} finally {
if (btn) {
btn.disabled = false;
btn.textContent = 'Guardar';
}
}
}
// -------------------------------------------------------------------------
// Init
// -------------------------------------------------------------------------
@@ -601,6 +644,12 @@ const Config = (() => {
// Bind UI events
bindEvents();
// Vehicle compat source save button
var btnCompat = document.getElementById('btn-save-compat-source');
if (btnCompat) {
btnCompat.addEventListener('click', saveVehicleCompatSource);
}
// Kiosk mode toggle
var kioskToggle = document.getElementById('cfg-kiosk-mode');
if (kioskToggle && window.NexusKiosk) {
@@ -621,6 +670,7 @@ const Config = (() => {
loadEmployees();
loadBusiness();
loadCurrency();
loadVehicleCompatSource();
}
document.addEventListener('DOMContentLoaded', init);