Delivery Ledger — missing invoice totals on resends
Symptom: invoices on the Delivery Ledger (portal, owner/admin) showing no total; most visible on 2026-08-04 (nine re-sends: T-MANA-INV-9166–9173 batch + MANA-INV-9194/9195).
Cause: invoice_total was added to tracking_tokens in 4616c0c
(2026-03-29) but only wired into the first-send path
(portal_cert_invoice_service.send_invoice). resend_invoice never passed it,
so every resent invoice recorded NULL. The column also only existed via a
manual prod ALTER — _ensure_tables in email_tracking_service still created
the old schema on fresh DBs.
Fix (entirely-api 3621a69): resend path now reads FIELD_INVOICE_TOTAL
identically to first-send; CREATE TABLE gains invoice_total REAL plus a
defensive PRAGMA-guarded ALTER (same pattern as delivery_status in
bounce_scanner).
Backfill: 42 of 43 NULL rows (2026-04-15 → 08-04) filled from Supabase
projects.invoice_total with an invoice-number match guard
(/home/claude/backfill_ledger_totals.py, dry-run then apply, verified).
Remaining: T-MANA-INV-9070 (6902 97th Place, Lanham) — project has no stored
invoice_total.
Related: email-tracking-service, delivery-ledger