Add multi-account support

- Schema: account_id FK on checks and layout_fields; UNIQUE per-account on check_no and field_name
- DB: runtime migration recreates both tables to add account_id (assigns existing rows to account 1)
- Routes: GET /api/accounts lists all; GET /api/account/:id replaces hardcoded id=1; POST /api/account/setup always creates a new account and returns accountId
- checks.js: all queries scoped by account_id; POST requires account_id in body
- pdf.js: resolves account from check's account_id instead of id=1; layout fields fetched per-account
- import-mdb.js: always INSERTs a new account (never deletes existing); all records tagged with new accountId
- Frontend: account switcher in header; activeAccountId persisted to localStorage; all API calls pass account_id; switching accounts reloads checks; wizard and import auto-switch to newly created account
This commit is contained in:
2026-03-12 22:13:52 -06:00
parent 5f9cc16ea5
commit e81a4386d2
10 changed files with 285 additions and 192 deletions
+12
View File
@@ -41,6 +41,18 @@ header {
.header-brand { font-size: 15px; font-weight: 600; }
.header-info { font-size: 12px; color: rgba(255,255,255,0.7); }
.header-info strong { color: #fff; }
.header-left { display: flex; align-items: center; gap: 10px; }
.account-switcher {
background: rgba(255,255,255,0.15);
border: 1px solid rgba(255,255,255,0.3);
color: #fff;
border-radius: 4px;
padding: 2px 6px;
font-size: 12px;
cursor: pointer;
}
.account-switcher option { background: var(--header-bg); color: #fff; }
/* ── Toolbar ── */
.toolbar {