diff --git a/.air.toml b/.air.toml
deleted file mode 100644
index 477b5f6d14d55df9fcc39a654d710b19cf3be5a0..0000000000000000000000000000000000000000
--- a/.air.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-root = "."
-testdata_dir = "testdata"
-tmp_dir = "tmp"
-
-[build]
- bin = "./mint"
- cmd = "go build"
- delay = 1000
- #exclude_file = ["internal/html/tailwind.go"]
- exclude_regex = ["_test.go"]
- exclude_unchanged = true
- include_ext = ["go", "html", "sql"]
- pre_cmd = ["go generate ./..."]
-
-[misc]
- clean_on_exit = true
-
-[proxy]
- app_port = 8080
- enabled = true
- proxy_port = 8081
-
-[screen]
- clear_on_rebuild = true
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 3d3f43b3532d18176467ad1970c71e686436c130..0000000000000000000000000000000000000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/mint*
diff --git a/database/models.go b/database/models.go
index 8d0ddd72f0d35180623d1f79c44f6a187b7d2746..2d7fc91cf703bf14521cf673885bd117ea53e670 100644
--- a/database/models.go
+++ b/database/models.go
@@ -14,6 +14,4 @@ Title string
Amount int64
Date time.Time
Recurrance string
- Week int64
- IsIncome bool
}
diff --git a/database/sqlc/migrations/001_schema.up.sql b/database/sqlc/migrations/001_schema.up.sql
index e10f67049ff0fd5f336379efdbc4d7cafc96552c..9adffc94e5619c9e81bbc1b0ba56d014e58774c5 100644
--- a/database/sqlc/migrations/001_schema.up.sql
+++ b/database/sqlc/migrations/001_schema.up.sql
@@ -3,7 +3,5 @@ id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
amount INTEGER NOT NULL,
date DATE NOT NULL,
- recurrance TEXT NOT NULL,
- week INTEGER NOT NULL,
- is_income BOOLEAN NOT NULL DEFAULT FALSE
+ recurrance TEXT NOT NULL
);
diff --git a/database/sqlc/queries/transactions.sql b/database/sqlc/queries/transactions.sql
index f3bd56e9690f2397b052c6ff36694f17e119bece..7f96a96debdb5d2b23ebf9d9b958668087119c10 100644
--- a/database/sqlc/queries/transactions.sql
+++ b/database/sqlc/queries/transactions.sql
@@ -4,19 +4,19 @@ WHERE id = ? LIMIT 1;
-- name: ListTransactions :many
SELECT * FROM transactions
-WHERE date BETWEEN ? AND ?;
+WHERE date > ? AND date < ?;
-- name: CreateTransaction :one
INSERT INTO transactions (
- title, amount, date, recurrance, week, is_income
+ title, amount, date, recurrance
) VALUES (
- ?, ?, ?, ?, ?, ?
+ ?, ?, ?, ?
)
RETURNING *;
-- name: UpdateTransaction :one
UPDATE transactions
-SET title = ?, amount = ?, date = ?, recurrance = ?, week = ?, is_income = ?
+SET title = ?, amount = ?, date = ?, recurrance = ?
WHERE id = ?
RETURNING *;
diff --git a/database/sqlc/sqlc.go b/database/sqlc/sqlc.go
index fe7be91944ef0ae946fc3d555db8c4406d3acc95..453ecc0c0ae67684749184d979cc8b9b93aaf567 100644
--- a/database/sqlc/sqlc.go
+++ b/database/sqlc/sqlc.go
@@ -1,4 +1,4 @@
-//go:generate go tool sqlc generate
+//go:generate sqlc generate
package sqlc
import (
diff --git a/database/transactions.sql.go b/database/transactions.sql.go
index f1aeea36704370894710e2216dcdf246b32b1442..3db2b494275d52bc29f333ac66ab726c11b2d175 100644
--- a/database/transactions.sql.go
+++ b/database/transactions.sql.go
@@ -12,11 +12,11 @@ )
const createTransaction = `-- name: CreateTransaction :one
INSERT INTO transactions (
- title, amount, date, recurrance, week, is_income
+ title, amount, date, recurrance
) VALUES (
- ?, ?, ?, ?, ?, ?
+ ?, ?, ?, ?
)
-RETURNING id, title, amount, date, recurrance, week, is_income
+RETURNING id, title, amount, date, recurrance
`
type CreateTransactionParams struct {
@@ -24,8 +24,6 @@ Title string
Amount int64
Date time.Time
Recurrance string
- Week int64
- IsIncome bool
}
func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) {
@@ -34,8 +32,6 @@ arg.Title,
arg.Amount,
arg.Date,
arg.Recurrance,
- arg.Week,
- arg.IsIncome,
)
var i Transaction
err := row.Scan(
@@ -44,8 +40,6 @@ &i.Title,
&i.Amount,
&i.Date,
&i.Recurrance,
- &i.Week,
- &i.IsIncome,
)
return i, err
}
@@ -61,7 +55,7 @@ return err
}
const getTransaction = `-- name: GetTransaction :one
-SELECT id, title, amount, date, recurrance, week, is_income from transactions
+SELECT id, title, amount, date, recurrance from transactions
WHERE id = ? LIMIT 1
`
@@ -74,24 +68,22 @@ &i.Title,
&i.Amount,
&i.Date,
&i.Recurrance,
- &i.Week,
- &i.IsIncome,
)
return i, err
}
const listTransactions = `-- name: ListTransactions :many
-SELECT id, title, amount, date, recurrance, week, is_income FROM transactions
-WHERE date BETWEEN ? AND ?
+SELECT id, title, amount, date, recurrance FROM transactions
+WHERE date > ? AND date < ?
`
type ListTransactionsParams struct {
- FromDate time.Time
- ToDate time.Time
+ Date time.Time
+ Date_2 time.Time
}
func (q *Queries) ListTransactions(ctx context.Context, arg ListTransactionsParams) ([]Transaction, error) {
- rows, err := q.db.QueryContext(ctx, listTransactions, arg.FromDate, arg.ToDate)
+ rows, err := q.db.QueryContext(ctx, listTransactions, arg.Date, arg.Date_2)
if err != nil {
return nil, err
}
@@ -105,8 +97,6 @@ &i.Title,
&i.Amount,
&i.Date,
&i.Recurrance,
- &i.Week,
- &i.IsIncome,
); err != nil {
return nil, err
}
@@ -123,9 +113,9 @@ }
const updateTransaction = `-- name: UpdateTransaction :one
UPDATE transactions
-SET title = ?, amount = ?, date = ?, recurrance = ?, week = ?, is_income = ?
+SET title = ?, amount = ?, date = ?, recurrance = ?
WHERE id = ?
-RETURNING id, title, amount, date, recurrance, week, is_income
+RETURNING id, title, amount, date, recurrance
`
type UpdateTransactionParams struct {
@@ -133,8 +123,6 @@ Title string
Amount int64
Date time.Time
Recurrance string
- Week int64
- IsIncome bool
ID int64
}
@@ -144,8 +132,6 @@ arg.Title,
arg.Amount,
arg.Date,
arg.Recurrance,
- arg.Week,
- arg.IsIncome,
arg.ID,
)
var i Transaction
@@ -155,8 +141,6 @@ &i.Title,
&i.Amount,
&i.Date,
&i.Recurrance,
- &i.Week,
- &i.IsIncome,
)
return i, err
}
diff --git a/import.go b/import.go
deleted file mode 100644
index 3a933349e80af98913e54b09fd752cb81028ba26..0000000000000000000000000000000000000000
--- a/import.go
+++ /dev/null
@@ -1,69 +0,0 @@
-//go:build import
-
-package main
-
-import (
- "context"
- "database/sql"
- "encoding/json"
- "errors"
- "flag"
- "fmt"
- "os"
- "time"
-
- "github.com/golang-migrate/migrate/v4"
- "go.jolheiser.com/mint/database"
- "go.jolheiser.com/mint/database/sqlc/migrations"
-)
-
-type budget struct {
- Title string
- Amount float64
- Date time.Time
-}
-
-func main() {
- b := flag.String("budget", "budget.json", "Path to existing budget")
- d := flag.String("database", "mint.sqlite3", "Path to database file")
- flag.Parse()
-
- data, err := os.ReadFile(*b)
- if err != nil {
- panic(err)
- }
-
- dsn := fmt.Sprintf("file:%s", *d)
- sdb, err := sql.Open("sqlite", dsn)
- if err != nil {
- panic(err)
- }
-
- migrator, err := migrations.New(sdb)
- if err != nil {
- panic(err)
- }
-
- if err := migrator.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) {
- panic(err)
- }
-
- db := database.New(sdb)
-
- var transactions []budget
- if err := json.Unmarshal(data, &transactions); err != nil {
- panic(err)
- }
-
- for _, t := range transactions {
- if _, err := db.CreateTransaction(context.Background(), database.CreateTransactionParams{
- Title: t.Title,
- Amount: int64(t.Amount * 100),
- Date: t.Date,
- Recurrance: "month",
- }); err != nil {
- panic(err)
- }
- }
- fmt.Println("Import complete")
-}
diff --git a/index.html b/index.html
index a759bf1a1bc64da41fb7dd82270f9e03c98554b9..f5d49a66afd414539f1b220cbb6f2d4cb8d2ae31 100644
--- a/index.html
+++ b/index.html
@@ -9,6 +9,7 @@