Add account management features and integrate Tailwind CSS typography
- Implement setAccountInTotal and deleteBudget functions in db.js - Update budget handling in the budget server API - Add DELETE endpoint for budget removal - Enhance account page with delete functionality and confirmation modal - Include @tailwindcss/typography in package.json and app.css
This commit is contained in:
@ -3,13 +3,30 @@ import postgres from 'postgres'
|
||||
|
||||
const db = postgres({ host:'192.168.1.126', username:'budget', password:'budget', database:'budget'}) // will use psql environment variables
|
||||
|
||||
export async function setAccountInTotal(accountId, total) {
|
||||
return await db`
|
||||
update account
|
||||
set in_total = ${total}
|
||||
where id = ${accountId}
|
||||
`
|
||||
}
|
||||
|
||||
export async function deleteBudget(id) {
|
||||
return await db`
|
||||
UPDATE budget
|
||||
SET delete = true
|
||||
WHERE id = ${id}
|
||||
`
|
||||
}
|
||||
|
||||
export async function createBudgetTable() {
|
||||
return await db`
|
||||
create table if not exists budget (
|
||||
id serial primary key,
|
||||
name text not null,
|
||||
amount numeric(10,2) not null,
|
||||
notes text
|
||||
notes text,
|
||||
delete boolean default false
|
||||
)
|
||||
`
|
||||
}
|
||||
@ -112,7 +129,8 @@ export async function getBudgets() {
|
||||
budget.name as name,
|
||||
budget.amount as amount,
|
||||
budget.notes as notes
|
||||
from budget
|
||||
from budget
|
||||
WHERE budget.delete is false
|
||||
`
|
||||
if (!budgets) {
|
||||
await createBudgetTable();
|
||||
@ -230,15 +248,15 @@ export async function updateAccounts(data) {
|
||||
}
|
||||
console.log(`Preparing to upsert transaction: ${txn.id} with data:`, txn);
|
||||
await db`
|
||||
insert into transaction (id, account_id, posted, amount, description, pending, extra_id)
|
||||
insert into transaction (id, account_id, posted, amount, description, pending, transacted_at)
|
||||
values (
|
||||
${txn.id},
|
||||
${account.id},
|
||||
${txn.posted},
|
||||
${txn.amount ?? null},
|
||||
${txn.description ?? null},
|
||||
${txn.pending},
|
||||
${extraId}
|
||||
${txn.pending ?? false},
|
||||
${txn.transacted_at ?? 0}
|
||||
)
|
||||
on conflict (id) do update set
|
||||
account_id = excluded.account_id,
|
||||
@ -246,7 +264,7 @@ export async function updateAccounts(data) {
|
||||
amount = excluded.amount,
|
||||
description = excluded.description,
|
||||
pending = excluded.pending,
|
||||
extra_id = excluded.extra_id
|
||||
transacted_at = excluded.transacted_at
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user