/* © 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. */ /* eslint-disable */ // JBREWS DMS — per-module settings. // Every module window gets a ⚙ gear on its titlebar (wired in chrome.jsx via // title matching). The gear opens THAT module's own editable settings; values // persist per dealer, sync cross-tab, and are read live by the module's math // (tax rates, labor rates, doc fees, default terms, reorder behavior, …). // window.jbSetting(module, key) → effective value (saved ?? default) // window.jbModSettings.set(module, k, v) → save + notify // window.jbModSettings.defs → the registry below (() => { const KEY = "jbrews-modsettings-v1"; const load = () => { try { return JSON.parse(localStorage.getItem(KEY) || "{}"); } catch (e) { return {}; } }; let cache = load(); const listeners = new Set(); const notify = () => listeners.forEach(fn => { try { fn(); } catch (e) {} }); window.addEventListener("storage", (e) => { if (e.key === KEY) { cache = load(); notify(); } }); // ── Registry: what each module lets you adjust ────────────────────── // type: num | pct | bool | text | select(options) const defs = { service: { label: "Service Department", match: /service repair orders|service dept|service department|repair order|dispatch/i, fields: { taxRate: { label: "Sales tax rate", type: "pct", def: 7.225, hint: "Applied to customer-pay labor + parts on ROs" }, // RC32 (rset): the gear's three dead fields are gone ("Retail labor rate $/hr" 129, "Shop supplies % of labor", "Flag ROs open longer // than (days)" — saved in this browser, read by no code). Their real settings are on Service Dept › Setup: the labor rates (Rates, // M3), the shop supplies fee (Rates, M1 — a later release) and the aged-RO days (RO screen & steps, R5). The panel links there. }, setupLink: true, }, parts: { label: "Parts Department", match: /parts department|parts dept|parts counter|parts ticket|counter ticket/i, // RC20: the Parts — Counter Ticket screen gets the gear too (the shared tax rate) fields: { taxRate: { label: "Sales tax rate", type: "pct", def: 7.225, hint: "Retail counter sales; wholesale is exempt" }, wholesaleExempt:{ label: "Wholesale sales tax-exempt", type: "bool", def: true }, matrixPct: { label: "Retail matrix markup %", type: "pct", def: 40, hint: "Suggested retail over cost on unpriced parts" }, reorderMode: { label: "Reorder suggestions", type: "select", def: "At or below min", options: ["At or below min", "Below min only", "Off"] }, }, }, desking: { label: "Desking Tool", match: /desking|cash worksheet|cashwind|trade-in appraisal/i, fields: { defaultTerm: { label: "Default term (months)", type: "num", def: 72 }, defaultApr: { label: "Default APR %", type: "pct", def: 6.49, hint: "Used when a deal's APR is left blank — Finance Deal and F&I Menu (an entered 0% stays 0%). The desk's option A/B/C rates are the desk's own starting rates, set on the desk." }, daysToFirst: { label: "Days to first payment", type: "num", def: 45 }, docFee: { label: "Doc / admin fee $", type: "num", def: 199 }, }, }, financews: { label: "Finance Worksheet (F&I)", match: /finance worksheet|crapp|credit application|deal compliance|funding|buyer.?s order|buyord/i, fields: { docFee: { label: "Doc / admin fee $", type: "num", def: 199 }, reserveSplit: { label: "Dealer reserve split %", type: "pct", def: 70, hint: "Dealer share of rate participation" }, titleFee: { label: "Title & license fee $", type: "num", def: 58.5 }, }, }, checkwriting: { label: "Check Writing", match: /check writing|checkbook/i, fields: { dualSigOver: { label: "Require 2nd signature over $", type: "num", def: 10000, hint: "0 = never" }, defaultMemoRef:{ label: "Print invoice # on memo line", type: "bool", def: true }, }, }, inventory: { label: "Vehicle Inventory", match: /vehicle inventory|^inventory|\binventory\b|stkin|stock-in|vin decode|unit finder|profit timeline/i, fields: { packFee: { label: "Pack fee $ per unit", type: "num", def: 0 }, floorplanApr: { label: "Floorplan APR %", type: "pct", def: 7.5, hint: "Used for holding-cost displays" }, agedDays: { label: "Aged-unit threshold (days)", type: "num", def: 60 }, }, }, crm: { label: "CRM / Prospects", match: /crm|customer relationship|leads/i, fields: { followUpDays: { label: "Default follow-up (days)", type: "num", def: 3 }, staleDays: { label: "Prospect goes cold after (days)", type: "num", def: 30 }, }, }, warranty: { label: "GWM Warranty Claims", match: /warranty claims|part returns|wpc/i, fields: { warrantyLaborRate: { label: "Warranty labor rate $/hr", type: "num", def: 119, hint: "GM-approved warranty rate" }, agedClaimDays: { label: "Flag unpaid claims after (days)", type: "num", def: 30 }, }, }, bodyshop: { label: "Body Shop", match: /body shop/i, fields: { bodyRate: { label: "Body labor rate $/hr", type: "num", def: 62 }, paintRate: { label: "Paint labor rate $/hr", type: "num", def: 62 }, frameRate: { label: "Frame labor rate $/hr", type: "num", def: 75 }, paintMatPct: { label: "Paint materials % of paint labor", type: "pct", def: 38 }, }, }, payroll: { label: "Payroll", match: /payroll/i, fields: { otMultiplier: { label: "Overtime multiplier", type: "num", def: 1.5 }, payPeriod: { label: "Pay period", type: "select", def: "Semi-monthly", options: ["Weekly", "Bi-weekly", "Semi-monthly", "Monthly"] }, }, }, accounting: { label: "General Ledger", match: /general ledger|glinq|doc entry|document entry|posting map|profit .?&? ?loss|acct office|accounting office|gmacct|gm standard|fixed ops|controls|cash command|dead money|\breports\b/i, fields: { fiscalStart: { label: "Fiscal year starts", type: "select", def: "January", options: ["January","February","March","April","May","June","July","August","September","October","November","December"] }, defaultJrn: { label: "Default journal # for manual entries", type: "num", def: 90 }, }, }, fcso: { label: "Fulfillment Orders (FCSO)", match: /fulfillment/i, fields: { defaultFC: { label: "Default fulfillment center", type: "text", def: "" }, depositDefault:{ label: "Default refundable deposit $", type: "num", def: 500 }, }, }, fleet: { label: "GM Fleet", match: /gm fleet/i, fields: { defaultType: { label: "Default fleet type", type: "select", def: "Dealer Fleet", options: ["Small Business", "Dealer Fleet", "Large Fleet", "Government", "Rental"] }, fanWarn: { label: "Warn when FAN missing", type: "bool", def: true }, }, }, salesincentive: { label: "Incentive Compliance (SIR)", match: /sales incentive|incentive compliance|\bSIR\b/i, fields: { agedSNDDays: { label: "Flag sold-not-delivered after (days)", type: "num", def: 30 }, cash8300: { label: "IRS 8300 cash threshold $", type: "num", def: 10000 }, }, }, policy: { label: "Policy / Goodwill", match: /policy|goodwill/i, fields: { goodwillCapPerCust: { label: "Goodwill cap per customer $", type: "num", def: 500 }, mgrApprovalOver: { label: "Manager approval over $", type: "num", def: 250 }, }, }, recon: { label: "Recon Tracker", match: /recon stage|make-ready|recon tracker/i, fields: { targetDays: { label: "Target days bought → front line", type: "num", def: 7 }, staleStageDays:{ label: "Flag stage stuck after (days)", type: "num", def: 3 }, }, }, forms: { label: "Deal Forms", match: /missouri deal forms|title-mo|forms — sales|forms sequencing|deal forms/i, fields: { defaultCopies: { label: "Default copies per form", type: "num", def: 1 }, defaultDest: { label: "Default destination", type: "select", def: "Screen", options: ["Screen", "Printer"] }, }, }, banks: { label: "Banks / Lenders", match: /banks|lenders/i, fields: { reserveSplit: { label: "Default reserve split %", type: "pct", def: 70 }, daysToFirst: { label: "Default days to first payment", type: "num", def: 45 }, }, }, fiproducts: { label: "F&I Products", match: /f&i products|fi products/i, fields: { defaultMarkupPct: { label: "Default product markup %", type: "pct", def: 100, hint: "Suggested retail over cost on new products" }, taxableDefault: { label: "Products taxable by default", type: "bool", def: false }, }, }, importtool: { label: "Import / Migration", match: /import|upload|migration/i, fields: { defaultMode: { label: "Default import mode", type: "select", def: "Merge (non-destructive)", options: ["Merge (non-destructive)", "Replace (overwrite)"] }, custNumFromPhone: { label: "Derive customer # from phone (7-digit)", type: "bool", def: true }, }, }, dashboard: { label: "Dashboard", match: /dashboard/i, fields: { unitTarget: { label: "Monthly unit target", type: "num", def: 60 }, grossTarget: { label: "Monthly gross target $", type: "num", def: 250000 }, }, }, }; const forTitle = (title) => { const t = String(title || ""); for (const k of Object.keys(defs)) if (defs[k].match.test(t)) return k; return null; }; // RC20 (fops): the service / parts tax rates and the wholesale exemption are ONE shared setting (serviceSettings.tax on the // server, set by the office or the Service Manager) — every station previews with it and the server posts with it, so a ticket, // its receipt and its journal can never disagree (owner-reviewer R6). This station's old local copy of those values is not used. const SHARED = { "service.taxRate": "servicePct", "parts.taxRate": "partsPct", "parts.wholesaleExempt": "wholesaleExempt" }; const sharedKey = (mod, key) => SHARED[mod + "." + key] || null; const shared = (mod, key) => { const k = sharedKey(mod, key); if (!k || !window.DMS || !window.DMS.fopsTaxConfig || !window.FopsCalc) return undefined; const c = window.DMS.fopsTaxConfig(); if (!c) return undefined; return k === "wholesaleExempt" ? c.wholesaleExempt : Number(window.FopsCalc.ppmToPct(k === "servicePct" ? c.servicePpm : c.partsPpm)); }; const get = (mod, key) => { const sh = shared(mod, key); if (sh !== undefined) return sh; const d = defs[mod] && defs[mod].fields[key]; const saved = cache[mod] && cache[mod][key]; return saved != null ? saved : (d ? d.def : undefined); }; const set = (mod, key, val) => { cache = load(); cache[mod] = cache[mod] || {}; cache[mod][key] = val; try { localStorage.setItem(KEY, JSON.stringify(cache)); } catch (e) {} notify(); }; const reset = (mod) => { cache = load(); delete cache[mod]; try { localStorage.setItem(KEY, JSON.stringify(cache)); } catch (e) {} notify(); }; window.jbModSettings = { defs, forTitle, get, set, reset, sharedKey, subscribe: (fn) => { listeners.add(fn); return () => listeners.delete(fn); } }; window.jbSetting = get; // Effective tax rate helpers (fractions) used by DMSCore math. window.jbTaxRate = (mod) => (+get(mod || "service", "taxRate") || 0) / 100; })(); // ── The gear panel (rendered by K2BTitlebar's ⚙) ───────────────────── const K2BModSettingsPanel = ({ module, onClose }) => { const S = window.jbModSettings; const def = S.defs[module]; const [, force] = React.useReducer(n => n + 1, 0); React.useEffect(() => S.subscribe(force), []); if (!def) return null; const fld = { fontSize: 13, padding: "6px 8px", border: "1px solid #C8CCD2", borderRadius: 4, width: "100%", boxSizing: "border-box" }; return ( { if (window.confirm("Reset " + def.label + " settings to defaults?")) S.reset(module); }}>Reset Defaults Done }>
{Object.keys(def.fields).map(k => { const f = def.fields[k]; const val = S.get(module, k); if (S.sharedKey && S.sharedKey(module, k)) return ; return ( ); })} {def.setupLink && }
Saved for {window.K2BStore ? window.K2BStore.branding().dba : "this store"} on this system and applied immediately — tax, rates and defaults recalculate live.
); }; // RC32 (rset): the Service gear points at the real service settings (Service Dept › Setup): labor rates, the aged-RO days, the RO screen, // steps, lists, technicians, texts and printing. The office and the Service Manager get a "More service settings ›" button that opens // Service Setup right here; everyone else reads where the settings are. const K2BSvcSetupLink = () => { const [open, setOpen] = React.useState(false); const D = window.DMS; const may = !!(D && ((D.svcCanSetup && D.svcCanSetup()) || (D._svcRawServiceManager && D._svcRawServiceManager()))); return (
Labor rates, the days before an RO counts as aged, and the RO screen, steps, lists, technicians, texts and printing are set on Service Dept › Setup — the same for every station. {may && } {open && window.ServiceSetupPanel && ( setOpen(false)} buttons={ setOpen(false)}>Done}>
)}
); }; // RC20 (fops): a shared tax setting — one value for every station, saved on the server by the office / Service Manager. const FopsSharedTaxField = ({ f, val, sk }) => { const [draft, setDraft] = React.useState(String(val)); React.useEffect(() => { setDraft(String(val)); }, [val]); const may = !!(window.DMS && window.DMS.fopsSeesShopCost && window.DMS.fopsSeesShopCost()); const save = (v) => { const r = window.DMS.fopsSetSharedTax({ [sk]: v }); window.k2bToast && window.k2bToast(r.msg, r.ok ? "ok" : "warn", 4500); }; const fld = { fontSize: 13, padding: "6px 8px", border: "1px solid #C8CCD2", borderRadius: 4, width: 120, boxSizing: "border-box", fontFamily: "var(--jb-mono, monospace)" }; return ( ); }; Object.assign(window, { K2BModSettingsPanel });