Branch derivation — shared helper (config.derive_invoice_branch)

Connections

Notes

  • 2026-07-28: Display-branch derivation unified into config.derive_invoice_branch (entirely-api 255c2f7). Precedence: account mapping unless UPRO → invoice-number prefix (after stripping T-) → triage_originating_branch → UPRO/blank fallback. UP-assigned PPDR desk reviews and legacy triage projects sit on ACCOUNT_UNLIKELY_PRO intentionally, so account-only lookups mislabeled them “UPRO” (or blank for triage-account rows).
  • Three call sites now share it: payments ledger (routes/portal_payment_recon.py, originally fixed in 8b14f0a), morning-ops briefing (services/agent_morning_ops.py _annotate_branches — keeps its explicit TRIAGE label for ACCOUNT_JES_TRIAGE and ”?” unknown fallback), and financial recon scanner (services/financial_recon_scanner.py _check_status_consistency). Both report queries added invoice_number/triage_originating_branch to their Supabase selects.
  • Cosmetic/reporting only — no routing or billing behavior. Any future spot that needs a display branch from a project/invoice row should call this helper, not INVOICE_BRANCH_CODES directly.