VAB PPDR Branch Display + Invoice Numbering Fix

Date: 2026-07-30 (session 66) · Commits: entirely-api da3a5ef, entirely-portal b29ec6b

Symptom

Calendar day-sidebar showed “Client: Manassas” for the 11 Mathews County VAB desk reviews (Virginia Beach PPDR engagement, created via triage intake wizard 2026-07-29).

Root causes (two independent gaps, same underlying pattern)

  1. Frontend: resolveBranch re-derived branch from the event title’s [UPR] account prefix with a hardcoded 'UPR': 'manassas' fallback — a relic from when all UP-parked desk reviews were Manassas PPDR. It ignored the server’s branch field entirely.
  2. Server: calendar_events set branch from the owning account only (unlikely_pro), never consulting triage_originating_branch.
  3. Bonus find: invoice_numbering’s originating-branch fallback used an inline 3-entry map (JES Baltimore/Manassas/Richmond exact strings) — “virginia beach” missed → 8 invoices numbered T-UPRO-INV-9178…9186 instead of T-VBEACH-INV-*.

What was NOT broken (verified via comm_log delivery evidence)

Fixes

  • intake.calendar_events: new _origin_branch_slug() (all branches, all text variants); UP-parked rows resolve display branch from originating branch; triage source_branch set widened; VAB/ROA/WV account codes mapped.
  • invoice_numbering: fallback resolves via config._TRIAGE_BRANCH_NAME_TO_ACCOUNT + INVOICE_BRANCH_CODES. First post-fix number came out T-VBEACH-INV-9188 (VAB-9010, live proof).
  • config: Roanoke/West Virginia added to _TRIAGE_BRANCH_NAME_TO_ACCOUNT.
  • Portal: resolveBranch prefers server ev.branch; UPR→manassas hack removed (UPR→unlikely_pro); Virginia Beach/Roanoke/West Virginia/ Hooksett display names; virginia_beach + unlikely_pro colors.

Backfill

invoice_numbers.db ledger branch_code UPRO→VBEACH for the 8 issued rows. Number strings deliberately unchanged — they are on delivered invoices and payment reconciliation matches by invoice number. Backup: /home/claude/.tmp/invoice_numbers.db.bak-20260730.

Pattern to remember

Every new JES branch must land in THREE maps or this recurs: _TRIAGE_BRANCH_NAME_TO_ACCOUNT, INVOICE_BRANCH_CODES (both config), and the calendar _branch_map/frontend BRANCH_DISPLAY_NAMES+BRANCH_COLORS. Rule from session 63 stands: display-branch derivation goes through shared config helpers, never inline maps.