---
name: xero-validation-project
description: "Evolution Xero pre-sync validation — requirements list done, checker + fallback-bank code pending"
metadata: 
  node_type: memory
  type: project
  originSessionId: e5f71c8e-37bc-4203-b6fc-0d076945ad4f
---

Pre-sync validation gate for Evolution→Xero, so misconfigured tenants are caught before they can push bills/invoices/payments (instead of crashing mid-sync like the `accountid cannot be null` cron failure on 2026-06-22).

**Phase 1 (done):** Requirements list at `evolution/audits/XERO_VALIDATION_REQUIREMENTS.md` — 4 severity tiers (BLOCK vs WARN), every dependency traced to a real table.column/getPref/getSetting. Triggered by, and built on top of, the `commitBillPayments()` null-account guard fix (see [[evolution_xero_ap_payment_sync]]).

**Key decision — fallback bank account (R-BANK-1):** explicit-then-implicit. `getSetting('defaultBankAccount')` returns the `accounts.id` to use (a *required* general setting, not Xero-specific); if unset, fall back implicitly to the first `type='2'` account with an `externalref`. When Xero is on, that account MUST have a Xero ID (`externalref`) or the tenant fails validation and is blocked from sending. Bank accounts = `accounts.type='2'`; Xero code lives in `accounts.externalref` (edit field `extRef` on `page=accountreg`/`accountedit`). No prior default-bank concept existed in the codebase.

**Phase 2 done (items 1+3):** `library/xeroValidator.php` (validate()/passesBlocking()/blockingFailures()/static gate(); static resolveDefaultBankAccount() = explicit `getSetting('defaultBankAccount')` then implicit first Xero-mapped bank). UI dashboard `xeroreadiness.inc` (`page=xeroreadiness`, admin-only, Fix deep-links). Cron now resolves unmatched payments to the fallback + flags review (was recording account=NULL), and logs a non-fatal pre-flight gate per tenant. Item 2 (defaultBankAccount setting+UI) was done by the user.

**Still pending:** nav/menu entry for `page=xeroreadiness` (URL-reachable only); wiring the gate into non-cron push handlers; optional promotion of the cron gate from log-only to hard-skip.
