/* eslint-disable */ /* © 2026 K2B NETWORK SOLUTIONS LLC. All rights reserved. Proprietary and confidential. Unauthorized copying, distribution, or use of this file, via any medium, is strictly prohibited. Original work product. */ // JBREWS DMS — Deal Compliance & Risk Score. // Scans each deal for required documents/steps, assigns risk points to anything // missing, and HARD-STOPS a deal that scores over the threshold from closing. // Reads/writes DMS.dealCompliance / DMS.setDealCompliance. Hooked into the deal // post path (Finance WS) so a high-risk jacket cannot be booked. const cmpTone = (level) => level === "clear" ? { bg: "#E6F7EC", fg: "#0E7A37", label: "CLEAR" } : level === "caution" ? { bg: "#FBF3E0", fg: "#9A6700", label: "CAUTION" } : { bg: "#FBE9E7", fg: "#B23A2E", label: "BLOCKED" }; const DealCompliance = ({ onClose, go }) => { const D = window.DMS; const [, force] = React.useReducer(n => n + 1, 0); React.useEffect(() => (D && D.subscribe) ? D.subscribe(force) : undefined, []); const act = (r) => { window.k2bToast && window.k2bToast(r.msg, r.ok ? "ok" : "warn", 3000); return r; }; const deals = (D && D.deals) ? D.deals().filter(d => d.status !== "Working" || d.salePrice > 0) : []; const [selId, setSelId] = React.useState(null); React.useEffect(() => { if (selId && deals.find(d => d.id === selId)) return; if (deals[0]) setSelId(deals[0].id); }, [deals.length]); const sel = deals.find(d => d.id === selId) || null; const comp = sel ? D.dealCompliance(sel.id) : null; const blocked = deals.filter(d => D.dealCompliance(d.id).level === "blocked").length; return (
{deals.length} deals scanned · {blocked} blocked from closing
Score over {D.COMPLIANCE_THRESHOLD} blocks the deal from posting.
{/* deal list */}
{deals.length === 0 &&
No deals to review. Start one in Deals.
} {deals.map(d => { const c = D.dealCompliance(d.id); const t = cmpTone(c.level); const on = d.id === selId; return (
setSelId(d.id)} style={{ padding: "10px 14px", borderBottom: "1px solid var(--jb-border)", cursor: "pointer", background: on ? "var(--jb-blue-tint, #E5EFFA)" : "transparent", borderLeft: on ? "3px solid var(--jb-blue)" : "3px solid transparent" }}>
{d.id}
{c.score} pts
{d.buyer}
{d.vehicle} · {d.status}
); })}
{/* detail */}
{sel && comp ? (
{sel.id}
{sel.buyer}
{sel.vehicle} · {sel.type} · {sel.status}
Risk Score
{comp.score}
{cmpTone(comp.level).label}
{comp.level === "blocked" && (
⛔ This deal exceeds the risk threshold ({comp.threshold}). It cannot be posted until the score drops to {comp.threshold} or below.
)} {/* checklist */}
RequirementRiskStatus
{comp.items.map(it => (
{it.label} {it.auto && AUTO} {it.note ? {it.note} : null} {it.ok ? "—" : "+" + it.pts} {it.auto ? ( {it.ok ? "✓ OK" : "✕ RISK"} ) : ( )}
))}
) :
Select a deal.
}
ESC-Close go && go("deal")}>Deals go && go("finance")}>Finance WS
); }; Object.assign(window, { DealCompliance });