diff --git a/public/css/style.css b/public/css/style.css
index c920b5c..ce048ad 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -174,6 +174,9 @@ button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg); }
+.btn-danger { background: #dc2626; color: #fff; font-weight: 500; }
+.btn-danger:not(:disabled):hover { background: #b91c1c; }
+.delete-account-row { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.btn-icon {
background: transparent;
diff --git a/public/index.html b/public/index.html
index 2e8c028..7d6bd99 100644
--- a/public/index.html
+++ b/public/index.html
@@ -300,6 +300,10 @@
+
+
+
+
+
+
+ This cannot be undone. Deleting this account will permanently remove all checks, deposits, and account settings. There is no recovery.
+
+
Are you sure you want to delete ?
+
+
+
+
diff --git a/public/js/app.js b/public/js/app.js
index 60c2946..34fcd5c 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -644,6 +644,40 @@ async function saveAccountSettings() {
}
}
+// ── Delete account ────────────────────────────────────────────────────────────
+
+function openDeleteAccount() {
+ const name = (state.account && state.account.company1) || 'this account';
+ document.getElementById('delete-account-name').textContent = name;
+ document.getElementById('delete-account-overlay').classList.add('open');
+ document.getElementById('delete-account-modal').classList.add('open');
+}
+
+function closeDeleteAccount() {
+ document.getElementById('delete-account-overlay').classList.remove('open');
+ document.getElementById('delete-account-modal').classList.remove('open');
+}
+
+async function confirmDeleteAccount() {
+ const btn = document.getElementById('btn-confirm-delete-account');
+ btn.disabled = true;
+ btn.textContent = 'Deleting…';
+ try {
+ await apiFetch('DELETE', `/api/account/${state.activeAccountId}`);
+ closeDeleteAccount();
+ closeAccountSettings();
+ state.account = null;
+ state.activeAccountId = null;
+ state.checks = [];
+ localStorage.removeItem('activeAccountId');
+ await loadAccounts(); // will open wizard if no accounts remain
+ } catch (err) {
+ alert('Delete failed: ' + err.message);
+ btn.disabled = false;
+ btn.textContent = 'Yes, Delete Account';
+ }
+}
+
// ── QBO Import ────────────────────────────────────────────────────────────────
let qboChecksRecords = null;
@@ -1241,6 +1275,12 @@ function init() {
document.getElementById('acct-settings-overlay').addEventListener('click', closeAccountSettings);
document.getElementById('btn-save-acct-settings').addEventListener('click', saveAccountSettings);
+ document.getElementById('btn-delete-account').addEventListener('click', openDeleteAccount);
+ document.getElementById('btn-close-delete-account').addEventListener('click', closeDeleteAccount);
+ document.getElementById('btn-cancel-delete-account').addEventListener('click', closeDeleteAccount);
+ document.getElementById('delete-account-overlay').addEventListener('click', closeDeleteAccount);
+ document.getElementById('btn-confirm-delete-account').addEventListener('click', confirmDeleteAccount);
+
document.getElementById('btn-set-check-no').addEventListener('click', openSetCheckNo);
document.getElementById('btn-close-set-check-no').addEventListener('click', closeSetCheckNo);
document.getElementById('btn-cancel-set-check-no').addEventListener('click', closeSetCheckNo);
diff --git a/src/app.js b/src/app.js
index 5f7f107..c4369ab 100644
--- a/src/app.js
+++ b/src/app.js
@@ -104,6 +104,22 @@ app.put('/api/account/:id/check-no', (req, res) => {
res.json({ next_check_no: next });
});
+// DELETE /api/account/:id - delete account and all associated data
+app.delete('/api/account/:id', (req, res) => {
+ const db = require('./db/database');
+ const account = db.prepare('SELECT id FROM account WHERE id = ?').get(req.params.id);
+ if (!account) return res.status(404).json({ error: 'Account not found.' });
+
+ db.transaction(() => {
+ // deposit_items deleted via ON DELETE CASCADE from deposits
+ db.prepare('DELETE FROM deposits WHERE account_id = ?').run(req.params.id);
+ db.prepare('DELETE FROM checks WHERE account_id = ?').run(req.params.id);
+ db.prepare('DELETE FROM account WHERE id = ?').run(req.params.id);
+ })();
+
+ res.status(204).end();
+});
+
// POST /api/account/setup - create a new account (wizard)
app.post('/api/account/setup', (req, res) => {
const db = require('./db/database');