HarmonyPOSMUTZU TOV
Demo User
Mutzu Tov
Site
HomeTodayWeddingsPurchase OrdersReceivingNew WeddingNew ItemCustomersItemsNew InvoiceJewelerRegisterStatementStatus

Sign in

`); win.document.close(); await loadAll(); } async function undoAlloc(allocId) { const a = allocs.find(x => x.id === allocId); const l = lineOf(a.line_id); if (!confirm(`Undo set-aside: ${l?.item_name} x${a.qty} back to shelf stock?`)) return; const poItem = pos.flatMap(p => p.purchase_order_items || []).find(i => i.id === a.po_item_id); if (poItem) { const cur = Number(poItem.po_items?.qty_on_hand ?? stock[poItem.po_items?.sku] ?? 0); await sb.from('po_items').update({ qty_on_hand: cur + Number(a.qty) }).eq('id', poItem.item_id); } await sb.from('po_receipt_allocations').delete().eq('id', allocId); const remaining = allocs.filter(x => x.line_id === a.line_id && x.id !== a.id); await sb.from('wedding_invoice_lines').update({ set_aside_state: remaining.length ? remaining[0].state : null }).eq('id', a.line_id); const w = weddingOf(a.wedding_id); await audit(a.wedding_id, 'po_receipt', a.id, 'undo', `Set-aside undone: ${l?.item_name} x${a.qty} for ${w?.label} - back to stock`); await loadAll(); } /* ---------- history ---------- */ function renderAudit() { document.getElementById('auditBox').innerHTML = auditRows.map(a => `
${new Date(a.created_at).toLocaleString()} - ${esc(a.actor || '')} - ${esc(a.action)}: ${esc(a.detail || '')}
`).join('') || '
No history yet.
'; }