Compare commits
4 Commits
2843d8a2f1
...
6fe30231d8
Author | SHA1 | Date | |
---|---|---|---|
6fe30231d8 | |||
49af9cd2ef | |||
ac27dc783e | |||
3c17d674f9 |
@ -23,7 +23,7 @@ DELETE FROM transactions
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: GetTransactionsForBudget :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount,
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id,
|
||||
accounts.name as account, COALESCE(payees.name, '') as payee, COALESCE(category_groups.name, '') as category_group, COALESCE(categories.name, '') as category
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id
|
||||
@ -35,7 +35,7 @@ ORDER BY transactions.date DESC
|
||||
LIMIT 200;
|
||||
|
||||
-- name: GetTransactionsForAccount :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount,
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id,
|
||||
accounts.name as account, COALESCE(payees.name, '') as payee, COALESCE(category_groups.name, '') as category_group, COALESCE(categories.name, '') as category
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id
|
||||
|
@ -1,6 +1,5 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions ADD COLUMN
|
||||
group_id uuid NULL;
|
||||
ALTER TABLE transactions ADD COLUMN group_id uuid NULL;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions DROP COLUMN group_id;
|
@ -132,7 +132,7 @@ func (q *Queries) GetTransactionsByMonthAndCategory(ctx context.Context, budgetI
|
||||
}
|
||||
|
||||
const getTransactionsForAccount = `-- name: GetTransactionsForAccount :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount,
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id,
|
||||
accounts.name as account, COALESCE(payees.name, '') as payee, COALESCE(category_groups.name, '') as category_group, COALESCE(categories.name, '') as category
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id
|
||||
@ -149,6 +149,7 @@ type GetTransactionsForAccountRow struct {
|
||||
Date time.Time
|
||||
Memo string
|
||||
Amount Numeric
|
||||
GroupID uuid.NullUUID
|
||||
Account string
|
||||
Payee string
|
||||
CategoryGroup string
|
||||
@ -169,6 +170,7 @@ func (q *Queries) GetTransactionsForAccount(ctx context.Context, accountID uuid.
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
&i.Amount,
|
||||
&i.GroupID,
|
||||
&i.Account,
|
||||
&i.Payee,
|
||||
&i.CategoryGroup,
|
||||
@ -188,7 +190,7 @@ func (q *Queries) GetTransactionsForAccount(ctx context.Context, accountID uuid.
|
||||
}
|
||||
|
||||
const getTransactionsForBudget = `-- name: GetTransactionsForBudget :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount,
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id,
|
||||
accounts.name as account, COALESCE(payees.name, '') as payee, COALESCE(category_groups.name, '') as category_group, COALESCE(categories.name, '') as category
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id
|
||||
@ -205,6 +207,7 @@ type GetTransactionsForBudgetRow struct {
|
||||
Date time.Time
|
||||
Memo string
|
||||
Amount Numeric
|
||||
GroupID uuid.NullUUID
|
||||
Account string
|
||||
Payee string
|
||||
CategoryGroup string
|
||||
@ -225,6 +228,7 @@ func (q *Queries) GetTransactionsForBudget(ctx context.Context, budgetID uuid.UU
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
&i.Amount,
|
||||
&i.GroupID,
|
||||
&i.Account,
|
||||
&i.Payee,
|
||||
&i.CategoryGroup,
|
||||
|
@ -212,11 +212,11 @@ func (ynab *YNABImport) ImportTransactions(r io.Reader) error {
|
||||
|
||||
_, err = ynab.queries.CreateTransaction(ynab.Context, transfer.CreateTransactionParams)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not save transaction %v: %w", transaction, err)
|
||||
return fmt.Errorf("could not save transaction %v: %w", transfer.CreateTransactionParams, err)
|
||||
}
|
||||
_, err = ynab.queries.CreateTransaction(ynab.Context, openTransfer.CreateTransactionParams)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not save transaction %v: %w", transaction, err)
|
||||
return fmt.Errorf("could not save transaction %v: %w", openTransfer.CreateTransactionParams, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -243,7 +243,12 @@ func (ynab *YNABImport) ImportTransactions(r io.Reader) error {
|
||||
}
|
||||
|
||||
for _, openTransfer := range openTransfers {
|
||||
fmt.Printf("Found transfer from %s to %s on %s over %f\n", openTransfer.FromAccount, openTransfer.ToAccount, openTransfer.Date, openTransfer.Amount.GetFloat64())
|
||||
fmt.Printf("Saving unmatched transfer from %s to %s on %s over %f as regular transaction\n", openTransfer.FromAccount, openTransfer.ToAccount, openTransfer.Date, openTransfer.Amount.GetFloat64())
|
||||
_, err = ynab.queries.CreateTransaction(ynab.Context, openTransfer.CreateTransactionParams)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not save transaction %v: %w", openTransfer.CreateTransactionParams, err)
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Printf("Imported %d transactions\n", count)
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
{{.CategoryGroup}} : {{.Category}}
|
||||
{{end}}
|
||||
</td>
|
||||
<td>
|
||||
{{if .GroupID.Valid}}☀{{end}}
|
||||
</td>
|
||||
<td>
|
||||
<a href="/budget/{{$.Budget.ID}}/transaction/{{.ID}}">{{.Memo}}</a>
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user