Include all accounts
Before this change, accounts without transactions in the specified timespan had not been included
This commit is contained in:
parent
951e827d20
commit
332f587bcf
@ -87,9 +87,8 @@ func (q *Queries) GetAccounts(ctx context.Context, budgetID uuid.UUID) ([]Accoun
|
||||
const getAccountsWithBalance = `-- name: GetAccountsWithBalance :many
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, SUM(transactions.amount)::decimal(12,2) as balance
|
||||
FROM accounts
|
||||
LEFT JOIN transactions ON transactions.account_id = accounts.id
|
||||
LEFT JOIN transactions ON transactions.account_id = accounts.id AND transactions.date < NOW()
|
||||
WHERE accounts.budget_id = $1
|
||||
AND transactions.date < NOW()
|
||||
GROUP BY accounts.id, accounts.name
|
||||
ORDER BY accounts.name
|
||||
`
|
||||
|
@ -16,8 +16,7 @@ ORDER BY accounts.name;
|
||||
-- name: GetAccountsWithBalance :many
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, SUM(transactions.amount)::decimal(12,2) as balance
|
||||
FROM accounts
|
||||
LEFT JOIN transactions ON transactions.account_id = accounts.id
|
||||
LEFT JOIN transactions ON transactions.account_id = accounts.id AND transactions.date < NOW()
|
||||
WHERE accounts.budget_id = $1
|
||||
AND transactions.date < NOW()
|
||||
GROUP BY accounts.id, accounts.name
|
||||
ORDER BY accounts.name;
|
Loading…
x
Reference in New Issue
Block a user