chore: check in pending work — queue preferences, QBO AR diagnostics, mobile engagement fixes, ops scripts

Bundles several in-progress efforts that were sitting uncommitted:
- User queue-preferences (migration 087, API route, popover component)
- QBO invoice soft-delete (migration 088) and AR diagnostics route
- Dashboard/mobile engagement route and page adjustments
- Docker Compose log-rotation config
- One-off ticket/RMM investigation scripts (scripts/)
- Planning docs: phase verification/pattern notes, mobile shell design spec
- .gitignore: exclude local scratch financial/inventory data and Claude Code
  worktree/local-settings runtime state (never meant for version control)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6RuWdiUiXrPK6FLBHjtpY
This commit is contained in:
lorentz 2026-07-18 06:34:57 -04:00
parent b638189cb0
commit 672f17b7f9
35 changed files with 2801 additions and 92 deletions

View file

@ -0,0 +1,23 @@
-- =============================================================================
-- Per-user queue preferences
-- =============================================================================
-- Lets each user hide specific queues from their own dashboard widgets
-- (notably the Queue posture heatmap). Presence of a row = that user has
-- hidden that queue. Absence = visible.
--
-- Independent of the global company_scope filter — that affects KPI counts
-- for everyone, this only affects what an individual user chooses to see.
-- =============================================================================
CREATE TABLE IF NOT EXISTS user_queue_preferences (
user_id TEXT NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
queue_id INTEGER NOT NULL REFERENCES queues(value) ON DELETE CASCADE,
hidden_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (user_id, queue_id)
);
CREATE INDEX IF NOT EXISTS idx_user_queue_preferences_user
ON user_queue_preferences(user_id);
COMMENT ON TABLE user_queue_preferences IS
'Per-user hidden-queue list. Row presence = queue is hidden for that user in dashboard widgets.';

View file

@ -0,0 +1,17 @@
-- Soft-delete support for qbo_invoices.
--
-- QBO's Invoice query endpoint only returns rows that still exist in QBO.
-- When an invoice is voided or deleted in QBO, it simply stops appearing in
-- responses — there is no "deleted" flag we can subscribe to. Without a
-- tombstone pass these orphan rows linger in Pulse forever and keep
-- inflating Total A/R (see the TNT Pizza incident, 2026-05-15).
--
-- A full QBO sync now compares the set of returned invoice IDs against
-- what Pulse has on file and flips is_deleted = true for any row the
-- query no longer returns. Finance queries filter on is_deleted = false.
ALTER TABLE qbo_invoices
ADD COLUMN IF NOT EXISTS is_deleted BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
CREATE INDEX IF NOT EXISTS idx_qbo_invoices_is_deleted ON qbo_invoices(is_deleted);