diff --git a/api/migrations/096_fmcsa_ucr_reminder.sql b/api/migrations/096_fmcsa_ucr_reminder.sql new file mode 100644 index 0000000..d11ee6e --- /dev/null +++ b/api/migrations/096_fmcsa_ucr_reminder.sql @@ -0,0 +1,15 @@ +-- UCR annual-renewal reminder tracking (mirrors IFTA): per-carrier touch number, +-- last-touch timestamp, and "I already did it" self-filed suppression. +-- Reset each year by build_ucr_annual_campaign.py. +-- ucr_reminded_at : timestamp of the most recent UCR touch +-- ucr_touch_no : highest touch number sent this cycle (1=30bd,2=12bd,3=4bd) +-- ucr_self_filed_at: clicked "I already registered" -> stop reminding this cycle + +ALTER TABLE fmcsa_carriers + ADD COLUMN IF NOT EXISTS ucr_reminded_at TIMESTAMPTZ, + ADD COLUMN IF NOT EXISTS ucr_touch_no SMALLINT, + ADD COLUMN IF NOT EXISTS ucr_self_filed_at TIMESTAMPTZ; + +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_fmcsa_carriers_ucr_touch + ON fmcsa_carriers (ucr_touch_no) + WHERE carrier_operation = 'A'; diff --git a/api/src/routes/checkout.ts b/api/src/routes/checkout.ts index b3f869d..d977c23 100644 --- a/api/src/routes/checkout.ts +++ b/api/src/routes/checkout.ts @@ -1735,11 +1735,18 @@ export async function handlePaymentComplete( const idLine = dotNumber ? `DOT#: ${dotNumber}\n` : frn ? `FRN: ${frn}\n` : ""; + // Campaign-source hint: an order carrying the daily campaign coupon (or any + // discount code) almost certainly came from an email campaign. Surface it so + // you can see the IFTA/UCR/CLIA/cold-email pipelines actually converting. + const srcLine = order.discount_code + ? `Source: campaign (code ${order.discount_code})\n` + : ""; const msg = `💰 NEW ORDER\n\n` + `Customer: ${customerName}\n` + `Email: ${customerEmail}\n` + idLine + serviceLine + + srcLine + subtotalLine + discountLine + surchargeLine diff --git a/api/src/routes/ifta.ts b/api/src/routes/ifta.ts index 172908b..9064688 100644 --- a/api/src/routes/ifta.ts +++ b/api/src/routes/ifta.ts @@ -82,4 +82,46 @@ router.get("/api/v1/ifta/filed", async (req, res) => { See how it works →
`)); }); +/** + * One-click "I already did it" for UCR annual reminders. + * GET /api/v1/ucr/filed?dot=1234567&t=If you already registered your UCR, you can ignore the reminders. Questions? Call (888) 411-0383.
`)); + return; + } + const expected = iftaFiledToken(dot); // shared token scheme + const ok = token.length === expected.length + && crypto.timingSafeEqual(Buffer.from(token), Buffer.from(expected)); + if (!ok) { + res.status(403).send(page("Invalid link", + `If you already registered your UCR, you can ignore the reminders. Questions? Call (888) 411-0383.
`)); + return; + } + try { + await pool.query( + `UPDATE fmcsa_carriers + SET ucr_self_filed_at = COALESCE(ucr_self_filed_at, now()) + WHERE dot_number = $1`, + [dot], + ); + } catch (err) { + console.error("[ucr/filed] db error:", err); + } + res.send(page("Thanks - you're all set", + `We'll stop reminding you about this year's UCR for DOT #${dot}. + We'll check back when next year's registration opens.
+Want us to handle next year's UCR so you don't have to? + See how it works →
`)); +}); + export default router; diff --git a/data/trucking_campaigns/ucr_annual_reminder.html b/data/trucking_campaigns/ucr_annual_reminder.html new file mode 100644 index 0000000..67c3ad1 --- /dev/null +++ b/data/trucking_campaigns/ucr_annual_reminder.html @@ -0,0 +1,43 @@ +
+{{ .Subscriber.Attribs.company }},
DOT# {{ .Subscriber.Attribs.dot_number }}
{{ .Subscriber.Attribs.ucr_urgency }}
+Your {{ .Subscriber.Attribs.ucr_year }} Unified Carrier Registration is due by {{ .Subscriber.Attribs.ucr_due_date }}. If you run interstate, UCR is mandatory. Skip it and you face:
+TODAY ONLY - {{ .Subscriber.Attribs.coupon_pct }}% OFF
+We file your UCR for $39 $23 + the state fee.
+Use code {{ .Subscriber.Attribs.coupon_code }} at checkout.
+Expires {{ .Subscriber.Attribs.coupon_expires }}.
+We file your UCR for $39 + the state fee.
+Two minutes of your time, we handle the rest. No portals, no guesswork on your fee tier.
+We figure out your exact fee tier.
+UCR fees are based on your fleet size, and getting the tier wrong causes rejections and delays. Tell us your power-unit count and we file it correctly the first time, so you stay legal and on the road.
+Or call us directly at (888) 411-0383.
+Already registered for this year?
+I already did it - stop reminding me +Performance West Inc.
DOT Compliance Services