Add allow_zero_price_sales toggle: config UI, POS enforcement and backend validation
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-15 17:50:02 +00:00
parent 2734a484f6
commit 116d4452da
7 changed files with 182 additions and 4 deletions

View File

@@ -625,6 +625,7 @@ const Config = (() => {
await saveVehicleCompatSource();
await saveAllowedBrands();
await saveModules();
await saveSalesSettings();
await saveReceiptConfig();
toast('Configuración guardada', 'ok');
} catch (e) {
@@ -1015,6 +1016,37 @@ const Config = (() => {
}
}
async function loadSalesSettings() {
try {
var res = await fetch(API + '/sales-settings', { headers: headers() });
if (!res.ok) return;
var data = await res.json();
var cb = document.getElementById('cfg-allow-zero-price');
if (cb) cb.checked = data.allow_zero_price_sales !== false;
} catch (e) {
console.error('Config.loadSalesSettings:', e);
}
}
async function saveSalesSettings() {
var cb = document.getElementById('cfg-allow-zero-price');
if (!cb) return;
try {
var res = await fetch(API + '/sales-settings', {
method: 'PUT',
headers: headers(),
body: JSON.stringify({ allow_zero_price_sales: cb.checked })
});
if (!res.ok) {
var err = await res.json().catch(function() { return { error: res.statusText }; });
throw new Error(err.error || 'Save failed');
}
} catch (e) {
toast(e.message, 'error');
throw e;
}
}
// -------------------------------------------------------------------------
// Tab navigation
// -------------------------------------------------------------------------
@@ -1277,6 +1309,7 @@ const Config = (() => {
loadVehicleCompatSource();
loadAllowedBrands();
loadModules();
loadSalesSettings();
loadReceiptConfig();
if (isAdmin) {
loadRolePermissions();