/* 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 — Warranty Part Returns board (WPC). // Tracks causal parts through the GM Warranty Parts Center return lifecycle: // Return Requested → Tagged/Held → Shipped → Received → Inspected → (Pass | // Debit). A claim flagged "Inspected — Debit" can be charged back from here. // Reads/writes the same warrantyReceivables records as GWM Warranty Claims. const PR_COLUMNS = [ { key: "Return Requested", tone: "#5A6472" }, { key: "Tagged / Held", tone: "#9A6700" }, { key: "Shipped to WPC", tone: "#1456A0" }, { key: "Received at WPC", tone: "#1B66A8" }, { key: "Inspected — Pass", tone: "#16A34A" }, { key: "Inspected — Debit",tone: "#B23A2E" }, ]; const PR_NEXT = { "Return Requested": "Tagged / Held", "Tagged / Held": "Shipped to WPC", "Shipped to WPC": "Received at WPC", "Received at WPC": "Inspected — Pass", }; const prMoney = (n) => "$" + (Number(n) || 0).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); const PartReturns = ({ 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) => Promise.resolve(r).then(x => { window.k2bToast && window.k2bToast(x.msg, x.ok ? "ok" : "warn", 3600); return x; }); // RC33 (mpx): the chargeback is a SERVER command (a promise) const claims = (D && D.warrantyReceivables) ? D.warrantyReceivables() : []; const ros = (D && D.repairOrders) ? D.repairOrders() : []; const roOf = (c) => ros.find(r => r.id === c.ro) || {}; // Only claims that are in some return state (exclude "Not Required"/blank) const inReturn = claims.filter(c => c.returnStatus && c.returnStatus !== "Not Required"); const byCol = {}; PR_COLUMNS.forEach(col => { byCol[col.key] = inReturn.filter(c => c.returnStatus === col.key); }); const pendingDebit = inReturn.filter(c => c.returnStatus === "Inspected — Debit" && c.status !== "Debited"); return (
{inReturn.length} part{inReturn.length !== 1 ? "s" : ""} in the return pipeline · {pendingDebit.length} flagged for debit
{PR_COLUMNS.map(col => (
{col.key}
{byCol[col.key].length}
{byCol[col.key].map(c => { const ro = roOf(c); const next = PR_NEXT[c.returnStatus]; return (
{c.claim}
{prMoney(c.amount)}
{ro.customer || "—"}
{c.causalPart &&
part {c.causalPart}
}
{next && } {c.returnStatus === "Received at WPC" && } {c.returnStatus === "Inspected — Debit" && c.status !== "Debited" && ( )}
); })} {byCol[col.key].length === 0 &&
—
}
))}
{inReturn.length === 0 && (
No parts in the return pipeline. On a warranty claim, set the part-return status to Return Requested to start tracking it here.
)}
ESC-Close go && go("warranty")}>Warranty Claims go && go("partsdept")}>Parts Dept
); }; Object.assign(window, { PartReturns });