Enhance account management: add functionality to hide accounts and retrieve hidden accounts; update API to handle account visibility settings.
This commit is contained in:
@ -11,6 +11,14 @@ export async function setAccountInTotal(accountId, total) {
|
||||
`
|
||||
}
|
||||
|
||||
export async function setAccountHide(accountId, hide) {
|
||||
return await db`
|
||||
update account
|
||||
set hide = ${hide}
|
||||
where id = ${accountId}
|
||||
`
|
||||
}
|
||||
|
||||
export async function deleteBudget(id) {
|
||||
return await db`
|
||||
UPDATE budget
|
||||
@ -148,9 +156,31 @@ export async function getAccounts(age) {
|
||||
org.name as org_name,
|
||||
balance,
|
||||
available_balance,
|
||||
balance_date
|
||||
balance_date,
|
||||
hide,
|
||||
in_total
|
||||
from account
|
||||
left join org on org.id = account.org_id
|
||||
where account.hide is false
|
||||
`
|
||||
// users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
|
||||
return accounts
|
||||
}
|
||||
|
||||
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
|
||||
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 }, ...]
|
||||
return accounts
|
||||
|
||||
Reference in New Issue
Block a user