/* 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 — GWM Warranty Claims (Global Warranty Management). // Prepare, submit, authorize, reconcile and debit warranty claims that arise // from Warranty-pay repair orders. Wired to the ledger: closing a Warranty RO // books the receivable to acct 263; paying a claim relieves 263 to cash; a full // debit charges warranty expense (684). Codes come from window.GWM picklists. const wcMoney = (n) => "$" + (Number(n) || 0).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); // RC33 fix round: what is still OPEN on a claim (claimed − already received − charged back while unpaid), in cents — what 263 carries for it const wcOpenC = (c) => Math.max(0, Math.round((+c.amount || 0) * 100) - Math.round((+c.received || 0) * 100) - Math.round((+c.debitedOpen || 0) * 100)); // a paid claim GM charged back: a credit on 263 the next GM statement takes (Record Payment on that statement's claim names it) const wcWaitingChargebacks = (claims) => (claims || []).filter(x => x.status === "Debited" && (x.debitWasPaid || x.paid) && !x.chargebackSettled && !x.voided); const wcDays = (iso) => iso ? Math.floor((Date.now() - new Date(iso)) / 86400000) : 0; const WC_STATUS_TONE = { "Not Submitted": { bg: "#EDEFF3", fg: "#5A6472" }, "Submitted": { bg: "var(--jb-blue-tint,#E5EFFA)", fg: "var(--jb-blue,#1B66A8)" }, "Authorized": { bg: "#E7F0FB", fg: "#1456A0" }, "Paid": { bg: "var(--jb-green-tint,#E6F7EC)", fg: "var(--jb-green,#16A34A)" }, "Rejected": { bg: "#FBE9E7", fg: "#B23A2E" }, "Debited": { bg: "#F6E2C5", fg: "#9A6700" }, }; const WCBadge = ({ status }) => { const t = WC_STATUS_TONE[status] || WC_STATUS_TONE["Not Submitted"]; return {status}; }; const WarrantyClaims = ({ 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): payment / chargeback are SERVER commands (promises) const claims = (D && D.warrantyReceivables) ? D.warrantyReceivables() : []; const ros = (D && D.repairOrders) ? D.repairOrders() : []; const roOf = (claim) => ros.find(r => r.id === claim.ro) || {}; const [view, setView] = React.useState("claims"); // claims | reconcile const [selId, setSelId] = React.useState(null); React.useEffect(() => { if (selId && claims.find(c => c.claim === selId)) return; if (claims[0]) setSelId(claims[0].claim); }, [claims.length]); const sel = claims.find(c => c.claim === selId) || null; // KPIs const openAmt = claims.filter(c => !c.paid && c.status !== "Debited" && !c.voided).reduce((s, c) => s + wcOpenC(c), 0) / 100; const unsub = claims.filter(c => !c.submitted && c.status !== "Paid" && c.status !== "Debited").length; const aged = claims.filter(c => c.submitted && !c.paid && c.status !== "Debited" && wcDays(c.submittedDate) >= 30).length; const debited = claims.filter(c => c.status === "Debited").length; return (
{/* KPI strip */}
{view === "reconcile" ? ( ) : (
{/* queue */}
{claims.length === 0 && (
No warranty claims yet. Close a Warranty-pay repair order to generate one.
)} {claims.map(c => { const ro = roOf(c); const on = c.claim === selId; return (
setSelId(c.claim)} 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" }}>
{c.claim}
{ro.customer || "—"}
{ro.vehicle || ""} · {c.ro}
{wcMoney(c.amount)} {c.submitted && !c.paid && c.status !== "Debited" && = 30 ? "var(--k2b-maroon)" : "#999" }}>· {wcDays(c.submittedDate)}d} {c.returnStatus && c.returnStatus !== "Not Required" && · 📦 {c.returnStatus}}
); })}
{/* editor */}
{sel ? : (
Select a claim.
)}
)}
ESC-Close go && go("service")}>Service ROs go && go("acctoffice")}>Acct Office (A/R) go && go("partsdept")}>Parts Dept
); }; const WcEditor = ({ claim: c, ro, act, go }) => { const G = window.GWM || {}; const D = window.DMS; const closed = c.status === "Paid" || c.status === "Debited"; const upd = (patch) => D.gwmUpdateClaim(c.claim, patch); const sel = { fontSize: 13, padding: "5px 7px", border: "1px solid #C8CCD2", background: closed ? "#F0F0F0" : "#FFFEF4", borderRadius: 4, fontFamily: "var(--jb-font)" }; const codeOpts = (list) => [, ...(list || []).map(o => )]; return (
{/* header */}
{c.claim} {c.txnType && {c.txnType}}
{ro.customer || "—"}
{ro.vehicle || ""}{ro.vin ? " · VIN " + ro.vin : ""} · {c.ro}
Claim Amount
{wcMoney(c.amount)}
{c.paid &&
paid {wcDays(c.paidDate)}d ago
} {!c.paid && c.status !== "Debited" && wcOpenC(c) !== Math.round((+c.amount || 0) * 100) &&
{wcMoney(wcOpenC(c) / 100)} still open{+c.debitedOpen ? ` · ${wcMoney(c.debitedOpen)} charged back` : ""}{+c.received ? ` · ${wcMoney(c.received)} received` : ""}
}
{/* coding */}
Claim Coding
upd({ laborOp: e.target.value.toUpperCase() })} placeholder="e.g. J6587" style={{ ...sel, fontFamily: "var(--jb-mono)" }} /> upd({ causalPart: e.target.value.toUpperCase() })} placeholder="part number that caused the failure" style={{ ...sel, fontFamily: "var(--jb-mono)" }} />
{(!c.complaintCode || !c.causeCode) && !closed && (
⚠ Complaint and Cause codes are required before the claim can be submitted.
)}
{/* lifecycle actions */}
Claim Lifecycle
{!c.submitted && c.status !== "Paid" && ( )} {c.submitted && c.status === "Submitted" && ( )} {(c.status === "Submitted" || c.status === "Authorized") && ( )} {c.submitted && c.status !== "Paid" && c.status !== "Debited" && ( act(D.rejectWarrantyClaim(c.claim, code))} /> )} {c.status !== "Debited" && ( act(D.debitWarrantyClaim(c.claim, code))} /> )}
{c.rejectCode && c.status === "Rejected" &&
Rejected — code {c.rejectCode}: {(G.REJECT.find(x => x.code === c.rejectCode) || {}).label}. Correct the coding and resubmit.
} {c.debitCode && c.status === "Debited" &&
Full debit — code {c.debitCode}: {(G.DEBIT.find(x => x.code === c.debitCode) || {}).label}. Charged to warranty expense (684).{(c.debitWasPaid || c.paid) ? (c.chargebackSettled ? ` Taken off GM's payment of ${c.chargebackSettled.claim || ""} (${c.chargebackSettled.je || ""}).` : " GM had paid it — 263 holds the credit until the next GM statement takes it (name it in Record Payment).") : ""}
} {Array.isArray(c.debits) && c.debits.length > 0 && c.status !== "Debited" &&
Partly charged back {wcMoney(c.debitedOpen)} — {wcMoney(wcOpenC(c) / 100)} still open for GM to pay.
}
{/* part return (WPC) */}
Warranty Part Return (WPC)
Status: {c.causalPart && causal part {c.causalPart}}
); }; // Visual lifecycle pipeline const WcLifecycle = ({ claim: c }) => { const steps = ["Not Submitted", "Submitted", "Authorized", "Paid"]; const idx = c.status === "Paid" ? 3 : c.status === "Authorized" ? 2 : c.submitted ? 1 : 0; const broke = c.status === "Rejected" || c.status === "Debited"; return (
{steps.map((s, i) => (
{i <= idx && !broke ? "✓" : i + 1} {s}
{i < steps.length - 1 && →}
))} {broke && · {c.status}}
); }; const WcRejectButton = ({ onReject }) => { const [open, setOpen] = React.useState(false); const G = window.GWM || {}; return (
{open && ( <>
{ e.currentTarget.__k2bDown = true; }} onClick={(e) => { const d = e.currentTarget.__k2bDown; e.currentTarget.__k2bDown = false; if (d) setOpen(false); }} style={{ position: "fixed", inset: 0, zIndex: 40 }} />
{(G.REJECT || []).map(o => ( ))}
)}
); }; const WcDebitButton = ({ onDebit }) => { const [open, setOpen] = React.useState(false); const G = window.GWM || {}; return (
{open && ( <>
{ e.currentTarget.__k2bDown = true; }} onClick={(e) => { const d = e.currentTarget.__k2bDown; e.currentTarget.__k2bDown = false; if (d) setOpen(false); }} style={{ position: "fixed", inset: 0, zIndex: 40 }} />
{(G.DEBIT || []).map(o => ( ))}
)}
); }; // Reconcile / Transaction Summary const WcReconcile = ({ claims, roOf, go }) => { const byStatus = {}; (window.GWM ? window.GWM.CLAIM_STATUS : []).forEach(s => { byStatus[s] = claims.filter(c => (c.status || "Not Submitted") === s); }); const sum = (arr) => arr.reduce((s, c) => s + (+c.amount || 0), 0); return (
{Object.keys(byStatus).map(s => (
{byStatus[s].length}
{wcMoney(sum(byStatus[s]))}
))}
{["Claim", "RO", "Customer", "Txn", "Complaint", "Cause", "Status", "Return", "Amount"].map((h, i) => )} {claims.map((c, i) => { const ro = roOf(c); return ( ); })} {claims.length === 0 && }
{h}
{c.claim} {c.ro} {ro.customer || "—"} {c.txnType || "—"} {c.complaintCode || "—"} {c.causeCode || "—"} {c.returnStatus && c.returnStatus !== "Not Required" ? c.returnStatus : "—"} {wcMoney(c.amount)}
No claims.
); }; const WcKpi = ({ label, value, tone }) => { const fg = tone === "red" ? "#C03546" : tone === "amber" ? "#9A6700" : tone === "ok" ? "var(--jb-green, #16A34A)" : "var(--jb-navy)"; return (
{label}
{value}
); }; const wcActiveTab = { background: "var(--jb-navy, #1B66A8)", color: "#FFF", fontWeight: 700 }; const WcFld = ({ label, children }) => ( ); Object.assign(window, { WarrantyClaims });