Implement transfer creation
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2022-02-23 22:53:04 +00:00
parent 696fbee7cc
commit 5ccec61465
4 changed files with 65 additions and 30 deletions

View File

@ -130,7 +130,7 @@ func (q *Queries) GetAccountsWithBalance(ctx context.Context, budgetID uuid.UUID
}
const searchAccounts = `-- name: SearchAccounts :many
SELECT accounts.id, accounts.budget_id, accounts.name FROM accounts
SELECT accounts.id, accounts.budget_id, accounts.name, true as is_account FROM accounts
WHERE accounts.budget_id = $1
AND accounts.name LIKE $2
ORDER BY accounts.name
@ -142,9 +142,10 @@ type SearchAccountsParams struct {
}
type SearchAccountsRow struct {
ID uuid.UUID
BudgetID uuid.UUID
Name string
ID uuid.UUID
BudgetID uuid.UUID
Name string
IsAccount bool
}
func (q *Queries) SearchAccounts(ctx context.Context, arg SearchAccountsParams) ([]SearchAccountsRow, error) {
@ -156,7 +157,12 @@ func (q *Queries) SearchAccounts(ctx context.Context, arg SearchAccountsParams)
var items []SearchAccountsRow
for rows.Next() {
var i SearchAccountsRow
if err := rows.Scan(&i.ID, &i.BudgetID, &i.Name); err != nil {
if err := rows.Scan(
&i.ID,
&i.BudgetID,
&i.Name,
&i.IsAccount,
); err != nil {
return nil, err
}
items = append(items, i)

View File

@ -83,6 +83,10 @@ func (n Numeric) Sub(other Numeric) Numeric {
panic("Cannot subtract with different exponents")
}
func (n Numeric) Neg() Numeric {
return Numeric{pgtype.Numeric{Exp: n.Exp, Int: big.NewInt(-1 * n.Int.Int64()), Status: n.Status}}
}
func (n Numeric) Add(other Numeric) Numeric {
left := n
right := other

View File

@ -22,7 +22,7 @@ GROUP BY accounts.id, accounts.name
ORDER BY accounts.name;
-- name: SearchAccounts :many
SELECT accounts.id, accounts.budget_id, accounts.name FROM accounts
SELECT accounts.id, accounts.budget_id, accounts.name, true as is_account FROM accounts
WHERE accounts.budget_id = @budget_id
AND accounts.name LIKE @search
ORDER BY accounts.name;