From 2eeac78b403cb58d464880eb8463ce306bddd5d1 Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 3 May 2026 16:26:23 -0400 Subject: [PATCH] fix(balance): exclude archived accounts from starter collisions (S4) getStarterCollisions now filters `archived_at IS NULL` so a starter account the user voluntarily archived no longer blocks re-creation through the StarterAccountsModal. Matches the rest-of-codebase convention (active = is_active=1 AND archived_at IS NULL). Suggestion S4 from PR #185 review (#187). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/balance/StarterAccountsModal.test.tsx | 7 +++++++ src/services/balance.service.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/balance/StarterAccountsModal.test.tsx b/src/components/balance/StarterAccountsModal.test.tsx index 81486d6..e0482dc 100644 --- a/src/components/balance/StarterAccountsModal.test.tsx +++ b/src/components/balance/StarterAccountsModal.test.tsx @@ -73,6 +73,13 @@ describe("getStarterCollisions", () => { expect(result.has("tfsa")).toBe(false); expect(result.has("cash")).toBe(false); // name "CELI" != "Compte chèque" }); + + it("excludes archived accounts via SQL filter", async () => { + mockSelect.mockResolvedValueOnce([]); + await getStarterCollisions(); + const sql = mockSelect.mock.calls[0][0]; + expect(sql).toMatch(/archived_at IS NULL/); + }); }); describe("proposeStarterAccounts", () => { diff --git a/src/services/balance.service.ts b/src/services/balance.service.ts index 5631466..52c083a 100644 --- a/src/services/balance.service.ts +++ b/src/services/balance.service.ts @@ -487,7 +487,8 @@ export async function getStarterCollisions(): Promise> { `SELECT c.key AS key, a.name AS account_name FROM balance_accounts a INNER JOIN balance_categories c ON c.id = a.balance_category_id - WHERE c.key IN ('cash','tfsa','rrsp','other')` + WHERE c.key IN ('cash','tfsa','rrsp','other') + AND a.archived_at IS NULL` ); const collisions = new Set(); for (const starter of STARTER_ACCOUNTS) {