/* Banyan Pharmacy — Suppliers (orders, status, reliability) */ function relLabel(r) { return r === "reliable" ? "Reliable" : r === "watch" ? "Watch" : "Slipping"; } function ordersSummary(ids) { const list = D.orders.filter((o) => o.supplierId === ids); const open = list.filter((o) => o.status !== "delivered").length; const bad = list.filter((o) => o.status === "short" || o.status === "delayed").length; return { open, bad, total: list.length }; } function SuppliersPage() { const app = useApp(); const focusId = app.loopFocus && app.loopFocus.kind === "supplier" ? app.loopFocus.id : null; const rows = [...D.suppliers].sort((a, b) => a.fill - b.fill); // weakest first return (

Suppliers

Live orders and a reliability read — store-chat signals fused with order data
{rows.map((s) => { const sum = ordersSummary(s.id); const focus = focusId === s.id; const tone = s.fill >= 95 ? "" : s.fill >= 90 ? "warn" : "bad"; return (
app.nav({ name: "supplier", id: s.id })}>
{s.name}{relLabel(s.reliability)}
{s.kind} · {s.id}
{sum.bad > 0 && {sum.bad} need attention} {sum.open} open order{sum.open !== 1 ? "s" : ""}
Fill rate{s.fill}%
= 92 ? "" : s.onTime >= 85 ? "warn" : "bad")}>
On-time{s.onTime}%
Short-supply incidents · 30d {s.incidents30} {s.trend === "down" ? : }{s.trend === "down" ? "worsening" : "steady"}
{s.signal && {s.signal}}
); })}
); } function SupplierDetail({ route }) { const app = useApp(); const s = D.supplierById[route.id]; if (!s) return
Supplier not found.
; const orders = D.orders.filter((o) => o.supplierId === s.id); const storeIds = [...new Set(D.stores.filter((st) => st.suppliers.includes(s.id)).map((st) => st.id))]; return (
app.nav({ name: "suppliers" })}>All suppliers
{relLabel(s.reliability)} {s.kind}

{s.name}

{s.note} {s.id}
Fill rate
{s.fill}%
On-time
{s.onTime}%
Incidents · 30d
{s.incidents30}
Stores supplied
{storeIds.length}
{orders.map((o) => ( ))}
OrderStoreSKUQtyDueStatusNote
{o.id} {D.storeById[o.storeId].locality} {window.skuName(o.sku)} {o.qty} {window.shortDate(o.due)} {o.status} {o.note || "—"}
{storeIds.map((id) => { const st = D.storeById[id]; return (
app.nav({ name: "store", id })}>
{st.locality}
{st.region}
); })}
{s.signal ? (
Flagged from store chats
{s.id === "sup_sunrise1" ? "“Sunrise still hasn't delivered — 3rd time this month.”" : "“Expedite request open for the ward.”"}
{s.signal}
) : (
No incidents flagged this month. Deliveries on track.
)}
); } window.Pages = window.Pages || {}; window.Pages.Suppliers = SuppliersPage; window.Pages.SupplierDetail = SupplierDetail;