diff --git a/public/pos/pos-app.js b/public/pos/pos-app.js index e0404dc..bf9fd20 100644 --- a/public/pos/pos-app.js +++ b/public/pos/pos-app.js @@ -315,6 +315,16 @@ function initials(s){ return parts.map(p=>p[0]||'').join('').toUpperCase().slice(0,2); } +// Decimal keyboards on South African phones type "," as the decimal key. +// Treat it as ".", drop everything else, keep only the first separator and +// at most 2 decimals (cents), so "12,50" -> "12.50" instead of 1250. +function cleanDecimal(v){ + let s = String(v||'').replace(/,/g,'.').replace(/[^0-9.]/g,''); + const i = s.indexOf('.'); + if(i !== -1) s = s.slice(0,i+1) + s.slice(i+1).replace(/\./g,'').slice(0,2); + return s; +} + // ---------------- custom (ad-hoc) lines ---------------- // // A line the cashier types by hand — "Bolt cutting" at R20 — that @@ -368,7 +378,7 @@ function closeCustomItem(){ } function saveCustomItem(){ const desc = document.getElementById('customDesc').value; - const price = document.getElementById('customPrice').value.replace(/[^0-9.]/g,''); + const price = cleanDecimal(document.getElementById('customPrice').value); const p = addCustomItem(desc, Number(price)); if(p) closeCustomItem(); } @@ -807,7 +817,7 @@ document.addEventListener('input', e=>{ }); document.addEventListener('input', e=>{ if(e.target.id!=='givenIn') return; - const raw = e.target.value.replace(/[^0-9.]/g,''); + const raw = cleanDecimal(e.target.value); e.target.value = raw; state.cashGiven = Number(raw)||0; paintChange(); diff --git a/public/pos/sw.js b/public/pos/sw.js index bbb48be..1927b2b 100644 --- a/public/pos/sw.js +++ b/public/pos/sw.js @@ -59,7 +59,8 @@ // painted under an unchanged total. Fixed with a global `[hidden]` override // plus blanking the figure when the row is hidden. Also carries the dark // palette lift. -const CACHE = "pos-v36"; +// v37: pos-app.js accepts a comma as the decimal point (custom item price, cash given). +const CACHE = "pos-v37"; const APP_SHELL = [ './', './index.html',