50-state trucking compliance: services, checker, order page, CA landing

- Migration 079: state_trucking_requirements table seeded for all 51 jurisdictions
  (IRP, IFTA, weight-distance taxes, MCP/CARB, intrastate authority, state DOT)
- Migration 080: carrier_operating_states tracking table
- 13 new state trucking services in catalog ($99-$599)
- StateTruckingHandler with state-specific admin todos
- DOT compliance checker: 7 new state-level checks (IRP, IFTA, weight tax,
  MCP/CARB, emissions, intrastate authority, state DOT number)
- New API endpoint: GET /api/v1/dot/state-requirements
- DOT order page: state compliance service cards with auto-preselect
- California trucking landing page (MCP + CARB + IRP + IFTA)
- Fix: DOT checker nav missing Trucking/DOT section
- Fix: All 8 DOT intake pages missing style block (dangling text)
- Fix: DOT confirmation email now says "Order Confirmed" not "Action Required"
- Fix: MCS150/BOC3/StateTrucking handlers missing async process() method
- Fix: StateTruckingHandler connection leak + slug resolution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-29 12:46:33 -05:00
parent c80f3a408a
commit 33da00fd89
21 changed files with 2078 additions and 14 deletions

View file

@ -2038,8 +2038,23 @@ async function sendComplianceIntakeEmail(
</p>
</div>` : "";
// Build intake form links for each service
const intakeLinks = orders.map(o => {
// DOT services are admin-assisted — no intake form needed
const DOT_SLUGS = new Set([
"mcs150-update", "boc3-filing", "ucr-registration", "dot-registration",
"mc-authority", "dot-drug-alcohol", "dot-audit-prep", "dot-full-compliance",
// State-level trucking
"irp-registration", "ifta-application", "ifta-quarterly",
"or-weight-mile-tax", "ny-hut-registration", "ky-kyu-registration",
"nm-weight-distance", "ct-highway-use-fee", "ca-mcp-carb",
"state-dot-registration", "intrastate-authority", "osow-permit",
"state-trucking-bundle",
]);
const dotOrders = orders.filter(o => DOT_SLUGS.has(o.service_slug as string));
const fccOrders = orders.filter(o => !DOT_SLUGS.has(o.service_slug as string));
const isDotOnly = fccOrders.length === 0;
// Build intake form links for FCC services only
const intakeLinks = fccOrders.map(o => {
const slug = o.service_slug as string;
const orderNum = o.order_number as string;
const name = o.service_name as string;
@ -2047,7 +2062,7 @@ async function sendComplianceIntakeEmail(
return `<li style="margin:6px 0;"><a href="${intakeUrl}" style="color:#1e40af;font-weight:600;font-size:14px;text-decoration:underline;">${name}</a></li>`;
}).join("\n");
const intakeSection = `
const intakeSection = fccOrders.length > 0 ? `
<div style="background:#eff6ff;border:2px solid #3b82f6;border-radius:8px;padding:20px;margin:20px 0;">
<p style="margin:0 0 8px;font-size:16px;font-weight:700;color:#1e3a5f;">Action Required: Complete Your Intake Form</p>
<p style="margin:0 0 12px;font-size:13px;color:#374151;line-height:1.5;">
@ -2055,12 +2070,26 @@ async function sendComplianceIntakeEmail(
</p>
<ul style="margin:0 0 12px;padding-left:18px;">${intakeLinks}</ul>
<p style="margin:0;font-size:12px;color:#6b7280;">This usually takes 2-5 minutes. We cannot begin your filing until the intake form is complete.</p>
</div>`;
</div>` : "";
const dotSection = dotOrders.length > 0 ? `
<div style="background:#fff7ed;border:2px solid #fdba74;border-radius:8px;padding:20px;margin:20px 0;">
<p style="margin:0 0 8px;font-size:16px;font-weight:700;color:#9a3412;">We're Working On It</p>
<p style="margin:0 0 12px;font-size:13px;color:#374151;line-height:1.5;">
The following services are being processed by our team. No further action is needed from you.
</p>
<ul style="margin:0 0 12px;padding-left:18px;">${dotOrders.map(o =>
`<li style="margin:4px 0;font-size:14px;color:#374151;">${o.service_name}</li>`
).join("\n")}</ul>
<p style="margin:0;font-size:12px;color:#6b7280;">You'll receive a confirmation email when your filing is complete, typically within 1 business day.</p>
</div>` : "";
const { sendEmail } = await import("../email.js");
await sendEmail({
to: customerEmail,
subject: `Action Required — ${entityName || "Your"} FCC Compliance Order`,
subject: isDotOnly
? `Order Confirmed — ${entityName || "Your"} DOT Compliance Order`
: `Action Required — ${entityName || "Your"} Compliance Order`,
html: `<!DOCTYPE html>
<html><head><meta charset="UTF-8"></head>
<body style="margin:0;padding:0;background:#eef0f3;font-family:Arial,sans-serif;">
@ -2093,14 +2122,22 @@ async function sendComplianceIntakeEmail(
${usacSection}
${dotSection}
${intakeSection}
<h2 style="margin:24px 0 8px;font-size:16px;font-weight:700;color:#111827;">What to Expect</h2>
${isDotOnly ? `
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">1.</span> Our team is already working on your filing.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">2.</span> Most DOT filings are completed within 1 business day.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">3.</span> You will receive a confirmation email when everything is filed.</p>
` : `
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">1.</span> Complete the intake form above so we have the details we need.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">2.</span> We will prepare your filing within 3-7 business days.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">3.</span> You will receive the document for review and electronic signature.</p>
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">4.</span> Once signed, we file it with the FCC and send you confirmation.</p>
${has499 ? `<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">4.</span> For 499-A filings, complete the USAC delegation above and click the confirmation button.</p>` : ""}
<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">4.</span> Once signed, we file it and send you confirmation.</p>
${has499 ? `<p style="margin:0 0 4px;font-size:14px;color:#374151;"><span style="color:#1e3a5f;font-weight:600;">5.</span> For 499-A filings, complete the USAC delegation above and click the confirmation button.</p>` : ""}
`}
<p style="margin:20px 0 0;font-size:13px;color:#9ca3af;">
Questions? Contact us at

View file

@ -269,6 +269,85 @@ const COMPLIANCE_SERVICES: Record<
erpnext_item: "DOT-FULL-COMPLIANCE",
discountable: true,
},
// ── State-Level Trucking Compliance ──────────────────────────────────
"irp-registration": {
name: "IRP Registration Assistance",
price_cents: 19900,
erpnext_item: "IRP-REGISTRATION",
discountable: true,
},
"ifta-application": {
name: "IFTA Application + Decals",
price_cents: 14900,
erpnext_item: "IFTA-APPLICATION",
discountable: true,
},
"ifta-quarterly": {
name: "IFTA Quarterly Filing",
price_cents: 9900,
erpnext_item: "IFTA-QUARTERLY",
discountable: true,
},
"or-weight-mile-tax": {
name: "Oregon Weight-Mile Tax Setup",
price_cents: 19900,
erpnext_item: "OR-WEIGHT-MILE-TAX",
discountable: true,
},
"ny-hut-registration": {
name: "NY Highway Use Tax Registration",
price_cents: 19900,
erpnext_item: "NY-HUT-REGISTRATION",
discountable: true,
},
"ky-kyu-registration": {
name: "KY Weight-Distance Tax Setup",
price_cents: 19900,
erpnext_item: "KY-KYU-REGISTRATION",
discountable: true,
},
"nm-weight-distance": {
name: "NM Weight-Distance Tax Setup",
price_cents: 19900,
erpnext_item: "NM-WEIGHT-DISTANCE",
discountable: true,
},
"ct-highway-use-fee": {
name: "CT Highway Use Fee Setup",
price_cents: 19900,
erpnext_item: "CT-HIGHWAY-USE-FEE",
discountable: true,
},
"ca-mcp-carb": {
name: "California MCP + CARB Compliance",
price_cents: 34900,
erpnext_item: "CA-MCP-CARB",
discountable: true,
},
"state-dot-registration": {
name: "State DOT Registration",
price_cents: 14900,
erpnext_item: "STATE-DOT-REGISTRATION",
discountable: true,
},
"intrastate-authority": {
name: "Intrastate Operating Authority",
price_cents: 24900,
erpnext_item: "INTRASTATE-AUTHORITY",
discountable: true,
},
"osow-permit": {
name: "Oversize/Overweight Permit",
price_cents: 9900,
erpnext_item: "OSOW-PERMIT",
discountable: true,
},
"state-trucking-bundle": {
name: "State Compliance Bundle",
price_cents: 59900,
erpnext_item: "STATE-TRUCKING-BUNDLE",
discountable: true,
},
};
// ── Intake validation map ─────────────────────────────────────────────

View file

@ -304,6 +304,109 @@ router.get("/api/v1/dot/lookup", async (req, res) => {
}
}
// ── State-Level Compliance Checks ──────────────────────────────
const phyState = (carrier?.phyState || census?.phy_state || "").toUpperCase();
const isInterstate = carrier
? (carrier.censusTypeId?.censusTypeDesc || "").toLowerCase().includes("interstate")
: (census?.carrier_operation || "").toLowerCase().includes("interstate");
const isForHireCarrier = census?.authorized_for_hire || false;
if (phyState && phyState.length === 2) {
try {
const stReq = await pool.query(
"SELECT * FROM state_trucking_requirements WHERE state_code = $1",
[phyState],
);
const st = stReq.rows[0];
if (st) {
// Check 8: IRP
if (st.irp_member && isInterstate) {
checks.push({
id: "irp",
label: "IRP (Apportioned Registration)",
status: "yellow",
detail: `Interstate carriers based in ${phyState} must register under the International Registration Plan (IRP) through ${st.irp_agency || "their state DMV"}.`,
action_url: st.irp_url || null,
});
}
// Check 9: IFTA
if (st.ifta_member && isInterstate) {
checks.push({
id: "ifta",
label: "IFTA (Fuel Tax)",
status: "yellow",
detail: `Interstate carriers must file quarterly IFTA fuel tax returns through ${st.ifta_agency || "their base state"}.`,
action_url: st.ifta_url || null,
});
}
// Check 10: Weight/Distance Tax
if (st.weight_distance_tax) {
checks.push({
id: "weight_distance_tax",
label: st.weight_distance_tax_name || "Weight-Distance Tax",
status: "yellow",
detail: `${phyState} requires a ${st.weight_distance_tax_name || "weight-distance tax"} for commercial vehicles${st.weight_distance_threshold_lbs ? ` over ${st.weight_distance_threshold_lbs.toLocaleString()} lbs` : ""}.`
+ (st.weight_distance_notes ? ` ${st.weight_distance_notes}` : ""),
action_url: st.weight_distance_url || null,
});
}
// Check 11: State Motor Carrier Permit (CA MCP, etc.)
if (st.state_carrier_permit) {
checks.push({
id: "state_carrier_permit",
label: st.state_carrier_permit_name || "State Carrier Permit",
status: "yellow",
detail: `${phyState} requires a ${st.state_carrier_permit_name || "state motor carrier permit"}.`
+ (st.state_carrier_permit_notes ? ` ${st.state_carrier_permit_notes}` : ""),
action_url: st.state_carrier_permit_url || null,
});
}
// Check 12: Emissions (CARB, ACT)
if (st.emissions_program) {
checks.push({
id: "emissions",
label: st.emissions_program_name || "Emissions Compliance",
status: "yellow",
detail: `${phyState} has emissions requirements for commercial vehicles: ${st.emissions_program_name || "state emissions program"}.`
+ (st.emissions_notes ? ` ${st.emissions_notes}` : ""),
action_url: st.emissions_url || null,
});
}
// Check 13: Intrastate Authority
if (st.intrastate_authority_required && isForHireCarrier) {
checks.push({
id: "intrastate_authority",
label: "Intrastate Operating Authority",
status: "yellow",
detail: `For-hire intrastate carriers in ${phyState} need ${st.intrastate_authority_name || "state operating authority"} from ${st.intrastate_authority_agency || "the state PUC/PSC"}.`
+ (st.intrastate_authority_notes ? ` ${st.intrastate_authority_notes}` : ""),
action_url: st.intrastate_authority_url || null,
});
}
// Check 14: State DOT Number
if (st.state_dot_required) {
checks.push({
id: "state_dot",
label: st.state_dot_number_name || "State DOT Registration",
status: "yellow",
detail: `${phyState} requires a ${st.state_dot_number_name || "state DOT number"} in addition to your federal USDOT number.`
+ (st.state_dot_notes ? ` ${st.state_dot_notes}` : ""),
action_url: st.state_dot_url || null,
});
}
}
} catch (stErr) {
// Table may not exist yet — skip state checks silently
console.warn("[dot-lookup] State checks skipped:", (stErr as Error).message);
}
}
// Build response
const redCount = checks.filter(c => c.status === "red").length;
const yellowCount = checks.filter(c => c.status === "yellow").length;
@ -416,4 +519,87 @@ router.get("/api/v1/dot/search", async (req, res) => {
}
});
// ── State Requirements Lookup ──────────────────────────────────────
router.get("/api/v1/dot/state-requirements", async (req, res) => {
const baseState = ((req.query.base_state as string) || "").toUpperCase().trim();
const opStates = ((req.query.operating_states as string) || "")
.split(",")
.map(s => s.toUpperCase().trim())
.filter(s => s.length === 2);
// Include base_state in the lookup set
const allStates = [...new Set([baseState, ...opStates].filter(Boolean))];
if (!allStates.length) {
res.status(400).json({ error: "Provide base_state and/or operating_states." });
return;
}
try {
const result = await pool.query(
"SELECT * FROM state_trucking_requirements WHERE state_code = ANY($1::char(2)[])",
[allStates],
);
const requirements: Record<string, any> = {};
const recommended: Array<{ slug: string; name: string; price_cents: number; reason: string }> = [];
let needsIrp = false;
let needsIfta = false;
for (const st of result.rows) {
const code = st.state_code;
const reqs: string[] = [];
if (st.irp_member) { reqs.push("IRP"); needsIrp = true; }
if (st.ifta_member) { reqs.push("IFTA"); needsIfta = true; }
if (st.weight_distance_tax) {
reqs.push(st.weight_distance_tax_name || "Weight-Distance Tax");
const slugMap: Record<string, string> = { OR: "or-weight-mile-tax", NY: "ny-hut-registration", KY: "ky-kyu-registration", NM: "nm-weight-distance", CT: "ct-highway-use-fee" };
if (slugMap[code]) {
recommended.push({ slug: slugMap[code], name: st.weight_distance_tax_name, price_cents: 19900, reason: `${code} ${st.weight_distance_tax_name} required` });
}
}
if (st.state_carrier_permit) {
reqs.push(st.state_carrier_permit_name || "State Carrier Permit");
if (code === "CA") recommended.push({ slug: "ca-mcp-carb", name: "California MCP + CARB Compliance", price_cents: 34900, reason: "CA Motor Carrier Permit + CARB required" });
}
if (st.emissions_program) reqs.push(st.emissions_program_name || "Emissions");
if (st.intrastate_authority_required) {
reqs.push("Intrastate Authority");
recommended.push({ slug: "intrastate-authority", name: "Intrastate Operating Authority", price_cents: 24900, reason: `${code} requires state operating authority` });
}
if (st.state_dot_required) reqs.push(st.state_dot_number_name || "State DOT Number");
requirements[code] = { ...st, requirement_summary: reqs };
}
// Add IRP/IFTA recommendations if any state requires them
if (needsIrp && allStates.length > 1) {
recommended.unshift({ slug: "irp-registration", name: "IRP Registration Assistance", price_cents: 19900, reason: "IRP required for interstate operation" });
}
if (needsIfta && allStates.length > 1) {
recommended.splice(1, 0, { slug: "ifta-application", name: "IFTA Application + Decals", price_cents: 14900, reason: "IFTA required for interstate fuel tax" });
}
// Deduplicate recommendations by slug
const seen = new Set<string>();
const uniqueRecs = recommended.filter(r => { if (seen.has(r.slug)) return false; seen.add(r.slug); return true; });
// Add bundle if 3+ recommendations
if (uniqueRecs.length >= 3) {
uniqueRecs.push({ slug: "state-trucking-bundle", name: "State Compliance Bundle", price_cents: 59900, reason: "Bundle saves vs. individual services" });
}
res.json({
base_state: baseState || null,
operating_states: opStates,
requirements,
recommended_services: uniqueRecs,
});
} catch (err) {
console.error("[dot-state-requirements] Error:", err);
res.status(500).json({ error: "State requirements lookup failed." });
}
});
export default router;