corporate check: live SOS lookup via state adapters for all 51 states
- Formal entities: queries workers /entity-status endpoint for real-time Secretary of State status (ACTIVE/dissolved/revoked/delinquent) - Green if active, red if not active, yellow if not found or lookup failed - Sole proprietors: yellow 'form an LLC' upsell - 12s timeout so compliance check doesn't hang on slow state portals
This commit is contained in:
parent
e2313bcc5e
commit
e8a98b1130
1 changed files with 64 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ import { pool } from "../db.js";
|
|||
|
||||
const router = Router();
|
||||
const FMCSA_API_KEY = process.env.FMCSA_API_KEY || "";
|
||||
const WORKER_URL = process.env.WORKER_URL || "http://workers:8090";
|
||||
const FMCSA_BASE = "https://mobile.fmcsa.dot.gov/qc/services/carriers";
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────
|
||||
|
|
@ -441,15 +442,74 @@ router.get("/api/v1/dot/lookup", async (req, res) => {
|
|||
const isFormalEntity = isLLC || isCorp || isLTD || isLP;
|
||||
const state = carrier?.phyState || census?.phy_state || "";
|
||||
|
||||
if (isFormalEntity) {
|
||||
if (isFormalEntity && state) {
|
||||
const entityType = isLLC ? "LLC" : isCorp ? "Corporation" : isLTD ? "Ltd" : "LP/LLP";
|
||||
|
||||
// Live SOS lookup via workers /entity-status endpoint
|
||||
let sosStatus: { found?: boolean; status?: string; error?: string } | null = null;
|
||||
try {
|
||||
const sosResp = await fetch(`${WORKER_URL}/entity-status`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ entity_name: name, state_code: state }),
|
||||
signal: AbortSignal.timeout(12000),
|
||||
});
|
||||
if (sosResp.ok) {
|
||||
sosStatus = (await sosResp.json()) as { found?: boolean; status?: string; error?: string };
|
||||
}
|
||||
} catch {
|
||||
// SOS lookup timed out or failed — fall back to informational
|
||||
}
|
||||
|
||||
if (sosStatus?.found && sosStatus.status === "ACTIVE") {
|
||||
checks.push({
|
||||
id: "corporate_compliance",
|
||||
label: "Corporate / Entity Compliance",
|
||||
status: "green",
|
||||
detail: `${entityType} in ${state} — ACTIVE and in good standing. `
|
||||
+ `Make sure your annual report and registered agent are current. `
|
||||
+ `Performance West can handle your annual filings and serve as your registered agent.`,
|
||||
});
|
||||
} else if (sosStatus?.found && sosStatus.status !== "ACTIVE") {
|
||||
checks.push({
|
||||
id: "corporate_compliance",
|
||||
label: "Corporate / Entity Compliance",
|
||||
status: "red",
|
||||
detail: `${entityType} in ${state} — status: ${sosStatus.status || "NOT ACTIVE"}. `
|
||||
+ `Your entity may be administratively dissolved, revoked, or delinquent. `
|
||||
+ `This can affect your USDOT registration and operating authority. `
|
||||
+ `Performance West can reinstate your entity and bring it back into compliance.`,
|
||||
});
|
||||
} else if (sosStatus && !sosStatus.found) {
|
||||
checks.push({
|
||||
id: "corporate_compliance",
|
||||
label: "Corporate / Entity Compliance",
|
||||
status: "yellow",
|
||||
detail: `${entityType} — could not locate entity record in ${state} Secretary of State database. `
|
||||
+ `This may mean the entity is registered under a different name or in a different state. `
|
||||
+ `Performance West can verify your entity status and handle any needed filings.`,
|
||||
});
|
||||
} else {
|
||||
// Lookup failed/timed out — informational only
|
||||
checks.push({
|
||||
id: "corporate_compliance",
|
||||
label: "Corporate / Entity Compliance",
|
||||
status: "yellow",
|
||||
detail: `${entityType} registered in ${state} — most states require annual reports, `
|
||||
+ `franchise tax filings, and a registered agent. Failure to file can result in `
|
||||
+ `administrative dissolution and loss of liability protection. `
|
||||
+ `Performance West can handle your annual filings and registered agent service.`,
|
||||
});
|
||||
}
|
||||
} else if (isFormalEntity) {
|
||||
// No state to check against
|
||||
const entityType = isLLC ? "LLC" : isCorp ? "Corporation" : isLTD ? "Ltd" : "LP/LLP";
|
||||
checks.push({
|
||||
id: "corporate_compliance",
|
||||
label: "Corporate / Entity Compliance",
|
||||
status: "yellow",
|
||||
detail: `${entityType} registered in ${state || "your state"} — most states require annual reports, `
|
||||
+ `franchise tax filings, and a registered agent. Failure to file can result in `
|
||||
+ `administrative dissolution and loss of liability protection. `
|
||||
detail: `${entityType} — most states require annual reports, `
|
||||
+ `franchise tax filings, and a registered agent. `
|
||||
+ `Performance West can handle your annual filings and registered agent service.`,
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue