Delivery Ledger — Account Resolution (2026-07-27)

Bug (reported by Dustin): the /delivery-ledger account column showed “Unlikely Professionals” for post-production desk reviews (PPDR-to-UP). It stored the raw linked-account title at send time. Display metadata only — the invoices themselves were verified correct (Bill To = JES branch, T-<branch> numbering).

Fix (entirely-api 3176b8c): new shared helper config.resolve_billing_account_id(project, account_id) — originating JES branch for triage-owned and PPDR-to-UP projects, own account otherwise. Applied at all three tracking-token creation sites:

  • cert send (routes/cert.py deliver_cert_internal)
  • invoice send (services/portal_cert_invoice_service.py)
  • invoice resend (previously recorded no account at all)

Backfill: 10 rows in /data/portal-auth/email_tracking.db corrected (8× T-MANA 7/24 PPDR batch → “JES - Manassas”; 1155 Ferber Ave cert + invoice → “JES - Baltimore”). 216 Wildman St rows left as “Unlikely Professionals” — genuine direct UP client.

Related: cert-routing, PPDR carve-out in resolve_cert_route_account_id.

Branch column fix (same day, 3325fda)

The branch column stored route_label.split()[0] — “JES”/“Unlikely”/“No”, useless for the API’s exact-match branch filter. Now stores the config.INVOICE_BRANCH_CODES code (MANA/BALT/RICH/NHAV/UPRO…) of the resolved billed account at all three send sites; “TRIAGE” only when the originating branch is unresolvable. Backfilled all 436 rows via per-project resolution in-container (380 MANA / 52 BALT / 4 UPRO, 0 unresolvable) and filled 105 blank/“JES Triage” account values with the branch account title. One-shot script: /home/claude/backfill_ledger_branch.py.