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) <noreply@anthropic.com>
This commit is contained in:
parent
fbd8be403a
commit
2eeac78b40
2 changed files with 9 additions and 1 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -487,7 +487,8 @@ export async function getStarterCollisions(): Promise<Set<string>> {
|
|||
`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<string>();
|
||||
for (const starter of STARTER_ACCOUNTS) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue