money: archived accounts (accounts.archived) — closed banks stay in history, net worth and charts but leave the quick balances, quick add and account pickers; archived section in the accounts panel; quick add defaults to Revolut
All checks were successful
Deploy production / deploy (push) Successful in 1m7s
All checks were successful
Deploy production / deploy (push) Successful in 1m7s
This commit is contained in:
@@ -128,6 +128,7 @@ export const actions: Actions = {
|
||||
const openingBalanceCents = cents(form.get('openingBalance'));
|
||||
const kind = String(form.get('kind') ?? 'spendable');
|
||||
const includeInTotal = form.get('includeInTotal') === 'on';
|
||||
const archived = form.get('archived') === 'on';
|
||||
const colorRaw = String(form.get('color') ?? '').trim();
|
||||
const color = colorRaw ? colorRaw.toLowerCase() : null;
|
||||
if (!name || openingBalanceCents == null || !['spendable', 'investment'].includes(kind))
|
||||
@@ -138,14 +139,20 @@ export const actions: Actions = {
|
||||
if (id) {
|
||||
const [row] = await db
|
||||
.update(moneyAccounts)
|
||||
.set({ name, openingBalanceCents, kind, includeInTotal, color })
|
||||
.set({ name, openingBalanceCents, kind, includeInTotal, archived, color })
|
||||
.where(and(eq(moneyAccounts.id, id), eq(moneyAccounts.userId, user.id)))
|
||||
.returning({ id: moneyAccounts.id });
|
||||
if (!row) error(404, 'Account not found');
|
||||
} else
|
||||
await db
|
||||
.insert(moneyAccounts)
|
||||
.values({ userId: user.id, name, openingBalanceCents, kind, includeInTotal, color });
|
||||
await db.insert(moneyAccounts).values({
|
||||
userId: user.id,
|
||||
name,
|
||||
openingBalanceCents,
|
||||
kind,
|
||||
includeInTotal,
|
||||
archived,
|
||||
color
|
||||
});
|
||||
} catch (cause) {
|
||||
if (typeof cause === 'object' && cause && 'code' in cause && cause.code === '23505')
|
||||
return invalid('An account with that name already exists.');
|
||||
|
||||
Reference in New Issue
Block a user