ucr: annual-renewal reminder campaign + order-alert campaign source

UCR (Unified Carrier Registration) is annual: opens Oct 1, due Dec 31, mandatory
for interstate carriers (op A, same ~628k pool as IFTA) -> recurring revenue.

- build_ucr_annual_campaign.py: 3-touch business-day cadence (30/12/4 bd before
  Dec 31, wider than IFTA since it's once a year), escalating tone, same-day
  coupon, 'I already did it' suppression. Reuses build_trucking_campaigns +
  IFTA business-day/token helpers (DRY). Per-year cycle reset.
- ucr_annual_reminder.html: deadline + fines/OOS risk + 'we figure out your fee
  tier' + coupon + filed link + CAN-SPAM. Source campaign 473.
- migration 096: ucr_reminded_at / ucr_touch_no / ucr_self_filed_at.
- ifta.ts: add GET /api/v1/ucr/filed (shares the HMAC token scheme).
- checkout.ts: order-placement Telegram now shows 'Source: campaign (code X)'
  when a discount code is present, so IFTA/UCR/CLIA conversions are visible.
  (Confirmed order-alert Telegram already fires from handlePaymentComplete for
  all compliance orders via both webhook + session paths.)
This commit is contained in:
justin 2026-06-14 00:30:23 -05:00
parent 2b361a83a8
commit a2665c22c2
5 changed files with 356 additions and 0 deletions

View file

@ -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';