Implement assignment import and clear of budget
This commit is contained in:
@ -91,6 +91,14 @@ func (q *Queries) GetCategories(ctx context.Context, budgetID uuid.UUID) ([]GetC
|
||||
|
||||
const getCategoriesWithBalance = `-- name: GetCategoriesWithBalance :many
|
||||
SELECT categories.id, categories.name, category_groups.name as group,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT SUM(a_hist.amount)
|
||||
FROM assignments a_hist
|
||||
WHERE categories.id = a_hist.category_id
|
||||
AND a_hist.date < $1
|
||||
)
|
||||
, 0)::decimal(12,2) as balance_assignments,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT SUM(t_hist.amount)
|
||||
@ -121,11 +129,12 @@ type GetCategoriesWithBalanceParams struct {
|
||||
}
|
||||
|
||||
type GetCategoriesWithBalanceRow struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Group string
|
||||
Balance Numeric
|
||||
Activity Numeric
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Group string
|
||||
BalanceAssignments Numeric
|
||||
Balance Numeric
|
||||
Activity Numeric
|
||||
}
|
||||
|
||||
func (q *Queries) GetCategoriesWithBalance(ctx context.Context, arg GetCategoriesWithBalanceParams) ([]GetCategoriesWithBalanceRow, error) {
|
||||
@ -141,6 +150,7 @@ func (q *Queries) GetCategoriesWithBalance(ctx context.Context, arg GetCategorie
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Group,
|
||||
&i.BalanceAssignments,
|
||||
&i.Balance,
|
||||
&i.Activity,
|
||||
); err != nil {
|
||||
|
Reference in New Issue
Block a user