Add allow_negative_stock toggle for sales, remissions, quotes, layaways and service orders
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 18:02:43 +00:00
parent 116d4452da
commit c90012ca37
7 changed files with 76 additions and 44 deletions

View File

@@ -1021,21 +1021,27 @@ const Config = (() => {
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;
var cbZero = document.getElementById('cfg-allow-zero-price');
if (cbZero) cbZero.checked = data.allow_zero_price_sales !== false;
var cbNeg = document.getElementById('cfg-allow-negative-stock');
if (cbNeg) cbNeg.checked = data.allow_negative_stock === true;
} catch (e) {
console.error('Config.loadSalesSettings:', e);
}
}
async function saveSalesSettings() {
var cb = document.getElementById('cfg-allow-zero-price');
if (!cb) return;
var cbZero = document.getElementById('cfg-allow-zero-price');
var cbNeg = document.getElementById('cfg-allow-negative-stock');
if (!cbZero && !cbNeg) return;
try {
var body = {};
if (cbZero) body.allow_zero_price_sales = cbZero.checked;
if (cbNeg) body.allow_negative_stock = cbNeg.checked;
var res = await fetch(API + '/sales-settings', {
method: 'PUT',
headers: headers(),
body: JSON.stringify({ allow_zero_price_sales: cb.checked })
body: JSON.stringify(body)
});
if (!res.ok) {
var err = await res.json().catch(function() { return { error: res.statusText }; });

View File

@@ -33,6 +33,7 @@ const POS = (() => {
let canCreateRemission = false;
let counterRemissionEnabled = false;
let allowZeroPriceSales = true;
let allowNegativeStock = false;
let currentPerms = [];
let receiptConfig = {};
let couriers = [];
@@ -143,12 +144,14 @@ const POS = (() => {
} catch (e) {
counterRemissionEnabled = false;
}
// Sales settings (zero-price sales toggle)
// Sales settings (zero-price and negative-stock toggles)
try {
const ssCfg = await api('/pos/api/config/sales-settings');
allowZeroPriceSales = ssCfg.allow_zero_price_sales !== false;
allowNegativeStock = ssCfg.allow_negative_stock === true;
} catch (e) {
allowZeroPriceSales = true;
allowNegativeStock = false;
}
// Counter remission workflow applies only to the counter role.
canCreateRemission = counterRemissionEnabled && employeeRole === 'counter' && perms.includes('pos.remission');

View File

@@ -6,7 +6,7 @@
// The fetch handler normalizes static asset URLs (strips ?v= query strings)
// so templates can use cache-busting query params freely.
const VERSION = 44;
const VERSION = 45;
const CACHE_NAME = 'nexus-pos-v' + VERSION;
const APP_SHELL = [