From 91b50248982c81412bf2c750e9604c68b1ac5b1d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 21 Sep 2026 11:20:47 -0700 Subject: Point of sale: a sale the till never saw settle is adopted from the wallet's own record. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Tmfg8k5f3TbNJS34qiqHAp --- src/features/pos.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/features') diff --git a/src/features/pos.js b/src/features/pos.js index 7f47f88..6a46b78 100644 --- a/src/features/pos.js +++ b/src/features/pos.js @@ -151,9 +151,26 @@ export function posFeature(ctx) { function openSale(sale) { const m = movementOf(sale); if (!m) { toast(t('posNoDetail')); return; } + // the money arrived while nobody was watching the till (app closed, + // screen elsewhere): the record says so now + if (sale.status !== 'paid') { + const s = st(); + const row = s.sales.find((x) => x.id === sale.id); + if (row) { row.status = 'paid'; row.paidAt = row.paidAt || m.ts || Date.now(); save(s); } + } ui.arkMoveDetail = m.id; render(); } + // Sales the till never saw settle, but the wallet did: adopt them on paint. + function adoptPaid(s) { + let changed = false; + for (const x of s.sales) { + if (x.status === 'paid') continue; + const m = movementOf(x); + if (m) { x.status = 'paid'; x.paidAt = x.paidAt || m.ts || Date.now(); changed = true; } + } + if (changed) save(s); + } const saleOfMovement = (m) => (m && m.type === 'ln-receive' && m.invoice ? st().sales.find((x) => x.invoice === m.invoice) : null); // ---- screens ------------------------------------------------------------- @@ -204,6 +221,7 @@ export function posFeature(ctx) { h('span', { class: 'small muted' }, '%')) : null); } function salesCard(s) { + adoptPaid(s); const sales = [...s.sales].reverse(); if (!sales.length) return null; const today = dayKey(Date.now()); -- cgit v1.2.3