new-site/api/migrations/094_fmcsa_ifta_reminded.sql
justin 3d4226e95c ifta: 3-touch business-day cadence + 'I already filed it' suppression
- Multi-touch reminders at 10/7/4 BUSINESS days before each deadline (weekends
  skipped; biz-day math so a touch never lands purely on a weekend with no
  runway). Escalating tone soft -> urgent -> last-chance, with the 'almost too
  late to DIY, we can still file it' angle so it's a convenience sale, not a free
  reminder service. ifta_touch_no tracks the highest touch sent so each touch
  hits only carriers below that level; never repeats a touch.
- 'I already filed it' one-click link: HMAC-tokenized GET /api/v1/ifta/filed
  (token matches between Python builder and api/src/routes/ifta.ts -- verified
  identical output), records ifta_self_filed_at, friendly confirmation page,
  stops further touches this cycle + gives DIY-vs-prospect signal. Builder
  excludes self-filed carriers.
- migration 094 (ifta_touch_no) + 095 (ifta_self_filed_at); cycle reset clears
  both each new quarter. Verified: biz-day touch schedule, token cross-match.
2026-06-13 23:41:14 -05:00

13 lines
664 B
SQL

-- Track IFTA quarterly-return reminder touches per interstate carrier so the
-- multi-touch cadence (10/7/4 business days before deadline) never repeats a
-- touch and escalates correctly. Reset each new quarter by the IFTA builder.
-- ifta_reminded_at : timestamp of the most recent IFTA touch (any)
-- ifta_touch_no : highest touch number sent this cycle (1=10d, 2=7d, 3=4d)
ALTER TABLE fmcsa_carriers
ADD COLUMN IF NOT EXISTS ifta_reminded_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS ifta_touch_no SMALLINT;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_fmcsa_carriers_ifta_reminded
ON fmcsa_carriers (ifta_touch_no)
WHERE carrier_operation = 'A';