Add getAccount function and update account data retrieval in the account page

This commit is contained in:
2025-07-08 21:54:20 -04:00
parent 592d21592b
commit 7cc8500fc7
3 changed files with 33 additions and 20 deletions

View File

@ -166,20 +166,39 @@ export async function getDeletedBudgets() {
return budgets
}
export async function getAccount(id) {
const account = await db`
select
account.id as id,
account.name as name,
account.balance as balance,
account.available_balance as available_balance,
account.balance_date as balance_date,
account.in_total as in_total,
account.hide as hide,
org.id as org_id,
org.name as org_name,
org.domain as org_domain,
org.sfin_url as org_sfin_url,
org.url as org_url
from account
left join org on account.org_id = org.id
where account.id = ${id}
`
if (!account || account.length === 0) {
return null
}
return account[0];
}
export async function getAccounts(age) {
const accounts = await db`
select
account.id as id,
account.name as name,
org.name as org_name,
balance,
available_balance,
balance_date,
hide,
in_total
balance
from account
left join org on org.id = account.org_id
where account.hide is false
where hide is false
`
// users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
return accounts
@ -189,15 +208,8 @@ export async function getHiddenAccounts(age) {
const accounts = await db`
select
account.id as id,
account.name as name,
org.name as org_name,
balance,
available_balance,
balance_date,
hide,
in_total
account.name as name
from account
left join org on org.id = account.org_id
where account.hide is true
`
// users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]