The p4 Clients roster in one SQL statement (#4365)
Changed onEvery client the caller can see (a human super-admin: every client) whose client status is test or active, ordered by name, read in one SQL statement, plus the counts per status. status is the first rule that holds: stopped (the client's kill switch is on), off (Penny is not on for the client: no settings row, not enabled, not on the deployment allowlist, Penny off for the deployment, or a patient-data company), blocked (an open Inbox item in group blocked), watch (an open Inbox item older than 48 hours; a stand-in until a close due date and "waiting on client" exist), else on_track. onboarding (PG-p04-011, aligned with #5105's isClientOnboarding) is true only for a test client with neither onboarding_completed_at nor company_books_status.last_close_date. accountingBasis (PG-p07-021) is "cash", "accrual", or null resolved in order from effective company_statement_basis, effective company_book_basis, tax_settings.accounting_method, and companies.accounting_method. reviewer (PG-p07-021) is { accountantId, name } from the assigned close reviewer (client_close_duties, duty reviewer), else the earliest assigned accountant with role reviewer, or null. pennyLiveActionTypes and pennyTotalActionTypes (PG-p07-021) count live agent_capability_states out of AGENT_CAPABILITIES.length (6). close is the close target (the oldest ended open GL period) with its completed or skipped step rows over all its step rows, or null when nothing is to close. openItems counts open Inbox items (a snoozed item whose time has passed reads open); next is the open item ranked blocked, review, ready, then oldest. owner is the earliest primary assignee. patientData is null when the client has no Penny settings row. #2587 p4: status is deprecated for the screen; read health: the worst of the client's six functions and its close prep. The functions are the ones p7's Overview shows (GET …/agent/functions, its close_prep row left out; PG-p01-002, so Clients and the Overview never disagree; none counts as off); where that read is not wired, roster-details' Inbox-derived states (deprecated) (blocked over watch over on_track); off functions are ignored, and the client is off only when all six are off and it has no close prep. Where Penny does not run at the client (not enabled, not on the deployment allowlist, patient data not answered "no", a company Penny refuses), only the Penny-run functions read off (categorize, reconcile, revenue, bills, documents); bank_feeds and close prep keep their own states (PG-p01-002, Lead 11-19). With health read, status is stopped by the kill switch, else stopped by Penny's stops where Penny is on, else health. Penny's own stop is roster-details' penny.mode, not health. closePrep is the client's row on GET /month-end-close/board (its default month): steps before close day done of 6, open codes, blocked; its health is blocked when the board marks the client blocked, watch when not ready while the board is behind pace, else on_track. Null with no close target. health and closePrep are null when the functions read is not wired. owner.userId is the owner's user id (null for an accountant with no user). lifecycle (PG-p04-021 / PG-p04-011) is inactive when client_status = inactive, else onboarding when onboarding is true, else active. ?lifecycle=inactive lists the caller's inactive clients instead, in the same row shape with health and closePrep null and summary counting that list; absent, the default list and its counts never include an inactive client (p13-003). Any other value is a 422. Display only: nothing is written. A signed-in person only: every API key is refused, the service token included (404).
Request
- Base URLhttps://api.medianfi.com/api/v1
- AuthHTTP bearer
Query parameters
PG-p04-021. inactive lists the inactive clients instead of the default (test and active) list.
Response
The roster and its counts
Changes
- info
endpoint added
- info