Skip to content

Fix account clear when references exist - #12

Merged
pallaoro merged 1 commit into
mainfrom
fix/account-clear-references
Sep 21, 2026
Merged

pallaoro merged 1 commit into
mainfrom
fix/account-clear-references

Conversation

@pallaoro

Copy link
Copy Markdown
Member

What changed

  • refuse account-chart clearing atomically when products, invoice lines, or posted journal entries still reference an account
  • map the named SQLite refusal to the existing actionable HTTP 409 response
  • remove the incomplete preflight check that only covered posted journal lines
  • add foreign-key-enabled HTTP regressions for unused, product-referenced, and draft-line-referenced charts

Why

PR #11 made the posted-journal case return 409, but the other two account foreign keys still produced a raw FOREIGN KEY constraint failed response and HTTP 500. Keeping the guard in SQLite makes the check and multi-row delete one atomic statement across D1 and preview storage.

Validation

  • pnpm test — 70/70 passed
  • pnpm build — passed
  • git diff --check — passed
  • local Wrangler D1 review reproduced the named trigger refusal and preserved all account rows

@pallaoro
pallaoro merged commit 78752e0 into main Sep 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant