added the analysis stuff. Still needs a lot of work but it will do for now
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// sqlc v1.31.1
|
||||
// source: expenses.sql
|
||||
|
||||
package pgsqlc
|
||||
@@ -84,6 +84,59 @@ func (q *Queries) GetExpense(ctx context.Context, expid int32) (GetExpenseRow, e
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getExpenseSum = `-- name: GetExpenseSum :one
|
||||
SELECT "ExpID", "Description", "Value", "StoreID", "CategoryID", "OwnerUserID", "TypeID", "ExpDate", "CreationDate", "PaidOff", "SharesEven", qr, "ExpShareID", "ExpID", "UserID", "Share", "Calculated" from "expenses"
|
||||
JOIN "expensesShares" ON "expenses"."ExpID" = "expensesShares"."ExpID"
|
||||
WHERE
|
||||
"expenses"."ExpID" = 673 AND
|
||||
"expensesShares"."UserID" = 1
|
||||
`
|
||||
|
||||
type GetExpenseSumRow struct {
|
||||
ExpID int32
|
||||
Description string
|
||||
Value pgtype.Numeric
|
||||
StoreID int32
|
||||
CategoryID int32
|
||||
OwnerUserID int32
|
||||
TypeID int32
|
||||
ExpDate pgtype.Timestamp
|
||||
CreationDate pgtype.Timestamp
|
||||
PaidOff pgtype.Bool
|
||||
SharesEven pgtype.Bool
|
||||
Qr string
|
||||
ExpShareID int32
|
||||
ExpID_2 int32
|
||||
UserID int32
|
||||
Share pgtype.Numeric
|
||||
Calculated pgtype.Numeric
|
||||
}
|
||||
|
||||
func (q *Queries) GetExpenseSum(ctx context.Context) (GetExpenseSumRow, error) {
|
||||
row := q.db.QueryRow(ctx, getExpenseSum)
|
||||
var i GetExpenseSumRow
|
||||
err := row.Scan(
|
||||
&i.ExpID,
|
||||
&i.Description,
|
||||
&i.Value,
|
||||
&i.StoreID,
|
||||
&i.CategoryID,
|
||||
&i.OwnerUserID,
|
||||
&i.TypeID,
|
||||
&i.ExpDate,
|
||||
&i.CreationDate,
|
||||
&i.PaidOff,
|
||||
&i.SharesEven,
|
||||
&i.Qr,
|
||||
&i.ExpShareID,
|
||||
&i.ExpID_2,
|
||||
&i.UserID,
|
||||
&i.Share,
|
||||
&i.Calculated,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getExpenses = `-- name: GetExpenses :many
|
||||
SELECT
|
||||
expenses."ExpID", expenses."Description", expenses."Value", expenses."StoreID", expenses."CategoryID", expenses."OwnerUserID", expenses."TypeID", expenses."ExpDate", expenses."CreationDate", expenses."PaidOff", expenses."SharesEven", expenses.qr,
|
||||
@@ -182,6 +235,45 @@ func (q *Queries) GetExpenses(ctx context.Context, arg GetExpensesParams) ([]Get
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getMonthlyTotalPaid = `-- name: GetMonthlyTotalPaid :many
|
||||
SELECT
|
||||
EXTRACT(MONTH FROM e."ExpDate") AS month,
|
||||
SUM(ep."Payed") AS monthly_total_paid
|
||||
FROM "expensesPayments" ep
|
||||
JOIN
|
||||
expenses e ON ep."ExpID" = e."ExpID"
|
||||
WHERE
|
||||
ep."UserID" = 1
|
||||
AND e."TypeID" = 0
|
||||
GROUP BY EXTRACT(MONTH FROM e."ExpDate")
|
||||
ORDER BY month
|
||||
`
|
||||
|
||||
type GetMonthlyTotalPaidRow struct {
|
||||
Month pgtype.Numeric
|
||||
MonthlyTotalPaid int64
|
||||
}
|
||||
|
||||
func (q *Queries) GetMonthlyTotalPaid(ctx context.Context) ([]GetMonthlyTotalPaidRow, error) {
|
||||
rows, err := q.db.Query(ctx, getMonthlyTotalPaid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetMonthlyTotalPaidRow
|
||||
for rows.Next() {
|
||||
var i GetMonthlyTotalPaidRow
|
||||
if err := rows.Scan(&i.Month, &i.MonthlyTotalPaid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertExpense = `-- name: InsertExpense :one
|
||||
INSERT INTO expenses(
|
||||
"Description",
|
||||
|
||||
Reference in New Issue
Block a user