Implement assignment import and clear of budget
This commit is contained in:
@ -48,6 +48,21 @@ func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionPa
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteAllTransactions = `-- name: DeleteAllTransactions :execrows
|
||||
DELETE FROM transactions
|
||||
USING accounts
|
||||
WHERE accounts.budget_id = $1
|
||||
AND accounts.id = transactions.account_id
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAllTransactions(ctx context.Context, budgetID uuid.UUID) (int64, error) {
|
||||
result, err := q.db.ExecContext(ctx, deleteAllTransactions, budgetID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected()
|
||||
}
|
||||
|
||||
const getTransactionsForAccount = `-- name: GetTransactionsForAccount :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount,
|
||||
accounts.name as account, COALESCE(payees.name, '') as payee, COALESCE(category_groups.name, '') as category_group, COALESCE(categories.name, '') as category
|
||||
|
Reference in New Issue
Block a user