diff --git a/public/pos/pos-app.js b/public/pos/pos-app.js index 5a95ac7..71493d9 100644 --- a/public/pos/pos-app.js +++ b/public/pos/pos-app.js @@ -19,7 +19,7 @@ const state = { // catalog load (both the IndexedDB and the network path) so the // per-keystroke filter only does `indexOf`, never normalisation. searchIndex: new Map(), - cart: new Map(), // id -> {p, qty, unitPriceOverride?} + cart: new Map(), // id -> {p, qty} customer: null, paymentMethod: null, cashGiven: 0, @@ -350,8 +350,7 @@ function cartTotals(){ let count=0, gross=0; for(const {p,qty} of state.cart.values()){ count += qty; - // Use the per-line override if the cashier edited the price - // via long-press; otherwise the catalogue shelf price. + // Catalogue shelf price — the till never edits a line's price. const unit = lineUnitPrice({p,qty}); gross += unit * qty; } @@ -385,14 +384,14 @@ function cartTotals(){ } /** - * Effective unit price for a cart line — the per-line override - * (set by long-press edit) or the catalogue's selling price. - * Returns 0 for the corner case where neither is set. + * Effective unit price for a cart line — always the catalogue's selling + * price. It used to prefer a per-line override set by the long-press edit + * sheet, but that sheet is quantity-only now, so no override can exist. + * Kept as a named helper because the price feeds four places (line render, + * cart totals, the sale record and the checkout payload) and they must not + * drift apart. Returns 0 when neither price is set. */ function lineUnitPrice(line){ - if (typeof line.unitPriceOverride === 'number' && Number.isFinite(line.unitPriceOverride)) { - return line.unitPriceOverride; - } return Number(line.p.selling_price ?? line.p.cost_price ?? 0) || 0; } function persistCart(){ @@ -430,17 +429,14 @@ function renderCartDrawer(){ document.getElementById('discountLine').hidden = true; return; } - body.innerHTML = Array.from(state.cart.values()).map(({p,qty,unitPriceOverride})=>{ - const price = lineUnitPrice({p,qty,unitPriceOverride}); - const overridden = typeof unitPriceOverride === 'number' - && Number.isFinite(unitPriceOverride) - && unitPriceOverride !== (p.selling_price ?? p.cost_price ?? 0); + body.innerHTML = Array.from(state.cart.values()).map(({p,qty})=>{ + const price = lineUnitPrice({p,qty}); return `
-
${escapeHTML(p.description||p.sku)}${fmt(price)} / ${escapeHTML(p.unit||'ea')} · ${escapeHTML(p.sku||'')}${overridden ? ' · price edited' : ''}
+
${escapeHTML(p.description||p.sku)}${fmt(price)} / ${escapeHTML(p.unit||'ea')} · ${escapeHTML(p.sku||'')}
- -
${qty}
- + + +
${fmt(price*qty)}
-
SubtotalR 0.00
+ +
+ Subtotal + + + R 0.00 +
VAT 15%R 0.00
- -
- -