Compare commits
179 Commits
Author | SHA1 | Date | |
---|---|---|---|
45af54d995 | |||
a241298170 | |||
9248c12aab | |||
8817e665e9 | |||
0b36048f47 | |||
0c2438373d | |||
2f636b5f9c | |||
4ef0b759ef | |||
08fbacc7e6 | |||
1c003486ca | |||
71be1ac49f | |||
d258ab63e4 | |||
9da4a6f03e | |||
1a11555075 | |||
b573553424 | |||
dd0f620b7a | |||
42b732eedc | |||
f437491823 | |||
dc15ae307b | |||
f8a8a6fc0c | |||
a031dd5bb1 | |||
d3ca3c87bf | |||
77c1a6dd18 | |||
a7e1826f52 | |||
94b5c4bbd3 | |||
fdb64b2000 | |||
2ca3328f0f | |||
bd026732c8 | |||
6032f6f526 | |||
e1c6bd22d5 | |||
91ed57f83d | |||
0817f18e33 | |||
704a520993 | |||
a48509e041 | |||
b812b19b34 | |||
0667e5a779 | |||
f47ede2060 | |||
91ac05b575 | |||
c30b33a070 | |||
4fa227c452 | |||
cfb1dbe276 | |||
8f99499c2f | |||
d22816dfd1 | |||
75a1839456 | |||
9fd70cd773 | |||
3b465f17cf | |||
f56d095016 | |||
741589dc71 | |||
44254ed4d0 | |||
777520e9df | |||
07c0c56d11 | |||
43a4647d74 | |||
c595f016b8 | |||
6702a775fb | |||
e4df2f0de5 | |||
ff06693f60 | |||
5c5429ab05 | |||
65424a2587 | |||
4563fcbbaf | |||
df7b691bdd | |||
f5274f69fc | |||
c50fc63303 | |||
88e1dbdfde | |||
0e84cdfa5f | |||
d29405bef3 | |||
46e665efc5 | |||
f3eb19ef91 | |||
2ca05b5d48 | |||
ed2eb53f93 | |||
8bf4fcfd42 | |||
38222c0777 | |||
f43feb66be | |||
49be1d5be6 | |||
8ec69e4b8f | |||
6b3026dc8e | |||
9b5119d3dd | |||
08f48a63ad | |||
c4fc80e47d | |||
23bd12147c | |||
3ca7bfeade | |||
249aa534c8 | |||
76ee88a1c6 | |||
bb664494f6 | |||
4f681d6d89 | |||
11df0fbff1 | |||
a2280e50ec | |||
ed321d3895 | |||
8fe91293e1 | |||
35690681cf | |||
54e591bc5e | |||
01c407d4f1 | |||
cef62574bb | |||
ae529665a3 | |||
2eba947d9d | |||
4d70f50683 | |||
9b67e700be | |||
cce9f29f17 | |||
eb2b31e622 | |||
967f1c71e5 | |||
585951d5e2 | |||
e7af03b702 | |||
a1ec7e9997 | |||
880ed731f8 | |||
a46ddded67 | |||
56485b8deb | |||
f67f6ff0d8 | |||
150a7d562b | |||
49d96be1e3 | |||
8df7968175 | |||
bd99f58ab4 | |||
9471c5b63b | |||
60d6967728 | |||
1913d9eaf0 | |||
8954cffb7a | |||
95eb302d26 | |||
93679c2932 | |||
cb8ce79107 | |||
80c0f0a231 | |||
d73eeb1b40 | |||
ce466e0031 | |||
684efffbdf | |||
cf39db52fb | |||
f0993fd9c3 | |||
5f6bea4ee2 | |||
4332a1537b | |||
2feefea737 | |||
2d9c380cf4 | |||
4a66d9fdfc | |||
967ea784dc | |||
23b7a4dbdd | |||
4798cb95b0 | |||
8eabf3d1c8 | |||
f0084b683e | |||
84c95d0c4e | |||
6576c994c9 | |||
a552983ac4 | |||
f99efe0e8e | |||
e1b6056d77 | |||
94329ac331 | |||
bfa67578cf | |||
eae196aa69 | |||
d2dd7d5280 | |||
f707197f42 | |||
66322ebd86 | |||
3ea90a5ebe | |||
d717ef1b4d | |||
61a534610f | |||
d8d713f841 | |||
7ac06012ec | |||
9af412a8bd | |||
3b61028576 | |||
87b78e7b67 | |||
6a71d9643c | |||
450324d29e | |||
6f4e286b7a | |||
324e13f5c5 | |||
0201b368d4 | |||
984a2aa296 | |||
d1a0296a58 | |||
d9efa9f4a1 | |||
b176ce26ba | |||
97de326527 | |||
a62ab543b0 | |||
244333adbc | |||
67ef4745a0 | |||
3856e8a8a5 | |||
db96fddde2 | |||
ecb801b2f2 | |||
fd6b77f154 | |||
442e87234c | |||
caf39fe5ea | |||
0dde94f855 | |||
34bbdf48b7 | |||
1e495a5e47 | |||
fc29b1409d | |||
8ecfd6b87a | |||
d89e702669 | |||
3795150508 | |||
67c013799d |
18
.drone.yml
18
.drone.yml
@ -4,6 +4,11 @@ type: docker
|
||||
name: budgeteer
|
||||
|
||||
steps:
|
||||
- name: submodules
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git submodule update --recursive --init
|
||||
|
||||
- name: Taskfile.dev PR
|
||||
image: hub.javil.eu/budgeteer:dev
|
||||
commands:
|
||||
@ -18,9 +23,10 @@ steps:
|
||||
commands:
|
||||
- task ci
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
@ -57,5 +63,13 @@ steps:
|
||||
event:
|
||||
- tag
|
||||
|
||||
services:
|
||||
- name: db
|
||||
image: postgres:alpine
|
||||
environment:
|
||||
POSTGRES_USER: budgeteer
|
||||
POSTGRES_PASSWORD: budgeteer
|
||||
POSTGRES_DB: budgeteer_test
|
||||
|
||||
image_pull_secrets:
|
||||
- hub.javil.eu
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "testdata"]
|
||||
path = testdata
|
||||
url = https://git.javil.eu/jacob1123/budgeteer-testdata.git
|
@ -14,6 +14,7 @@ linters:
|
||||
- gci # not working, shows errors on freshly formatted file
|
||||
- varnamelen
|
||||
- lll
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
exclude-functions:
|
||||
@ -25,3 +26,18 @@ linters-settings:
|
||||
varnamelen:
|
||||
ignore-decls:
|
||||
- c *gin.Context
|
||||
wrapcheck:
|
||||
ignoreSigs:
|
||||
- .JSON(
|
||||
- .Redirect(
|
||||
- .String(
|
||||
- .Errorf(
|
||||
- errors.New(
|
||||
- errors.Unwrap(
|
||||
- .Wrap(
|
||||
- .Wrapf(
|
||||
- .WithMessage(
|
||||
- .WithMessagef(
|
||||
- .WithStack(
|
||||
ignorePackageGlobs:
|
||||
- git.javil.eu/jacob1123/budgeteer/postgres
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -9,5 +9,7 @@
|
||||
},
|
||||
"gopls": {
|
||||
"formatting.gofumpt": true,
|
||||
}
|
||||
},
|
||||
"editor.detectIndentation": false,
|
||||
"editor.tabSize": 2
|
||||
}
|
26
README.md
26
README.md
@ -1,20 +1,18 @@
|
||||
# Budgeteer
|
||||
|
||||
Budgeting Web-Application
|
||||
Budgeting Web-Application written in Go and inspired by [YNAB](https://youneedabudget.com).
|
||||
|
||||
## Data structure
|
||||
## Getting started
|
||||
|
||||
1 User
|
||||
N Budgets
|
||||
AccountID[]
|
||||
CategoryID[]
|
||||
PayeeID[]
|
||||
The fastest way to get up and running quickly, is using docker-compose. Just download the [docker-compose.yml](https://git.javil.eu/jacob1123/budgeteer/src/branch/master/docker/docker-compose.yml) to some empty directory and run `docker-compose up -d`. This starts budgeteer, a postgres database and an adminer instance. The latter is optional and can be removed from the docker-compose.yml.
|
||||
|
||||
N Accounts
|
||||
TransactionID[]
|
||||
N Categories
|
||||
AssignmentID[]
|
||||
N Payees
|
||||
## Known issues
|
||||
|
||||
N Transactions
|
||||
N Assignments
|
||||
Currently the application is usable when importing from YNAB via their CSV export. All balances should match the balances from YNAB. There are even unit-tests that confirm that using my personal budget.
|
||||
|
||||
For people wishing to start fresh in Budgeteer, there currently are some blockers though:
|
||||
- The ability to create new accounts and categories is missing (#59)
|
||||
|
||||
## Contributing
|
||||
|
||||
If you're willing to help, please check the issues for [help-wanted labels](https://git.javil.eu/jacob1123/budgeteer/issues?labels=4). Just using Budgeteer and reporting any issues is although very helpful.
|
142
Taskfile.yml
142
Taskfile.yml
@ -5,30 +5,31 @@ vars:
|
||||
|
||||
tasks:
|
||||
default:
|
||||
desc: Build budgeteer in production mode
|
||||
deps: [frontend, go-mod, go-sqlc]
|
||||
cmds:
|
||||
- task: build-prod
|
||||
- task: backend
|
||||
|
||||
sqlc:
|
||||
desc: sqlc code generation
|
||||
sources:
|
||||
- ./sqlc.yaml
|
||||
- ./postgres/schema/*
|
||||
- ./postgres/queries/*
|
||||
generates:
|
||||
- ./postgres/*.sql.go
|
||||
run:
|
||||
desc: Start budgeteer
|
||||
deps: [backend, go-mod, go-sqlc]
|
||||
cmds:
|
||||
- sqlc generate
|
||||
- ./build/budgeteer{{exeExt}}
|
||||
|
||||
gomod:
|
||||
desc: Go modules
|
||||
sources:
|
||||
- ./go.mod
|
||||
- ./go.sum
|
||||
method: checksum
|
||||
dev:
|
||||
desc: Build budgeteer in dev mode (without frontend)
|
||||
deps: [go-mod, go-sqlc]
|
||||
cmds:
|
||||
- go mod download
|
||||
- task: backend
|
||||
|
||||
build:
|
||||
ci:
|
||||
desc: Run CI build
|
||||
deps: [default, static]
|
||||
|
||||
static:
|
||||
deps: [go-lint, go-vet, go-fmt, js-tsc, js-lint, cover]
|
||||
|
||||
backend:
|
||||
desc: Build budgeteer
|
||||
sources:
|
||||
- ./go.mod
|
||||
@ -43,70 +44,99 @@ tasks:
|
||||
cmds:
|
||||
- go build -o ./build/budgeteer{{exeExt}} ./cmd/budgeteer
|
||||
|
||||
build-dev:
|
||||
desc: Build budgeteer in dev mode
|
||||
deps: [gomod, sqlc]
|
||||
go-vet:
|
||||
cmds:
|
||||
- go vet
|
||||
- go fmt
|
||||
- golangci-lint run
|
||||
- task: build
|
||||
|
||||
build-prod:
|
||||
desc: Build budgeteer in prod mode
|
||||
deps: [gomod, sqlc, frontend]
|
||||
go-fmt:
|
||||
cmds:
|
||||
- go vet
|
||||
- go fmt
|
||||
- golangci-lint run
|
||||
- task: build
|
||||
|
||||
ci:
|
||||
desc: Run CI build
|
||||
go-lint:
|
||||
cmds:
|
||||
- task: build-prod
|
||||
- go test ./...
|
||||
- golangci-lint run
|
||||
|
||||
go-sqlc:
|
||||
desc: sqlc code generation
|
||||
sources:
|
||||
- ./sqlc.yaml
|
||||
- ./postgres/schema/*
|
||||
- ./postgres/queries/*
|
||||
generates:
|
||||
- ./postgres/*.sql.go
|
||||
cmds:
|
||||
- sqlc generate
|
||||
|
||||
go-mod:
|
||||
desc: Go modules
|
||||
sources:
|
||||
- ./go.mod
|
||||
- ./go.sum
|
||||
method: checksum
|
||||
cmds:
|
||||
- go mod download
|
||||
|
||||
cover:
|
||||
desc: Run test and analyze coverage
|
||||
cmds:
|
||||
- go test ./... -coverprofile=coverage.out -covermode=atomic
|
||||
- go tool cover -html=coverage.out -o=coverage.html
|
||||
|
||||
frontend:
|
||||
desc: Build vue frontend
|
||||
dir: web
|
||||
deps: [js-build]
|
||||
sources:
|
||||
- web/src/**/*
|
||||
generates:
|
||||
- web/dist/**/*
|
||||
|
||||
frontend-dev:
|
||||
desc: Run dev-server for frontend
|
||||
dir: web
|
||||
cmds:
|
||||
- yarn run dev
|
||||
|
||||
js-build:
|
||||
dir: web
|
||||
deps: [js-mod]
|
||||
cmds:
|
||||
- yarn build
|
||||
|
||||
js-mod:
|
||||
run: once
|
||||
sources:
|
||||
- web/src/package.json
|
||||
- web/src/yarn.lock
|
||||
generates:
|
||||
- web/node_modules/**/*
|
||||
dir: web
|
||||
cmds:
|
||||
- yarn
|
||||
- yarn build
|
||||
|
||||
js-tsc:
|
||||
dir: web
|
||||
deps: [js-mod]
|
||||
cmds:
|
||||
- yarn run vue-tsc --noEmit
|
||||
|
||||
docker:
|
||||
desc: Build budgeeter:latest
|
||||
deps: [build-prod]
|
||||
sources:
|
||||
- ./build/budgeteer{{exeExt}}
|
||||
- ./build/Dockerfile
|
||||
js-lint:
|
||||
dir: web
|
||||
deps: [js-mod]
|
||||
cmds:
|
||||
- docker build -t {{.IMAGE_NAME}}:latest ./build
|
||||
- docker push {{.IMAGE_NAME}}:latest
|
||||
- yarn run eslint "./src/**"
|
||||
|
||||
dev-docker:
|
||||
desc: Build budgeeter:dev
|
||||
sources:
|
||||
- ./docker/Dockerfile
|
||||
- ./docker/build.sh
|
||||
- ./docker/Dockerfile.dev
|
||||
- ./web/package.json
|
||||
- ./web/yarn.lock
|
||||
cmds:
|
||||
- docker build -t {{.IMAGE_NAME}}:dev . -f docker/Dockerfile.dev
|
||||
- docker push {{.IMAGE_NAME}}:dev
|
||||
|
||||
run:
|
||||
desc: Start budgeteer
|
||||
deps: [build-dev]
|
||||
run-dev:
|
||||
desc: Run dev environment in docker
|
||||
deps: [dev-docker]
|
||||
cmds:
|
||||
- ./build/budgeteer{{exeExt}}
|
||||
|
||||
rundocker:
|
||||
desc: Start docker-compose
|
||||
deps: [docker]
|
||||
cmds:
|
||||
- docker-compose up -d
|
||||
- docker-compose -f docker/docker-compose.dev.yml -p budgeteer up -d
|
12
bass.build
Normal file
12
bass.build
Normal file
@ -0,0 +1,12 @@
|
||||
(def go
|
||||
(from (linux/alpine)
|
||||
($ apk add go)))
|
||||
|
||||
(-> ($ go mod download)
|
||||
(with-image go)
|
||||
(with-mount *dir*/go.mod ./go.mod)
|
||||
(with-mount *dir*/go.sum ./go.sum))
|
||||
|
||||
(def go-mods
|
||||
(from go
|
||||
($ go mod download)))
|
@ -17,22 +17,22 @@ import (
|
||||
func main() {
|
||||
cfg, err := config.LoadConfig()
|
||||
if err != nil {
|
||||
log.Fatalf("Could not load config: %v", err)
|
||||
log.Fatalf("load config: %v", err)
|
||||
}
|
||||
|
||||
queries, err := postgres.Connect("pgx", cfg.DatabaseConnection)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed connecting to DB: %v", err)
|
||||
log.Fatalf("connect to database: %v", err)
|
||||
}
|
||||
|
||||
static, err := fs.Sub(web.Static, "dist")
|
||||
if err != nil {
|
||||
panic("couldn't open static files")
|
||||
panic("open static files")
|
||||
}
|
||||
|
||||
tokenVerifier, err := jwt.NewTokenVerifier(cfg.SessionSecret)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("couldn't create token verifier: %w", err))
|
||||
panic(fmt.Errorf("create token verifier: %w", err))
|
||||
}
|
||||
|
||||
handler := &server.Handler{
|
||||
|
@ -5,13 +5,11 @@ RUN go install github.com/go-task/task/v3/cmd/task@latest
|
||||
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
||||
FROM alpine
|
||||
RUN apk --no-cache add go nodejs yarn bash curl git git-perl tmux
|
||||
ADD docker/dev.sh /
|
||||
RUN yarn global add @vue/cli
|
||||
RUN apk --no-cache add go nodejs yarn bash curl git git-perl
|
||||
ENV PATH="/root/.yarn/bin/:${PATH}"
|
||||
WORKDIR /src/web
|
||||
ADD web/package.json web/yarn.lock /src/web/
|
||||
RUN yarn
|
||||
WORKDIR /src
|
||||
VOLUME /go
|
||||
VOLUME /.cache
|
||||
COPY --from=godeps /root/go/bin/task /root/go/bin/sqlc /root/go/bin/golangci-lint /usr/local/bin/
|
||||
CMD /dev.sh
|
||||
|
@ -1,26 +1,31 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
app:
|
||||
backend:
|
||||
image: hub.javil.eu/budgeteer:dev
|
||||
container_name: budgeteer
|
||||
stdin_open: true # docker run -i
|
||||
tty: true # docker run -t
|
||||
command: task -w run
|
||||
ports:
|
||||
- 1323:1323
|
||||
- 3000:3000
|
||||
user: '1000'
|
||||
volumes:
|
||||
- ~/budgeteer:/src
|
||||
- ~/.gitconfig:/.gitconfig
|
||||
- ~/.go:/go
|
||||
- ~/.cache:/.cache
|
||||
- go-cache:/go
|
||||
- yarn-cache:/.cache
|
||||
environment:
|
||||
BUDGETEER_DB: postgres://budgeteer:budgeteer@db:5432/budgeteer
|
||||
BUDGETEER_SESSION_SECRET: random string for JWT authorization
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
frontend:
|
||||
image: hub.javil.eu/budgeteer:dev
|
||||
command: task frontend-dev
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- ~/budgeteer:/src
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
db:
|
||||
image: postgres:14
|
||||
ports:
|
||||
@ -41,3 +46,5 @@ services:
|
||||
|
||||
volumes:
|
||||
db:
|
||||
go-cache:
|
||||
yarn-cache:
|
||||
|
34
go.mod
34
go.mod
@ -4,21 +4,28 @@ go 1.17
|
||||
|
||||
require (
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/gin-gonic/gin v1.7.4
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/jackc/pgx/v4 v4.13.0
|
||||
github.com/pressly/goose/v3 v3.3.1
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
|
||||
)
|
||||
|
||||
require github.com/DATA-DOG/go-txdb v0.1.5
|
||||
require (
|
||||
github.com/DATA-DOG/go-txdb v0.1.5
|
||||
github.com/labstack/echo/v4 v4.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/labstack/gommon v0.3.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.11 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.13.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.4.1 // indirect
|
||||
github.com/golang/protobuf v1.5.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.10.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
@ -26,16 +33,9 @@ require (
|
||||
github.com/jackc/pgproto3/v2 v2.1.1 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgtype v1.8.1 // direct
|
||||
github.com/json-iterator/go v1.1.9 // indirect
|
||||
github.com/leodido/go-urn v1.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/ugorji/go/codec v1.1.7 // indirect
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
)
|
||||
|
65
go.sum
65
go.sum
@ -56,23 +56,11 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
|
||||
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
@ -83,13 +71,14 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
@ -97,7 +86,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
@ -105,9 +93,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
@ -168,8 +154,6 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@ -178,14 +162,14 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/labstack/echo/v4 v4.8.0 h1:wdc6yKVaHxkNOEdz4cRZs1pQkwSXPiRjq69yWP4QQS8=
|
||||
github.com/labstack/echo/v4 v4.8.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
|
||||
github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o=
|
||||
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||
github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
@ -198,10 +182,13 @@ github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
|
||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
@ -211,10 +198,6 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
@ -283,11 +266,11 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
@ -322,6 +305,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@ -343,6 +327,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -376,17 +361,23 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b h1:1VkfZQv42XQlA/jchYumAnv1UPo6RgF9rJFkTgZIxO4=
|
||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@ -406,7 +397,6 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8T
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
@ -419,11 +409,9 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
@ -431,11 +419,10 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
@ -1,11 +1,13 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: accounts.sql
|
||||
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"database/sql"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||
"github.com/google/uuid"
|
||||
@ -15,7 +17,7 @@ const createAccount = `-- name: CreateAccount :one
|
||||
INSERT INTO accounts
|
||||
(name, budget_id)
|
||||
VALUES ($1, $2)
|
||||
RETURNING id, budget_id, name, on_budget, is_open
|
||||
RETURNING id, budget_id, name, on_budget, is_open, last_reconciled
|
||||
`
|
||||
|
||||
type CreateAccountParams struct {
|
||||
@ -32,12 +34,13 @@ func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (A
|
||||
&i.Name,
|
||||
&i.OnBudget,
|
||||
&i.IsOpen,
|
||||
&i.LastReconciled,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAccount = `-- name: GetAccount :one
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, accounts.on_budget, accounts.is_open FROM accounts
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, accounts.on_budget, accounts.is_open, accounts.last_reconciled FROM accounts
|
||||
WHERE accounts.id = $1
|
||||
`
|
||||
|
||||
@ -50,12 +53,13 @@ func (q *Queries) GetAccount(ctx context.Context, id uuid.UUID) (Account, error)
|
||||
&i.Name,
|
||||
&i.OnBudget,
|
||||
&i.IsOpen,
|
||||
&i.LastReconciled,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAccounts = `-- name: GetAccounts :many
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, accounts.on_budget, accounts.is_open FROM accounts
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, accounts.on_budget, accounts.is_open, accounts.last_reconciled FROM accounts
|
||||
WHERE accounts.budget_id = $1
|
||||
AND accounts.is_open = TRUE
|
||||
ORDER BY accounts.name
|
||||
@ -76,6 +80,7 @@ func (q *Queries) GetAccounts(ctx context.Context, budgetID uuid.UUID) ([]Accoun
|
||||
&i.Name,
|
||||
&i.OnBudget,
|
||||
&i.IsOpen,
|
||||
&i.LastReconciled,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -91,8 +96,7 @@ func (q *Queries) GetAccounts(ctx context.Context, budgetID uuid.UUID) ([]Accoun
|
||||
}
|
||||
|
||||
const getAccountsWithBalance = `-- name: GetAccountsWithBalance :many
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, accounts.is_open,
|
||||
(SELECT MAX(transactions.date) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.status = 'Reconciled')::date as last_reconciled,
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, accounts.is_open, accounts.last_reconciled,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW())::decimal(12,2) as working_balance,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW() AND transactions.status IN ('Cleared', 'Reconciled'))::decimal(12,2) as cleared_balance,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW() AND transactions.status = 'Reconciled')::decimal(12,2) as reconciled_balance
|
||||
@ -107,7 +111,7 @@ type GetAccountsWithBalanceRow struct {
|
||||
Name string
|
||||
OnBudget bool
|
||||
IsOpen bool
|
||||
LastReconciled time.Time
|
||||
LastReconciled sql.NullTime
|
||||
WorkingBalance numeric.Numeric
|
||||
ClearedBalance numeric.Numeric
|
||||
ReconciledBalance numeric.Numeric
|
||||
@ -149,7 +153,7 @@ const searchAccounts = `-- name: SearchAccounts :many
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, 'account' as type FROM accounts
|
||||
WHERE accounts.budget_id = $1
|
||||
AND accounts.is_open = TRUE
|
||||
AND accounts.name LIKE $2
|
||||
AND accounts.name ILIKE $2
|
||||
ORDER BY accounts.name
|
||||
`
|
||||
|
||||
@ -193,13 +197,24 @@ func (q *Queries) SearchAccounts(ctx context.Context, arg SearchAccountsParams)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setLastReconciled = `-- name: SetLastReconciled :exec
|
||||
UPDATE accounts
|
||||
SET last_reconciled = NOW()
|
||||
WHERE accounts.id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) SetLastReconciled(ctx context.Context, id uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, setLastReconciled, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateAccount = `-- name: UpdateAccount :one
|
||||
UPDATE accounts
|
||||
SET name = $1,
|
||||
on_budget = $2,
|
||||
is_open = $3
|
||||
WHERE accounts.id = $4
|
||||
RETURNING id, budget_id, name, on_budget, is_open
|
||||
RETURNING id, budget_id, name, on_budget, is_open, last_reconciled
|
||||
`
|
||||
|
||||
type UpdateAccountParams struct {
|
||||
@ -223,6 +238,7 @@ func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (A
|
||||
&i.Name,
|
||||
&i.OnBudget,
|
||||
&i.IsOpen,
|
||||
&i.LastReconciled,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: assignments.sql
|
||||
|
||||
package postgres
|
||||
@ -17,7 +19,7 @@ INSERT INTO assignments (
|
||||
) VALUES (
|
||||
$1, $2, $3
|
||||
)
|
||||
RETURNING id, category_id, date, memo, amount
|
||||
RETURNING category_id, date, memo, amount
|
||||
`
|
||||
|
||||
type CreateAssignmentParams struct {
|
||||
@ -30,7 +32,6 @@ func (q *Queries) CreateAssignment(ctx context.Context, arg CreateAssignmentPara
|
||||
row := q.db.QueryRowContext(ctx, createAssignment, arg.Date, arg.Amount, arg.CategoryID)
|
||||
var i Assignment
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CategoryID,
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
@ -130,3 +131,41 @@ func (q *Queries) GetAssignmentsByMonthAndCategory(ctx context.Context, budgetID
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateAssignment = `-- name: UpdateAssignment :exec
|
||||
INSERT INTO assignments (category_id, date, amount)
|
||||
VALUES($1, $2, $3)
|
||||
ON CONFLICT (category_id, date)
|
||||
DO
|
||||
UPDATE SET amount = $3
|
||||
`
|
||||
|
||||
type UpdateAssignmentParams struct {
|
||||
CategoryID uuid.UUID
|
||||
Date time.Time
|
||||
Amount numeric.Numeric
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateAssignment(ctx context.Context, arg UpdateAssignmentParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateAssignment, arg.CategoryID, arg.Date, arg.Amount)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateAssignmentWithDifference = `-- name: UpdateAssignmentWithDifference :exec
|
||||
INSERT INTO assignments (category_id, date, amount)
|
||||
VALUES($1, $2, $3)
|
||||
ON CONFLICT (category_id, date)
|
||||
DO
|
||||
UPDATE SET amount = assignments.amount + $3
|
||||
`
|
||||
|
||||
type UpdateAssignmentWithDifferenceParams struct {
|
||||
CategoryID uuid.UUID
|
||||
Date time.Time
|
||||
Amount numeric.Numeric
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateAssignmentWithDifference(ctx context.Context, arg UpdateAssignmentWithDifferenceParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateAssignmentWithDifference, arg.CategoryID, arg.Date, arg.Amount)
|
||||
return err
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: budgets.sql
|
||||
|
||||
package postgres
|
||||
|
@ -59,5 +59,6 @@ func (s *Database) NewBudget(context context.Context, name string, userID uuid.U
|
||||
return nil, fmt.Errorf("commit: %w", err)
|
||||
}
|
||||
|
||||
budget.IncomeCategoryID = cat.ID
|
||||
return &budget, nil
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: categories.sql
|
||||
|
||||
package postgres
|
||||
@ -122,7 +124,8 @@ SELECT CONCAT(category_groups.name, ' : ', categories.name) as name, categories.
|
||||
FROM categories
|
||||
INNER JOIN category_groups ON categories.category_group_id = category_groups.id
|
||||
WHERE category_groups.budget_id = $1
|
||||
AND categories.name LIKE $2
|
||||
AND categories.name ILIKE $2
|
||||
AND category_groups.name != 'Hidden Categories'
|
||||
ORDER BY category_groups.name, categories.name
|
||||
`
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: cumultative-balances.sql
|
||||
|
||||
package postgres
|
||||
@ -13,21 +15,19 @@ import (
|
||||
|
||||
const getCumultativeBalances = `-- name: GetCumultativeBalances :many
|
||||
SELECT COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id),
|
||||
COALESCE(ass.amount, 0)::decimal(12,2) as assignments, SUM(ass.amount) OVER (PARTITION BY ass.category_id ORDER BY ass.date)::decimal(12,2) as assignments_cum,
|
||||
COALESCE(tra.amount, 0)::decimal(12,2) as transactions, SUM(tra.amount) OVER (PARTITION BY tra.category_id ORDER BY tra.date)::decimal(12,2) as transactions_cum
|
||||
COALESCE(ass.amount, 0)::decimal(12,2) as assignments,
|
||||
COALESCE(tra.amount, 0)::decimal(12,2) as transactions
|
||||
FROM assignments_by_month as ass
|
||||
FULL OUTER JOIN transactions_by_month as tra ON ass.date = tra.date AND ass.category_id = tra.category_id
|
||||
WHERE (ass.budget_id IS NULL OR ass.budget_id = $1) AND (tra.budget_id IS NULL OR tra.budget_id = $1)
|
||||
ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id)
|
||||
WHERE COALESCE(ass.budget_id, tra.budget_id) = $1
|
||||
ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.amount, tra.amount)
|
||||
`
|
||||
|
||||
type GetCumultativeBalancesRow struct {
|
||||
Date time.Time
|
||||
CategoryID uuid.UUID
|
||||
Assignments numeric.Numeric
|
||||
AssignmentsCum numeric.Numeric
|
||||
Transactions numeric.Numeric
|
||||
TransactionsCum numeric.Numeric
|
||||
}
|
||||
|
||||
func (q *Queries) GetCumultativeBalances(ctx context.Context, budgetID uuid.UUID) ([]GetCumultativeBalancesRow, error) {
|
||||
@ -43,9 +43,7 @@ func (q *Queries) GetCumultativeBalances(ctx context.Context, budgetID uuid.UUID
|
||||
&i.Date,
|
||||
&i.CategoryID,
|
||||
&i.Assignments,
|
||||
&i.AssignmentsCum,
|
||||
&i.Transactions,
|
||||
&i.TransactionsCum,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
|
||||
package postgres
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
|
||||
package postgres
|
||||
|
||||
@ -37,10 +39,10 @@ type Account struct {
|
||||
Name string
|
||||
OnBudget bool
|
||||
IsOpen bool
|
||||
LastReconciled sql.NullTime
|
||||
}
|
||||
|
||||
type Assignment struct {
|
||||
ID uuid.UUID
|
||||
CategoryID uuid.UUID
|
||||
Date time.Time
|
||||
Memo sql.NullString
|
||||
|
@ -25,6 +25,13 @@ func FromInt64WithExp(value int64, exp int32) Numeric {
|
||||
return Numeric{Numeric: pgtype.Numeric{Int: big.NewInt(value), Exp: exp, Status: pgtype.Present}}
|
||||
}
|
||||
|
||||
func (n *Numeric) SetZero() {
|
||||
n.Exp = 0
|
||||
n.Int = big.NewInt(0)
|
||||
n.Status = pgtype.Present
|
||||
n.NaN = false
|
||||
}
|
||||
|
||||
func (n Numeric) GetFloat64() float64 {
|
||||
if n.Status != pgtype.Present {
|
||||
return 0
|
||||
@ -53,6 +60,13 @@ func (n Numeric) IsZero() bool {
|
||||
return float == 0
|
||||
}
|
||||
|
||||
func (n *Numeric) MatchExpI(exp int32) {
|
||||
diffExp := n.Exp - exp
|
||||
factor := big.NewInt(0).Exp(big.NewInt(10), big.NewInt(int64(diffExp)), nil) //nolint:gomnd
|
||||
n.Exp = exp
|
||||
n.Int = big.NewInt(0).Mul(n.Int, factor)
|
||||
}
|
||||
|
||||
func (n Numeric) MatchExp(exp int32) Numeric {
|
||||
diffExp := n.Exp - exp
|
||||
factor := big.NewInt(0).Exp(big.NewInt(10), big.NewInt(int64(diffExp)), nil) //nolint:gomnd
|
||||
@ -64,6 +78,22 @@ func (n Numeric) MatchExp(exp int32) Numeric {
|
||||
}}
|
||||
}
|
||||
|
||||
func (n *Numeric) SubI(other Numeric) *Numeric {
|
||||
right := other
|
||||
if n.Exp < other.Exp {
|
||||
right = other.MatchExp(n.Exp)
|
||||
} else if n.Exp > other.Exp {
|
||||
n.MatchExpI(other.Exp)
|
||||
}
|
||||
|
||||
if n.Exp == right.Exp {
|
||||
n.Int = big.NewInt(0).Sub(n.Int, right.Int)
|
||||
return n
|
||||
}
|
||||
|
||||
panic("Cannot subtract with different exponents")
|
||||
}
|
||||
|
||||
func (n Numeric) Sub(other Numeric) Numeric {
|
||||
left := n
|
||||
right := other
|
||||
@ -106,6 +136,22 @@ func (n Numeric) Add(other Numeric) Numeric {
|
||||
panic("Cannot add with different exponents")
|
||||
}
|
||||
|
||||
func (n *Numeric) AddI(other Numeric) *Numeric {
|
||||
right := other
|
||||
if n.Exp < other.Exp {
|
||||
right = other.MatchExp(n.Exp)
|
||||
} else if n.Exp > other.Exp {
|
||||
n.MatchExpI(other.Exp)
|
||||
}
|
||||
|
||||
if n.Exp == right.Exp {
|
||||
n.Int = big.NewInt(0).Add(n.Int, right.Int)
|
||||
return n
|
||||
}
|
||||
|
||||
panic("Cannot add with different exponents")
|
||||
}
|
||||
|
||||
func (n Numeric) String() string {
|
||||
if n.Int == nil || n.Int.Int64() == 0 {
|
||||
return "0"
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: payees.sql
|
||||
|
||||
package postgres
|
||||
@ -60,7 +62,7 @@ func (q *Queries) GetPayees(ctx context.Context, budgetID uuid.UUID) ([]Payee, e
|
||||
const searchPayees = `-- name: SearchPayees :many
|
||||
SELECT payees.id, payees.budget_id, payees.name, 'payee' as type FROM payees
|
||||
WHERE payees.budget_id = $1
|
||||
AND payees.name LIKE $2
|
||||
AND payees.name ILIKE $2
|
||||
ORDER BY payees.name
|
||||
`
|
||||
|
||||
|
@ -15,8 +15,7 @@ AND accounts.is_open = TRUE
|
||||
ORDER BY accounts.name;
|
||||
|
||||
-- name: GetAccountsWithBalance :many
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, accounts.is_open,
|
||||
(SELECT MAX(transactions.date) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.status = 'Reconciled')::date as last_reconciled,
|
||||
SELECT accounts.id, accounts.name, accounts.on_budget, accounts.is_open, accounts.last_reconciled,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW())::decimal(12,2) as working_balance,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW() AND transactions.status IN ('Cleared', 'Reconciled'))::decimal(12,2) as cleared_balance,
|
||||
(SELECT SUM(transactions.amount) FROM transactions WHERE transactions.account_id = accounts.id AND transactions.date < NOW() AND transactions.status = 'Reconciled')::decimal(12,2) as reconciled_balance
|
||||
@ -29,7 +28,7 @@ ORDER BY accounts.name;
|
||||
SELECT accounts.id, accounts.budget_id, accounts.name, 'account' as type FROM accounts
|
||||
WHERE accounts.budget_id = @budget_id
|
||||
AND accounts.is_open = TRUE
|
||||
AND accounts.name LIKE @search
|
||||
AND accounts.name ILIKE @search
|
||||
ORDER BY accounts.name;
|
||||
|
||||
-- name: UpdateAccount :one
|
||||
@ -39,3 +38,8 @@ SET name = $1,
|
||||
is_open = $3
|
||||
WHERE accounts.id = $4
|
||||
RETURNING *;
|
||||
|
||||
-- name: SetLastReconciled :exec
|
||||
UPDATE accounts
|
||||
SET last_reconciled = NOW()
|
||||
WHERE accounts.id = $1;
|
@ -23,3 +23,17 @@ FROM assignments
|
||||
INNER JOIN categories ON categories.id = assignments.category_id
|
||||
INNER JOIN category_groups ON categories.category_group_id = category_groups.id
|
||||
WHERE category_groups.budget_id = @budget_id;
|
||||
|
||||
-- name: UpdateAssignment :exec
|
||||
INSERT INTO assignments (category_id, date, amount)
|
||||
VALUES($1, $2, $3)
|
||||
ON CONFLICT (category_id, date)
|
||||
DO
|
||||
UPDATE SET amount = $3;
|
||||
|
||||
-- name: UpdateAssignmentWithDifference :exec
|
||||
INSERT INTO assignments (category_id, date, amount)
|
||||
VALUES($1, $2, $3)
|
||||
ON CONFLICT (category_id, date)
|
||||
DO
|
||||
UPDATE SET amount = assignments.amount + $3;
|
@ -25,6 +25,7 @@ SELECT CONCAT(category_groups.name, ' : ', categories.name) as name, categories.
|
||||
FROM categories
|
||||
INNER JOIN category_groups ON categories.category_group_id = category_groups.id
|
||||
WHERE category_groups.budget_id = @budget_id
|
||||
AND categories.name LIKE @search
|
||||
AND categories.name ILIKE @search
|
||||
AND category_groups.name != 'Hidden Categories'
|
||||
ORDER BY category_groups.name, categories.name;
|
||||
--ORDER BY levenshtein(payees.name, $2);
|
@ -1,8 +1,8 @@
|
||||
-- name: GetCumultativeBalances :many
|
||||
SELECT COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id),
|
||||
COALESCE(ass.amount, 0)::decimal(12,2) as assignments, SUM(ass.amount) OVER (PARTITION BY ass.category_id ORDER BY ass.date)::decimal(12,2) as assignments_cum,
|
||||
COALESCE(tra.amount, 0)::decimal(12,2) as transactions, SUM(tra.amount) OVER (PARTITION BY tra.category_id ORDER BY tra.date)::decimal(12,2) as transactions_cum
|
||||
COALESCE(ass.amount, 0)::decimal(12,2) as assignments,
|
||||
COALESCE(tra.amount, 0)::decimal(12,2) as transactions
|
||||
FROM assignments_by_month as ass
|
||||
FULL OUTER JOIN transactions_by_month as tra ON ass.date = tra.date AND ass.category_id = tra.category_id
|
||||
WHERE (ass.budget_id IS NULL OR ass.budget_id = @budget_id) AND (tra.budget_id IS NULL OR tra.budget_id = @budget_id)
|
||||
ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id);
|
||||
WHERE COALESCE(ass.budget_id, tra.budget_id) = @budget_id
|
||||
ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.amount, tra.amount);
|
@ -12,6 +12,6 @@ ORDER BY name;
|
||||
-- name: SearchPayees :many
|
||||
SELECT payees.*, 'payee' as type FROM payees
|
||||
WHERE payees.budget_id = @budget_id
|
||||
AND payees.name LIKE @search
|
||||
AND payees.name ILIKE @search
|
||||
ORDER BY payees.name;
|
||||
--ORDER BY levenshtein(payees.name, $2);
|
@ -34,8 +34,7 @@ WHERE t.budget_id = $1;
|
||||
-- name: GetTransactionsForAccount :many
|
||||
SELECT t.*
|
||||
FROM display_transactions AS t
|
||||
WHERE t.account_id = $1
|
||||
LIMIT 200;
|
||||
WHERE t.account_id = $1;
|
||||
|
||||
-- name: DeleteAllTransactions :execrows
|
||||
DELETE FROM transactions
|
||||
@ -47,3 +46,28 @@ AND accounts.id = transactions.account_id;
|
||||
SELECT *
|
||||
FROM transactions_by_month
|
||||
WHERE transactions_by_month.budget_id = @budget_id;
|
||||
|
||||
-- name: GetProblematicTransactions :many
|
||||
SELECT transactions.*
|
||||
FROM display_transactions AS transactions
|
||||
LEFT JOIN accounts
|
||||
ON transactions.account_id = accounts.id
|
||||
LEFT JOIN transactions AS otherGroupTransaction
|
||||
ON transactions.group_id = otherGroupTransaction.group_id
|
||||
AND transactions.id != otherGroupTransaction.id
|
||||
AND transactions.account_id != otherGroupTransaction.account_id
|
||||
LEFT JOIn accounts AS otherGroupAccount
|
||||
ON otherGroupTransaction.account_id = otherGroupAccount.id
|
||||
WHERE transactions.category_id IS NULL
|
||||
AND accounts.on_budget
|
||||
AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget)
|
||||
AND accounts.budget_id = $1;
|
||||
|
||||
-- name: GetFilteredTransactions :many
|
||||
SELECT transactions.*
|
||||
FROM display_transactions AS transactions
|
||||
WHERE (NOT @filter_category::boolean OR transactions.category_id = @category_id)
|
||||
AND (NOT @filter_account::boolean OR transactions.account_id = @account_id)
|
||||
AND (NOT @filter_payee::boolean OR transactions.payee_id = @payee_id)
|
||||
AND transactions.date BETWEEN @from_date AND @to_date
|
||||
AND transactions.budget_id = @budget_id;
|
6
postgres/schema/0017_natural-key-assignments.sql
Normal file
6
postgres/schema/0017_natural-key-assignments.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE assignments DROP id;
|
||||
ALTER TABLE assignments ADD PRIMARY KEY (category_id, date);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE assignments ADD COLUMN id uuid DEFAULT uuid_generate_v4() PRIMARY KEY;
|
12
postgres/schema/0018_reconciled-on.sql
Normal file
12
postgres/schema/0018_reconciled-on.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE accounts ADD COLUMN last_reconciled date NULL;
|
||||
UPDATE accounts
|
||||
SET last_reconciled = (
|
||||
SELECT MAX(transactions.date)
|
||||
FROM transactions
|
||||
WHERE transactions.account_id = accounts.id
|
||||
AND transactions.status = 'Reconciled'
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE accounts DROP COLUMN last_reconciled;
|
@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
CREATE OR REPLACE VIEW transactions_by_month AS
|
||||
SELECT date_trunc('month', transactions.date)::date as date, transactions.category_id, accounts.budget_id, SUM(amount) as amount
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id AND accounts.on_budget
|
||||
GROUP BY date_trunc('month', transactions.date), transactions.category_id, accounts.budget_id;
|
||||
|
||||
-- +goose Down
|
||||
CREATE OR REPLACE VIEW transactions_by_month AS
|
||||
SELECT date_trunc('month', transactions.date)::date as date, transactions.category_id, accounts.budget_id, SUM(amount) as amount
|
||||
FROM transactions
|
||||
INNER JOIN accounts ON accounts.id = transactions.account_id
|
||||
GROUP BY date_trunc('month', transactions.date), transactions.category_id, accounts.budget_id;
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: transactions.sql
|
||||
|
||||
package postgres
|
||||
@ -115,6 +117,133 @@ func (q *Queries) GetAllTransactionsForBudget(ctx context.Context, budgetID uuid
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getFilteredTransactions = `-- name: GetFilteredTransactions :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id, transactions.status, transactions.account, transactions.payee_id, transactions.category_id, transactions.payee, transactions.category_group, transactions.category, transactions.transfer_account, transactions.budget_id, transactions.account_id
|
||||
FROM display_transactions AS transactions
|
||||
WHERE (NOT $1::boolean OR transactions.category_id = $2)
|
||||
AND (NOT $3::boolean OR transactions.account_id = $4)
|
||||
AND (NOT $5::boolean OR transactions.payee_id = $6)
|
||||
AND transactions.date BETWEEN $7 AND $8
|
||||
AND transactions.budget_id = $9
|
||||
`
|
||||
|
||||
type GetFilteredTransactionsParams struct {
|
||||
FilterCategory bool
|
||||
CategoryID uuid.NullUUID
|
||||
FilterAccount bool
|
||||
AccountID uuid.UUID
|
||||
FilterPayee bool
|
||||
PayeeID uuid.NullUUID
|
||||
FromDate time.Time
|
||||
ToDate time.Time
|
||||
BudgetID uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) GetFilteredTransactions(ctx context.Context, arg GetFilteredTransactionsParams) ([]DisplayTransaction, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getFilteredTransactions,
|
||||
arg.FilterCategory,
|
||||
arg.CategoryID,
|
||||
arg.FilterAccount,
|
||||
arg.AccountID,
|
||||
arg.FilterPayee,
|
||||
arg.PayeeID,
|
||||
arg.FromDate,
|
||||
arg.ToDate,
|
||||
arg.BudgetID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []DisplayTransaction
|
||||
for rows.Next() {
|
||||
var i DisplayTransaction
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
&i.Amount,
|
||||
&i.GroupID,
|
||||
&i.Status,
|
||||
&i.Account,
|
||||
&i.PayeeID,
|
||||
&i.CategoryID,
|
||||
&i.Payee,
|
||||
&i.CategoryGroup,
|
||||
&i.Category,
|
||||
&i.TransferAccount,
|
||||
&i.BudgetID,
|
||||
&i.AccountID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProblematicTransactions = `-- name: GetProblematicTransactions :many
|
||||
SELECT transactions.id, transactions.date, transactions.memo, transactions.amount, transactions.group_id, transactions.status, transactions.account, transactions.payee_id, transactions.category_id, transactions.payee, transactions.category_group, transactions.category, transactions.transfer_account, transactions.budget_id, transactions.account_id
|
||||
FROM display_transactions AS transactions
|
||||
LEFT JOIN accounts
|
||||
ON transactions.account_id = accounts.id
|
||||
LEFT JOIN transactions AS otherGroupTransaction
|
||||
ON transactions.group_id = otherGroupTransaction.group_id
|
||||
AND transactions.id != otherGroupTransaction.id
|
||||
AND transactions.account_id != otherGroupTransaction.account_id
|
||||
LEFT JOIn accounts AS otherGroupAccount
|
||||
ON otherGroupTransaction.account_id = otherGroupAccount.id
|
||||
WHERE transactions.category_id IS NULL
|
||||
AND accounts.on_budget
|
||||
AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget)
|
||||
AND accounts.budget_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProblematicTransactions(ctx context.Context, budgetID uuid.UUID) ([]DisplayTransaction, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProblematicTransactions, budgetID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []DisplayTransaction
|
||||
for rows.Next() {
|
||||
var i DisplayTransaction
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
&i.Amount,
|
||||
&i.GroupID,
|
||||
&i.Status,
|
||||
&i.Account,
|
||||
&i.PayeeID,
|
||||
&i.CategoryID,
|
||||
&i.Payee,
|
||||
&i.CategoryGroup,
|
||||
&i.Category,
|
||||
&i.TransferAccount,
|
||||
&i.BudgetID,
|
||||
&i.AccountID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTransaction = `-- name: GetTransaction :one
|
||||
SELECT id, date, memo, amount, group_id, status, account, payee_id, category_id, payee, category_group, category, transfer_account, budget_id, account_id FROM display_transactions
|
||||
WHERE id = $1
|
||||
@ -181,7 +310,6 @@ const getTransactionsForAccount = `-- name: GetTransactionsForAccount :many
|
||||
SELECT t.id, t.date, t.memo, t.amount, t.group_id, t.status, t.account, t.payee_id, t.category_id, t.payee, t.category_group, t.category, t.transfer_account, t.budget_id, t.account_id
|
||||
FROM display_transactions AS t
|
||||
WHERE t.account_id = $1
|
||||
LIMIT 200
|
||||
`
|
||||
|
||||
func (q *Queries) GetTransactionsForAccount(ctx context.Context, accountID uuid.UUID) ([]DisplayTransaction, error) {
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: user_budgets.sql
|
||||
|
||||
package postgres
|
||||
|
@ -1,4 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.13.0
|
||||
// source: users.sql
|
||||
|
||||
package postgres
|
||||
|
@ -91,12 +91,12 @@ func (ynab *YNABImport) ImportAssignments(context context.Context, r io.Reader)
|
||||
continue
|
||||
}
|
||||
|
||||
assignment := CreateAssignmentParams{
|
||||
assignment := UpdateAssignmentWithDifferenceParams{
|
||||
Date: date,
|
||||
CategoryID: category.UUID,
|
||||
Amount: amount,
|
||||
}
|
||||
_, err = ynab.queries.CreateAssignment(context, assignment)
|
||||
err = ynab.queries.UpdateAssignmentWithDifference(context, assignment)
|
||||
if err != nil {
|
||||
return fmt.Errorf("save assignment %v: %w", assignment, err)
|
||||
}
|
||||
@ -226,7 +226,8 @@ func (ynab *YNABImport) GetTransaction(context context.Context, record []string)
|
||||
}
|
||||
|
||||
func (ynab *YNABImport) ImportRegularTransaction(context context.Context, payeeName string,
|
||||
transaction CreateTransactionParams) error {
|
||||
transaction CreateTransactionParams,
|
||||
) error {
|
||||
payeeID, err := ynab.GetPayee(context, payeeName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get payee %s: %w", payeeName, err)
|
||||
@ -242,7 +243,8 @@ func (ynab *YNABImport) ImportRegularTransaction(context context.Context, payeeN
|
||||
|
||||
func (ynab *YNABImport) ImportTransferTransaction(context context.Context, payeeName string,
|
||||
transaction CreateTransactionParams, openTransfers *[]Transfer,
|
||||
account *Account, amount numeric.Numeric) error {
|
||||
account *Account, amount numeric.Numeric,
|
||||
) error {
|
||||
transferToAccountName := payeeName[11:]
|
||||
transferToAccount, err := ynab.GetAccount(context, transferToAccountName)
|
||||
if err != nil {
|
||||
|
@ -2,37 +2,102 @@ package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func (h *Handler) transactionsForAccount(c *gin.Context) {
|
||||
type FilterTransactionsRequest struct {
|
||||
CategoryID string `json:"categoryId"`
|
||||
PayeeID string `json:"payeeId"`
|
||||
AccountID string `json:"accountId"`
|
||||
FromDate time.Time `json:"fromDate"`
|
||||
ToDate time.Time `json:"toDate"`
|
||||
}
|
||||
|
||||
func (h *Handler) filteredTransactions(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
var request FilterTransactionsRequest
|
||||
err = c.Bind(&request)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
params := postgres.GetFilteredTransactionsParams{
|
||||
BudgetID: budgetUUID,
|
||||
FromDate: request.FromDate,
|
||||
ToDate: request.ToDate,
|
||||
}
|
||||
params.CategoryID, params.FilterCategory = parseEmptyUUID(request.CategoryID)
|
||||
accountID, filterAccount := parseEmptyUUID(request.AccountID)
|
||||
params.AccountID, params.FilterAccount = accountID.UUID, filterAccount
|
||||
params.PayeeID, params.FilterPayee = parseEmptyUUID(request.PayeeID)
|
||||
|
||||
transactions, err := h.Service.GetFilteredTransactions(c.Request().Context(), params)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, TransactionsResponse{nil, transactions})
|
||||
}
|
||||
|
||||
func parseEmptyUUID(value string) (uuid.NullUUID, bool) {
|
||||
if value == "" {
|
||||
return uuid.NullUUID{}, false
|
||||
}
|
||||
|
||||
val, err := uuid.Parse(value)
|
||||
if err != nil {
|
||||
return uuid.NullUUID{}, false
|
||||
}
|
||||
|
||||
return uuid.NullUUID{UUID: val, Valid: true}, true
|
||||
}
|
||||
|
||||
func (h *Handler) problematicTransactions(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
transactions, err := h.Service.GetProblematicTransactions(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, TransactionsResponse{nil, transactions})
|
||||
}
|
||||
|
||||
func (h *Handler) transactionsForAccount(c echo.Context) error {
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
account, err := h.Service.GetAccount(c.Request.Context(), accountUUID)
|
||||
account, err := h.Service.GetAccount(c.Request().Context(), accountUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
transactions, err := h.Service.GetTransactionsForAccount(c.Request.Context(), accountUUID)
|
||||
transactions, err := h.Service.GetTransactionsForAccount(c.Request().Context(), accountUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, TransactionsResponse{account, transactions})
|
||||
return c.JSON(http.StatusOK, TransactionsResponse{&account, transactions})
|
||||
}
|
||||
|
||||
type TransactionsResponse struct {
|
||||
Account postgres.Account
|
||||
Account *postgres.Account
|
||||
Transactions []postgres.DisplayTransaction
|
||||
}
|
||||
|
||||
@ -42,19 +107,17 @@ type EditAccountRequest struct {
|
||||
IsOpen bool `json:"isOpen"`
|
||||
}
|
||||
|
||||
func (h *Handler) editAccount(c *gin.Context) {
|
||||
func (h *Handler) editAccount(c echo.Context) error {
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
var request EditAccountRequest
|
||||
err = c.BindJSON(&request)
|
||||
err = c.Bind(&request)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
updateParams := postgres.UpdateAccountParams{
|
||||
@ -63,11 +126,10 @@ func (h *Handler) editAccount(c *gin.Context) {
|
||||
IsOpen: request.IsOpen,
|
||||
ID: accountUUID,
|
||||
}
|
||||
account, err := h.Service.UpdateAccount(c.Request.Context(), updateParams)
|
||||
account, err := h.Service.UpdateAccount(c.Request().Context(), updateParams)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
h.returnBudgetingData(c, account.BudgetID)
|
||||
return h.getBudget(c, account.BudgetID)
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@ -11,24 +11,19 @@ import (
|
||||
"git.javil.eu/jacob1123/budgeteer/bcrypt"
|
||||
"git.javil.eu/jacob1123/budgeteer/jwt"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
txdb "github.com/DATA-DOG/go-txdb"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func init() { //nolint:gochecknoinits
|
||||
txdb.Register("pgtx", "pgx", "postgres://budgeteer_test:budgeteer_test@localhost:5432/budgeteer_test")
|
||||
}
|
||||
|
||||
func TestRegisterUser(t *testing.T) { //nolint:funlen
|
||||
func TestRegisterUser(t *testing.T) {
|
||||
t.Parallel()
|
||||
database, err := postgres.Connect("pgtx", "example")
|
||||
database, err := postgres.Connect("pgtx", cfg.DatabaseConnection)
|
||||
if err != nil {
|
||||
fmt.Printf("could not connect to db: %s\n", err)
|
||||
t.Skip()
|
||||
t.Errorf("connect to DB: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
tokenVerifier, _ := jwt.NewTokenVerifier("this_is_my_demo_secret_for_unit_tests")
|
||||
tokenVerifier, _ := jwt.NewTokenVerifier(cfg.SessionSecret)
|
||||
h := Handler{
|
||||
Service: database,
|
||||
TokenVerifier: tokenVerifier,
|
||||
@ -36,21 +31,28 @@ func TestRegisterUser(t *testing.T) { //nolint:funlen
|
||||
}
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
context, engine := gin.CreateTestContext(recorder)
|
||||
engine := echo.New()
|
||||
h.LoadRoutes(engine)
|
||||
|
||||
t.Run("RegisterUser", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
context.Request, err = http.NewRequest(
|
||||
request, err := http.NewRequestWithContext(context.Background(),
|
||||
http.MethodPost,
|
||||
"/api/v1/user/register",
|
||||
strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
context := engine.NewContext(request, recorder)
|
||||
if err != nil {
|
||||
t.Errorf("error creating request: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
h.registerPost(context)
|
||||
err = h.registerPost(context)
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
t.Error("Error registering")
|
||||
return
|
||||
}
|
||||
|
||||
if recorder.Code != http.StatusOK {
|
||||
t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)
|
||||
@ -66,22 +68,4 @@ func TestRegisterUser(t *testing.T) { //nolint:funlen
|
||||
t.Error("Did not get a token")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("GetTransactions", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
context.Request, err = http.NewRequest(http.MethodGet, "/account/accountid/transactions", nil)
|
||||
if recorder.Code != http.StatusOK {
|
||||
t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)
|
||||
}
|
||||
|
||||
var response TransactionsResponse
|
||||
err = json.NewDecoder(recorder.Body).Decode(&response)
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
t.Error("Error retreiving list of transactions.")
|
||||
}
|
||||
if len(response.Transactions) == 0 {
|
||||
t.Error("Did not get any transactions.")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4,109 +4,66 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/pressly/goose/v3"
|
||||
)
|
||||
|
||||
func (h *Handler) clearDatabase(c *gin.Context) {
|
||||
func (h *Handler) clearDatabase(c echo.Context) error {
|
||||
if err := goose.Reset(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
if err := goose.Up(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
func (h *Handler) deleteBudget(c *gin.Context) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) deleteBudget(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
h.clearBudgetData(c, budgetUUID)
|
||||
|
||||
err = h.Service.DeleteBudget(c.Request.Context(), budgetUUID)
|
||||
err = h.clearBudgetData(c, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (h *Handler) clearBudgetData(c *gin.Context, budgetUUID uuid.UUID) {
|
||||
rows, err := h.Service.DeleteAllAssignments(c.Request.Context(), budgetUUID)
|
||||
err = h.Service.DeleteBudget(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) clearBudgetData(c echo.Context, budgetUUID uuid.UUID) error {
|
||||
rows, err := h.Service.DeleteAllAssignments(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Deleted %d assignments\n", rows)
|
||||
|
||||
rows, err = h.Service.DeleteAllTransactions(c.Request.Context(), budgetUUID)
|
||||
rows, err = h.Service.DeleteAllTransactions(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Deleted %d transactions\n", rows)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) clearBudget(c *gin.Context) {
|
||||
func (h *Handler) clearBudget(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
h.clearBudgetData(c, budgetUUID)
|
||||
}
|
||||
|
||||
func (h *Handler) cleanNegativeBudget(c *gin.Context) {
|
||||
/*budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/login")
|
||||
return
|
||||
}*/
|
||||
|
||||
/*min_date, err := h.Service.GetFirstActivity(c.Request.Context(), budgetUUID)
|
||||
date := getFirstOfMonthTime(min_date)
|
||||
for {
|
||||
nextDate := date.AddDate(0, 1, 0)
|
||||
params := postgres.GetCategoriesWithBalanceParams{
|
||||
BudgetID: budgetUUID,
|
||||
ToDate: nextDate,
|
||||
FromDate: date,
|
||||
}
|
||||
categories, err := h.Service.GetCategoriesWithBalance(c.Request.Context(), params)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, category := range categories {
|
||||
available := category.Available.GetFloat64()
|
||||
if available >= 0 {
|
||||
continue
|
||||
}
|
||||
var negativeAvailable postgres.Numeric
|
||||
negativeAvailable.Set(-available)
|
||||
createAssignment := postgres.CreateAssignmentParams{
|
||||
Date: nextDate.AddDate(0, 0, -1),
|
||||
Amount: negativeAvailable,
|
||||
CategoryID: category.ID,
|
||||
}
|
||||
h.Service.CreateAssignment(c.Request.Context(), createAssignment)
|
||||
}
|
||||
|
||||
if nextDate.Before(time.Now()) {
|
||||
date = nextDate
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}*/
|
||||
return h.clearBudgetData(c, budgetUUID)
|
||||
}
|
||||
|
@ -5,41 +5,58 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func (h *Handler) autocompleteCategories(c *gin.Context) {
|
||||
func (h *Handler) autocompleteAccounts(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
|
||||
}
|
||||
|
||||
query := c.Request.URL.Query().Get("s")
|
||||
query := c.Request().URL.Query().Get("s")
|
||||
searchParams := postgres.SearchAccountsParams{
|
||||
BudgetID: budgetUUID,
|
||||
Search: "%" + query + "%",
|
||||
}
|
||||
categories, err := h.Service.SearchAccounts(c.Request().Context(), searchParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, categories)
|
||||
}
|
||||
|
||||
func (h *Handler) autocompleteCategories(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
|
||||
}
|
||||
|
||||
query := c.Request().URL.Query().Get("s")
|
||||
searchParams := postgres.SearchCategoriesParams{
|
||||
BudgetID: budgetUUID,
|
||||
Search: "%" + query + "%",
|
||||
}
|
||||
categories, err := h.Service.SearchCategories(c.Request.Context(), searchParams)
|
||||
categories, err := h.Service.SearchCategories(c.Request().Context(), searchParams)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, categories)
|
||||
return c.JSON(http.StatusOK, categories)
|
||||
}
|
||||
|
||||
func (h *Handler) autocompletePayee(c *gin.Context) {
|
||||
func (h *Handler) autocompletePayee(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
|
||||
}
|
||||
|
||||
query := c.Request.URL.Query().Get("s")
|
||||
query := c.Request().URL.Query().Get("s")
|
||||
|
||||
transferPrefix := "Transfer"
|
||||
if strings.HasPrefix(query, transferPrefix) {
|
||||
@ -48,25 +65,23 @@ func (h *Handler) autocompletePayee(c *gin.Context) {
|
||||
Search: "%" + strings.Trim(query[len(transferPrefix):], " \t\n:") + "%",
|
||||
}
|
||||
|
||||
accounts, err := h.Service.SearchAccounts(c.Request.Context(), searchParams)
|
||||
accounts, err := h.Service.SearchAccounts(c.Request().Context(), searchParams)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, accounts)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, accounts)
|
||||
} else {
|
||||
searchParams := postgres.SearchPayeesParams{
|
||||
BudgetID: budgetUUID,
|
||||
Search: query + "%",
|
||||
}
|
||||
|
||||
payees, err := h.Service.SearchPayees(c.Request.Context(), searchParams)
|
||||
payees, err := h.Service.SearchPayees(c.Request().Context(), searchParams)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, payees)
|
||||
}
|
||||
return c.JSON(http.StatusOK, payees)
|
||||
}
|
||||
|
@ -3,31 +3,28 @@ package server
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type newBudgetInformation struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (h *Handler) newBudget(c *gin.Context) {
|
||||
func (h *Handler) newBudget(c echo.Context) error {
|
||||
var newBudget newBudgetInformation
|
||||
if err := c.BindJSON(&newBudget); err != nil {
|
||||
c.AbortWithError(http.StatusNotAcceptable, err)
|
||||
return
|
||||
if err := c.Bind(&newBudget); err != nil {
|
||||
return echo.NewHTTPError(http.StatusNotAcceptable, err)
|
||||
}
|
||||
|
||||
if newBudget.Name == "" {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budget name is required"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budget name is required")
|
||||
}
|
||||
|
||||
userID := MustGetToken(c).GetID()
|
||||
budget, err := h.Service.NewBudget(c.Request.Context(), newBudget.Name, userID)
|
||||
budget, err := h.Service.NewBudget(c.Request().Context(), newBudget.Name, userID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, budget)
|
||||
return c.JSON(http.StatusOK, budget)
|
||||
}
|
||||
|
@ -1,31 +1,18 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func getFirstOfMonth(year, month int, location *time.Location) time.Time {
|
||||
return time.Date(year, time.Month(month), 1, 0, 0, 0, 0, location)
|
||||
}
|
||||
|
||||
func getFirstOfMonthTime(date time.Time) time.Time {
|
||||
var monthM time.Month
|
||||
year, monthM, _ := date.Date()
|
||||
month := int(monthM)
|
||||
return getFirstOfMonth(year, month, date.Location())
|
||||
}
|
||||
|
||||
type CategoryWithBalance struct {
|
||||
*postgres.GetCategoriesRow
|
||||
Available numeric.Numeric
|
||||
AvailableLastMonth numeric.Numeric
|
||||
Activity numeric.Numeric
|
||||
Assigned numeric.Numeric
|
||||
@ -34,101 +21,79 @@ type CategoryWithBalance struct {
|
||||
func NewCategoryWithBalance(category *postgres.GetCategoriesRow) CategoryWithBalance {
|
||||
return CategoryWithBalance{
|
||||
GetCategoriesRow: category,
|
||||
Available: numeric.Zero(),
|
||||
AvailableLastMonth: numeric.Zero(),
|
||||
Activity: numeric.Zero(),
|
||||
Assigned: numeric.Zero(),
|
||||
}
|
||||
}
|
||||
|
||||
func getDate(c *gin.Context) (time.Time, error) {
|
||||
var year, month int
|
||||
yearString := c.Param("year")
|
||||
monthString := c.Param("month")
|
||||
if yearString == "" && monthString == "" {
|
||||
return getFirstOfMonthTime(time.Now()), nil
|
||||
}
|
||||
|
||||
year, err := strconv.Atoi(yearString)
|
||||
if err != nil {
|
||||
return time.Time{}, fmt.Errorf("parse year: %w", err)
|
||||
}
|
||||
|
||||
month, err = strconv.Atoi(monthString)
|
||||
if err != nil {
|
||||
return time.Time{}, fmt.Errorf("parse month: %w", err)
|
||||
}
|
||||
|
||||
return getFirstOfMonth(year, month, time.Now().Location()), nil
|
||||
}
|
||||
|
||||
func (h *Handler) budgetingForMonth(c *gin.Context) {
|
||||
func (h *Handler) budgetingForMonth(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
|
||||
}
|
||||
|
||||
budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
|
||||
budget, err := h.Service.GetBudget(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
firstOfMonth, err := getDate(c)
|
||||
month, err := getDate(c)
|
||||
if err != nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budgetUUID.String())
|
||||
return
|
||||
return c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String())
|
||||
}
|
||||
|
||||
categories, err := h.Service.GetCategories(c.Request.Context(), budgetUUID)
|
||||
data, err := h.getBudgetingViewForMonth(c.Request().Context(), budget, month)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
firstOfNextMonth := firstOfMonth.AddDate(0, 1, 0)
|
||||
cumultativeBalances, err := h.Service.GetCumultativeBalances(c.Request.Context(), budgetUUID)
|
||||
return c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
func (h *Handler) getBudgetingViewForMonth(ctx context.Context, budget postgres.Budget, month Month) (BudgetingForMonthResponse, error) {
|
||||
categories, err := h.Service.GetCategories(ctx, budget.ID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, ErrorResponse{fmt.Sprintf("error loading balances: %s", err)})
|
||||
return
|
||||
return BudgetingForMonthResponse{}, fmt.Errorf("error loading categories: %w", err)
|
||||
}
|
||||
|
||||
categoriesWithBalance, moneyUsed := h.calculateBalances(
|
||||
budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances)
|
||||
cumultativeBalances, err := h.Service.GetCumultativeBalances(ctx, budget.ID)
|
||||
if err != nil {
|
||||
return BudgetingForMonthResponse{}, fmt.Errorf("error loading balances: %w", err)
|
||||
}
|
||||
|
||||
availableBalance := h.getAvailableBalance(categories, budget, moneyUsed, cumultativeBalances, firstOfNextMonth)
|
||||
categoriesWithBalance, moneyUsed, overspentLastMonth := h.calculateBalances(budget, month, categories, cumultativeBalances)
|
||||
availableBalance := h.getAvailableBalance(budget, month, moneyUsed, cumultativeBalances)
|
||||
|
||||
data := struct {
|
||||
data := BudgetingForMonthResponse{categoriesWithBalance, availableBalance, overspentLastMonth}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
type BudgetingForMonthResponse struct {
|
||||
Categories []CategoryWithBalance
|
||||
AvailableBalance numeric.Numeric
|
||||
}{categoriesWithBalance, availableBalance}
|
||||
c.JSON(http.StatusOK, data)
|
||||
OverspentLastMonth numeric.Numeric
|
||||
}
|
||||
|
||||
func (*Handler) getAvailableBalance(categories []postgres.GetCategoriesRow, budget postgres.Budget,
|
||||
func (*Handler) getAvailableBalance(budget postgres.Budget, month Month,
|
||||
moneyUsed numeric.Numeric, cumultativeBalances []postgres.GetCumultativeBalancesRow,
|
||||
firstOfNextMonth time.Time) numeric.Numeric {
|
||||
availableBalance := numeric.Zero()
|
||||
for _, cat := range categories {
|
||||
if cat.ID != budget.IncomeCategoryID {
|
||||
continue
|
||||
}
|
||||
availableBalance = moneyUsed
|
||||
) numeric.Numeric {
|
||||
availableBalance := moneyUsed
|
||||
|
||||
for _, bal := range cumultativeBalances {
|
||||
if bal.CategoryID != cat.ID {
|
||||
if bal.CategoryID != budget.IncomeCategoryID {
|
||||
continue
|
||||
}
|
||||
|
||||
if !bal.Date.Before(firstOfNextMonth) {
|
||||
if month.InFuture(bal.Date) {
|
||||
continue
|
||||
}
|
||||
|
||||
availableBalance = availableBalance.Add(bal.Transactions)
|
||||
}
|
||||
availableBalance.AddI(bal.Transactions)
|
||||
availableBalance.AddI(bal.Assignments) // should be zero, but who knows
|
||||
}
|
||||
|
||||
return availableBalance
|
||||
}
|
||||
|
||||
@ -137,60 +102,50 @@ type BudgetingResponse struct {
|
||||
Budget postgres.Budget
|
||||
}
|
||||
|
||||
func (h *Handler) budgeting(c *gin.Context) {
|
||||
func (h *Handler) budget(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
|
||||
}
|
||||
|
||||
h.returnBudgetingData(c, budgetUUID)
|
||||
return h.getBudget(c, budgetUUID)
|
||||
}
|
||||
|
||||
func (h *Handler) returnBudgetingData(c *gin.Context, budgetUUID uuid.UUID) {
|
||||
budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
|
||||
func (h *Handler) getBudget(c echo.Context, budgetUUID uuid.UUID) error {
|
||||
budget, err := h.Service.GetBudget(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
accounts, err := h.Service.GetAccountsWithBalance(c.Request.Context(), budgetUUID)
|
||||
accounts, err := h.Service.GetAccountsWithBalance(c.Request().Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
data := BudgetingResponse{accounts, budget}
|
||||
|
||||
c.JSON(http.StatusOK, data)
|
||||
return c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
func (h *Handler) calculateBalances(budget postgres.Budget,
|
||||
firstOfNextMonth time.Time, firstOfMonth time.Time, categories []postgres.GetCategoriesRow,
|
||||
cumultativeBalances []postgres.GetCumultativeBalancesRow) ([]CategoryWithBalance, numeric.Numeric) {
|
||||
func (h *Handler) calculateBalances(budget postgres.Budget, month Month,
|
||||
categories []postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow,
|
||||
) ([]CategoryWithBalance, numeric.Numeric, numeric.Numeric) {
|
||||
categoriesWithBalance := []CategoryWithBalance{}
|
||||
|
||||
moneyUsed := numeric.Zero()
|
||||
overspentLastMonth := numeric.Zero()
|
||||
categories = append(categories, postgres.GetCategoriesRow{
|
||||
Group: "Income",
|
||||
Name: "No Category",
|
||||
ID: uuid.UUID{},
|
||||
})
|
||||
for i := range categories {
|
||||
cat := &categories[i]
|
||||
// do not show hidden categories
|
||||
categoryWithBalance := h.CalculateCategoryBalances(cat, cumultativeBalances,
|
||||
firstOfNextMonth, &moneyUsed, firstOfMonth, budget)
|
||||
|
||||
if cat.ID == budget.IncomeCategoryID {
|
||||
continue
|
||||
}
|
||||
|
||||
categoriesWithBalance = append(categoriesWithBalance, categoryWithBalance)
|
||||
}
|
||||
|
||||
return categoriesWithBalance, moneyUsed
|
||||
}
|
||||
|
||||
func (*Handler) CalculateCategoryBalances(cat *postgres.GetCategoriesRow,
|
||||
cumultativeBalances []postgres.GetCumultativeBalancesRow, firstOfNextMonth time.Time,
|
||||
moneyUsed *numeric.Numeric, firstOfMonth time.Time, budget postgres.Budget) CategoryWithBalance {
|
||||
categoryWithBalance := NewCategoryWithBalance(cat)
|
||||
for _, bal := range cumultativeBalances {
|
||||
if bal.CategoryID != cat.ID {
|
||||
@ -198,25 +153,30 @@ func (*Handler) CalculateCategoryBalances(cat *postgres.GetCategoriesRow,
|
||||
}
|
||||
|
||||
// skip everything in the future
|
||||
if !bal.Date.Before(firstOfNextMonth) {
|
||||
if month.InFuture(bal.Date) {
|
||||
continue
|
||||
}
|
||||
|
||||
*moneyUsed = moneyUsed.Sub(bal.Assignments)
|
||||
categoryWithBalance.Available = categoryWithBalance.Available.Add(bal.Assignments)
|
||||
categoryWithBalance.Available = categoryWithBalance.Available.Add(bal.Transactions)
|
||||
if !categoryWithBalance.Available.IsPositive() && bal.Date.Before(firstOfMonth) {
|
||||
*moneyUsed = moneyUsed.Add(categoryWithBalance.Available)
|
||||
categoryWithBalance.Available = numeric.Zero()
|
||||
}
|
||||
|
||||
if bal.Date.Before(firstOfMonth) {
|
||||
categoryWithBalance.AvailableLastMonth = categoryWithBalance.Available
|
||||
} else if bal.Date.Before(firstOfNextMonth) {
|
||||
moneyUsed.SubI(bal.Assignments)
|
||||
if month.InPresent(bal.Date) {
|
||||
categoryWithBalance.Activity = bal.Transactions
|
||||
categoryWithBalance.Assigned = bal.Assignments
|
||||
continue
|
||||
}
|
||||
|
||||
categoryWithBalance.AvailableLastMonth.AddI(bal.Assignments)
|
||||
categoryWithBalance.AvailableLastMonth.AddI(bal.Transactions)
|
||||
if !categoryWithBalance.AvailableLastMonth.IsPositive() {
|
||||
moneyUsed.AddI(categoryWithBalance.AvailableLastMonth)
|
||||
if month.Previous().InPresent(bal.Date) {
|
||||
overspentLastMonth.AddI(categoryWithBalance.AvailableLastMonth)
|
||||
}
|
||||
categoryWithBalance.AvailableLastMonth = numeric.Zero()
|
||||
}
|
||||
}
|
||||
|
||||
return categoryWithBalance
|
||||
categoriesWithBalance = append(categoriesWithBalance, categoryWithBalance)
|
||||
}
|
||||
|
||||
return categoriesWithBalance, moneyUsed, overspentLastMonth
|
||||
}
|
||||
|
52
server/category.go
Normal file
52
server/category.go
Normal file
@ -0,0 +1,52 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type SetCategoryAssignmentRequest struct {
|
||||
Assigned float64
|
||||
}
|
||||
|
||||
func (h *Handler) setCategoryAssignment(c echo.Context) error {
|
||||
categoryID := c.Param("categoryid")
|
||||
categoryUUID, err := uuid.Parse(categoryID)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "categoryid missing from URL")
|
||||
}
|
||||
|
||||
var request SetCategoryAssignmentRequest
|
||||
err = c.Bind(&request)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("invalid payload: %w", err))
|
||||
}
|
||||
|
||||
date, err := getDate(c)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("date invalid: %w", err))
|
||||
}
|
||||
|
||||
var amount numeric.Numeric
|
||||
err = amount.Set(request.Assigned)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse amount: %w", err))
|
||||
}
|
||||
|
||||
updateArgs := postgres.UpdateAssignmentParams{
|
||||
CategoryID: categoryUUID,
|
||||
Date: date.FirstOfMonth(),
|
||||
Amount: amount,
|
||||
}
|
||||
err = h.Service.UpdateAssignment(c.Request().Context(), updateArgs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update assignment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (h *Handler) dashboard(c *gin.Context) {
|
||||
userID := MustGetToken(c).GetID()
|
||||
budgets, err := h.Service.GetBudgetsForUser(c.Request.Context(), userID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
d := DashboardData{
|
||||
Budgets: budgets,
|
||||
}
|
||||
c.JSON(http.StatusOK, d)
|
||||
}
|
||||
|
||||
type DashboardData struct {
|
||||
Budgets []postgres.Budget
|
||||
}
|
@ -11,7 +11,9 @@ import (
|
||||
"git.javil.eu/jacob1123/budgeteer"
|
||||
"git.javil.eu/jacob1123/budgeteer/bcrypt"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
)
|
||||
|
||||
// Handler handles incoming requests.
|
||||
@ -24,37 +26,31 @@ type Handler struct {
|
||||
|
||||
// Serve starts the http server.
|
||||
func (h *Handler) Serve() {
|
||||
router := gin.Default()
|
||||
router := echo.New()
|
||||
h.LoadRoutes(router)
|
||||
|
||||
if err := router.Run(":1323"); err != nil {
|
||||
if err := router.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
type SuccessResponse struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
// LoadRoutes initializes all the routes.
|
||||
func (h *Handler) LoadRoutes(router *gin.Engine) {
|
||||
func (h *Handler) LoadRoutes(router *echo.Echo) {
|
||||
router.Use(enableCachingForStaticFiles())
|
||||
router.NoRoute(h.ServeStatic)
|
||||
router.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||
Filesystem: h.StaticFS,
|
||||
HTML5: true,
|
||||
}))
|
||||
|
||||
api := router.Group("/api/v1")
|
||||
|
||||
anonymous := api.Group("/user")
|
||||
anonymous.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login") })
|
||||
anonymous.POST("/login", h.loginPost)
|
||||
anonymous.POST("/register", h.registerPost)
|
||||
|
||||
authenticated := api.Group("")
|
||||
{
|
||||
authenticated.Use(h.verifyLoginWithForbidden)
|
||||
authenticated.GET("/dashboard", h.dashboard)
|
||||
authenticated.GET("/account/:accountid/transactions", h.transactionsForAccount)
|
||||
authenticated.POST("/account/:accountid/reconcile", h.reconcileTransactions)
|
||||
authenticated.POST("/account/:accountid", h.editAccount)
|
||||
@ -62,27 +58,34 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
|
||||
|
||||
budget := authenticated.Group("/budget")
|
||||
budget.POST("/new", h.newBudget)
|
||||
budget.GET("/:budgetid", h.budgeting)
|
||||
budget.GET("/:budgetid", h.budget)
|
||||
budget.GET("/:budgetid/:year/:month", h.budgetingForMonth)
|
||||
budget.POST("/:budgetid/category/:categoryid/:year/:month", h.setCategoryAssignment)
|
||||
budget.GET("/:budgetid/autocomplete/payees", h.autocompletePayee)
|
||||
budget.GET("/:budgetid/autocomplete/accounts", h.autocompleteAccounts)
|
||||
budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
||||
budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
|
||||
budget.POST("/:budgetid/filtered-transactions", h.filteredTransactions)
|
||||
budget.DELETE("/:budgetid", h.deleteBudget)
|
||||
budget.POST("/:budgetid/import/ynab", h.importYNAB)
|
||||
budget.POST("/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
|
||||
budget.POST("/:budgetid/export/ynab/assignments", h.exportYNABAssignments)
|
||||
budget.POST("/:budgetid/settings/clear", h.clearBudget)
|
||||
budget.POST("/:budgetid/settings/clean-negative", h.cleanNegativeBudget)
|
||||
|
||||
transaction := authenticated.Group("/transaction")
|
||||
transaction.POST("/new", h.newTransaction)
|
||||
transaction.POST("/:transactionid", h.newTransaction)
|
||||
transaction.POST("/:transactionid", h.updateTransaction)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) ServeStatic(c *gin.Context) {
|
||||
h.ServeStaticFile(c, c.Request.URL.Path)
|
||||
func (h *Handler) ServeStatic(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
h.ServeStaticFile(c, c.Path())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) ServeStaticFile(c *gin.Context, fullPath string) {
|
||||
func (h *Handler) ServeStaticFile(c echo.Context, fullPath string) {
|
||||
file, err := h.StaticFS.Open(fullPath)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
h.ServeStaticFile(c, path.Join("/", "/index.html"))
|
||||
@ -90,13 +93,13 @@ func (h *Handler) ServeStaticFile(c *gin.Context, fullPath string) {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
stat, err := file.Stat()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -106,16 +109,20 @@ func (h *Handler) ServeStaticFile(c *gin.Context, fullPath string) {
|
||||
}
|
||||
|
||||
if file, ok := file.(io.ReadSeeker); ok {
|
||||
http.ServeContent(c.Writer, c.Request, stat.Name(), stat.ModTime(), file)
|
||||
http.ServeContent(c.Response().Writer, c.Request(), stat.Name(), stat.ModTime(), file)
|
||||
} else {
|
||||
panic("File does not implement ReadSeeker")
|
||||
}
|
||||
}
|
||||
|
||||
func enableCachingForStaticFiles() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/static/") {
|
||||
c.Header("Cache-Control", "max-age=86400")
|
||||
func enableCachingForStaticFiles() echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
if strings.HasPrefix(c.Path(), "/static/") {
|
||||
c.Response().Header().Set("Cache-Control", "max-age=86400")
|
||||
}
|
||||
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
305
server/main_test.go
Normal file
305
server/main_test.go
Normal file
@ -0,0 +1,305 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/bcrypt"
|
||||
"git.javil.eu/jacob1123/budgeteer/config"
|
||||
"git.javil.eu/jacob1123/budgeteer/jwt"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"git.javil.eu/jacob1123/budgeteer/web"
|
||||
|
||||
txdb "github.com/DATA-DOG/go-txdb"
|
||||
)
|
||||
|
||||
var cfg = config.Config{ //nolint:gochecknoglobals
|
||||
DatabaseConnection: "postgres://budgeteer:budgeteer@db:5432/budgeteer_test",
|
||||
SessionSecret: "this_is_my_demo_secret_for_unit_tests",
|
||||
}
|
||||
|
||||
func init() { //nolint:gochecknoinits
|
||||
_, err := postgres.Connect("pgx", cfg.DatabaseConnection)
|
||||
if err != nil {
|
||||
panic("failed connecting to DB for migrations: " + err.Error())
|
||||
}
|
||||
|
||||
txdb.Register("pgtx", "pgx", cfg.DatabaseConnection)
|
||||
}
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
queries, err := postgres.Connect("pgtx", cfg.DatabaseConnection)
|
||||
if err != nil {
|
||||
t.Errorf("connect to DB: %v", err)
|
||||
}
|
||||
|
||||
static, err := fs.Sub(web.Static, "dist")
|
||||
if err != nil {
|
||||
panic("couldn't open static files")
|
||||
}
|
||||
|
||||
tokenVerifier, err := jwt.NewTokenVerifier(cfg.SessionSecret)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("couldn't create token verifier: %w", err))
|
||||
}
|
||||
|
||||
handler := &Handler{
|
||||
Service: queries,
|
||||
TokenVerifier: tokenVerifier,
|
||||
CredentialsVerifier: &bcrypt.Verifier{},
|
||||
StaticFS: http.FS(static),
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
createUserParams := postgres.CreateUserParams{
|
||||
Email: "test@example.com",
|
||||
Name: "test@example.com",
|
||||
Password: "this is my dumb password",
|
||||
}
|
||||
user, err := handler.Service.CreateUser(ctx, createUserParams)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
budget, err := handler.Service.NewBudget(ctx, "My nice Budget", user.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
handler.DoYNABImport(ctx, t, budget)
|
||||
|
||||
loc := time.Now().Location()
|
||||
|
||||
AssertCategoriesAndAvailableEqual(ctx, t, loc, handler, budget)
|
||||
|
||||
AssertAccountsEqual(ctx, t, handler, budget)
|
||||
}
|
||||
|
||||
func AssertAccountsEqual(ctx context.Context, t *testing.T, handler *Handler, budget *postgres.Budget) {
|
||||
t.Helper()
|
||||
|
||||
t.Run("account balances", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
resultDir := "../testdata/production-export/results"
|
||||
files, err := os.ReadDir(resultDir)
|
||||
if err != nil {
|
||||
t.Errorf("could not load results: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := file.Name()[0 : len(file.Name())-5]
|
||||
if name != "accounts" {
|
||||
continue
|
||||
}
|
||||
|
||||
testCaseFile := filepath.Join(resultDir, file.Name())
|
||||
handler.CheckAccountBalance(ctx, t, testCaseFile, budget)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (h Handler) CheckAccountBalance(ctx context.Context, t *testing.T, testCaseFile string, budget *postgres.Budget) {
|
||||
t.Helper()
|
||||
|
||||
accounts, err := h.Service.GetAccountsWithBalance(ctx, budget.ID)
|
||||
if err != nil {
|
||||
t.Errorf("get accounts: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
testDataFile, err := os.Open(testCaseFile)
|
||||
if err != nil {
|
||||
t.Errorf("could not load category test data: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
var testData map[string]float64
|
||||
dec := json.NewDecoder(testDataFile)
|
||||
err = dec.Decode(&testData)
|
||||
if err != nil {
|
||||
t.Errorf("could not decode category test data: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
for accountName, accountBalance := range testData {
|
||||
found := false
|
||||
for _, account := range accounts {
|
||||
if account.Name == accountName {
|
||||
assertEqual(t, accountBalance, account.WorkingBalance.GetFloat64(), "balance for "+accountName)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Errorf("account " + accountName + " was not found in result")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func AssertCategoriesAndAvailableEqual(ctx context.Context, t *testing.T, loc *time.Location, handler *Handler, budget *postgres.Budget) {
|
||||
t.Helper()
|
||||
|
||||
t.Run("Categories and available balance", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
resultDir := "../testdata/production-export/results"
|
||||
files, err := os.ReadDir(resultDir)
|
||||
if err != nil {
|
||||
t.Errorf("could not load results: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := file.Name()[0 : len(file.Name())-5]
|
||||
parts := strings.Split(name, "-")
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
year, _ := strconv.Atoi(parts[0])
|
||||
month, _ := strconv.Atoi(parts[1])
|
||||
testCaseFile := filepath.Join(resultDir, file.Name())
|
||||
handler.CheckAvailableBalance(ctx, t, testCaseFile, budget, Month{year, month})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type TestData struct {
|
||||
AvailableBalance float64
|
||||
Categories map[string]CategoryTestData
|
||||
}
|
||||
|
||||
type CategoryTestData struct {
|
||||
Available float64
|
||||
Activity float64
|
||||
Assigned float64
|
||||
}
|
||||
|
||||
func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, testCaseFile string, budget *postgres.Budget, month Month) {
|
||||
t.Helper()
|
||||
|
||||
t.Run(month.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
data, err := h.getBudgetingViewForMonth(ctx, *budget, month)
|
||||
if err != nil {
|
||||
t.Errorf("prepare budgeting: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
testDataFile, err := os.Open(testCaseFile)
|
||||
if err != nil {
|
||||
t.Errorf("could not load category test data: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
var testData TestData
|
||||
dec := json.NewDecoder(testDataFile)
|
||||
err = dec.Decode(&testData)
|
||||
if err != nil {
|
||||
t.Errorf("could not decode category test data: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
assertEqual(t, testData.AvailableBalance, data.AvailableBalance.GetFloat64(), "available balance")
|
||||
|
||||
for categoryName, categoryTestData := range testData.Categories {
|
||||
found := false
|
||||
for _, category := range data.Categories {
|
||||
name := category.Group + " : " + category.Name
|
||||
|
||||
if name == categoryName {
|
||||
assertEqual(t, categoryTestData.Activity, category.Activity.GetFloat64(), "activity for "+categoryName)
|
||||
assertEqual(t, categoryTestData.Assigned, category.Assigned.GetFloat64(), "assigned for "+categoryName)
|
||||
available := category.AvailableLastMonth
|
||||
available.AddI(category.Activity).AddI(category.Assigned)
|
||||
assertEqual(t, categoryTestData.Available, available.GetFloat64(), "available for "+categoryName)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Errorf("category " + categoryName + " was not found in result")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func AssertEqualBool(t *testing.T, expected, actual bool, message string) {
|
||||
t.Helper()
|
||||
if expected == actual {
|
||||
return
|
||||
}
|
||||
|
||||
t.Errorf("%s: expected %v, got %v", message, expected, actual)
|
||||
}
|
||||
|
||||
func assertEqual(t *testing.T, expected, actual float64, message string) {
|
||||
t.Helper()
|
||||
if expected == actual {
|
||||
return
|
||||
}
|
||||
|
||||
t.Errorf("%s: expected %f, got %f", message, expected, actual)
|
||||
}
|
||||
|
||||
func (h Handler) DoYNABImport(ctx context.Context, t *testing.T, budget *postgres.Budget) {
|
||||
t.Helper()
|
||||
budgetID := budget.ID
|
||||
ynab, err := postgres.NewYNABImport(ctx, h.Service.Queries, budgetID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
transactions, err := os.Open("../testdata/production-export/Register.tsv")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
assignments, err := os.Open("../testdata/production-export/Budget.tsv")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
err = ynab.ImportTransactions(ctx, transactions)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
err = ynab.ImportAssignments(ctx, assignments)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
}
|
71
server/month.go
Normal file
71
server/month.go
Normal file
@ -0,0 +1,71 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Month struct {
|
||||
Year int
|
||||
Month int
|
||||
}
|
||||
|
||||
func NewFromTime(date time.Time) Month {
|
||||
return Month{date.Year(), int(date.Month())}
|
||||
}
|
||||
|
||||
func (m Month) String() string {
|
||||
return fmt.Sprintf("%d-%d", m.Year, m.Month)
|
||||
}
|
||||
|
||||
func (m Month) FirstOfMonth() time.Time {
|
||||
return time.Date(m.Year, time.Month(m.Month), 1, 0, 0, 0, 0, time.Now().Location())
|
||||
}
|
||||
|
||||
func (m Month) Previous() Month {
|
||||
if m.Month == int(time.January) {
|
||||
return Month{Year: m.Year - 1, Month: int(time.December)}
|
||||
}
|
||||
|
||||
return Month{Year: m.Year, Month: m.Month - 1}
|
||||
}
|
||||
|
||||
func (m Month) Next() Month {
|
||||
if m.Month == int(time.December) {
|
||||
return Month{Year: m.Year + 1, Month: int(time.January)}
|
||||
}
|
||||
|
||||
return Month{Year: m.Year, Month: m.Month + 1}
|
||||
}
|
||||
|
||||
func (m Month) InFuture(date time.Time) bool {
|
||||
if m.Year < date.Year() {
|
||||
return true
|
||||
}
|
||||
|
||||
if m.Year > date.Year() {
|
||||
return false
|
||||
}
|
||||
|
||||
return time.Month(m.Month) < date.Month()
|
||||
}
|
||||
|
||||
func (m Month) InPast(date time.Time) bool {
|
||||
if m.Year > date.Year() {
|
||||
return true
|
||||
}
|
||||
|
||||
if m.Year < date.Year() {
|
||||
return false
|
||||
}
|
||||
|
||||
return time.Month(m.Month) > date.Month()
|
||||
}
|
||||
|
||||
func (m Month) InPresent(date time.Time) bool {
|
||||
if date.Year() != m.Year {
|
||||
return false
|
||||
}
|
||||
|
||||
return date.Month() == time.Month(m.Month)
|
||||
}
|
46
server/month_test.go
Normal file
46
server/month_test.go
Normal file
@ -0,0 +1,46 @@
|
||||
package server_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/server"
|
||||
)
|
||||
|
||||
type TestCaseCompare struct {
|
||||
Value server.Month
|
||||
Date time.Time
|
||||
InPast bool
|
||||
InPresent bool
|
||||
InFuture bool
|
||||
}
|
||||
|
||||
func TestComparisons(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
loc := time.Now().Location()
|
||||
tests := []TestCaseCompare{
|
||||
{server.Month{2022, 2}, time.Date(2022, 3, 1, 0, 0, 0, 0, loc), false, false, true},
|
||||
{server.Month{2022, 3}, time.Date(2022, 3, 1, 0, 0, 0, 0, loc), false, true, false},
|
||||
{server.Month{2022, 4}, time.Date(2022, 3, 1, 0, 0, 0, 0, loc), true, false, false},
|
||||
{server.Month{2022, 2}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), false, false, true},
|
||||
{server.Month{2022, 3}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), false, true, false},
|
||||
{server.Month{2022, 4}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), true, false, false},
|
||||
{server.Month{2021, 2}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), false, false, true},
|
||||
{server.Month{2021, 3}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), false, false, true},
|
||||
{server.Month{2021, 4}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), false, false, true},
|
||||
{server.Month{2023, 2}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), true, false, false},
|
||||
{server.Month{2023, 3}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), true, false, false},
|
||||
{server.Month{2023, 4}, time.Date(2022, 3, 31, 0, 0, 0, 0, loc), true, false, false},
|
||||
{server.Month{2021, 11}, time.Date(2021, 12, 1, 0, 0, 0, 0, loc), false, false, true},
|
||||
}
|
||||
for i := range tests { //nolint:paralleltest
|
||||
test := tests[i]
|
||||
t.Run(test.Date.Format("2006-01-02")+" is in of "+test.Value.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
server.AssertEqualBool(t, test.InPast, test.Value.InPast(test.Date), "in past")
|
||||
server.AssertEqualBool(t, test.InPresent, test.Value.InPresent(test.Date), "in present")
|
||||
server.AssertEqualBool(t, test.InFuture, test.Value.InFuture(test.Date), "in future")
|
||||
})
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@ import (
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type ReconcileTransactionsRequest struct {
|
||||
@ -22,62 +22,60 @@ type ReconcileTransactionsResponse struct {
|
||||
ReconciliationTransaction *postgres.DisplayTransaction
|
||||
}
|
||||
|
||||
func (h *Handler) reconcileTransactions(c *gin.Context) {
|
||||
func (h *Handler) reconcileTransactions(c echo.Context) error {
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
var request ReconcileTransactionsRequest
|
||||
err = c.BindJSON(&request)
|
||||
err = c.Bind(&request)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
|
||||
}
|
||||
|
||||
var amount numeric.Numeric
|
||||
err = amount.Set(request.ReconcilationTransactionAmount)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
|
||||
}
|
||||
|
||||
tx, err := h.Service.BeginTx(c.Request.Context(), &sql.TxOptions{})
|
||||
tx, err := h.Service.BeginTx(c.Request().Context(), &sql.TxOptions{})
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("begin tx: %w", err))
|
||||
return
|
||||
return fmt.Errorf("begin tx: %w", err)
|
||||
}
|
||||
|
||||
db := h.Service.WithTx(tx)
|
||||
for _, transactionID := range request.TransactionIDs {
|
||||
err := db.SetTransactionReconciled(c.Request.Context(), transactionID)
|
||||
err := db.SetTransactionReconciled(c.Request().Context(), transactionID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("update transaction: %w", err))
|
||||
return
|
||||
return fmt.Errorf("update transaction: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
reconciliationTransaction, err := h.CreateReconcilationTransaction(amount, accountUUID, db, c)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("insert new transaction: %w", err))
|
||||
return
|
||||
return fmt.Errorf("insert new transaction: %w", err)
|
||||
}
|
||||
|
||||
err = h.Service.SetLastReconciled(c.Request().Context(), accountUUID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("set last reconciled: %w", err)
|
||||
}
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("commit: %w", err))
|
||||
return
|
||||
return fmt.Errorf("commit: %w", err)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, ReconcileTransactionsResponse{
|
||||
return c.JSON(http.StatusOK, ReconcileTransactionsResponse{
|
||||
Message: fmt.Sprintf("Set status for %d transactions", len(request.TransactionIDs)),
|
||||
ReconciliationTransaction: reconciliationTransaction,
|
||||
})
|
||||
}
|
||||
|
||||
func (*Handler) CreateReconcilationTransaction(amount numeric.Numeric, accountUUID uuid.UUID, db *postgres.Queries, c *gin.Context) (*postgres.DisplayTransaction, error) {
|
||||
func (*Handler) CreateReconcilationTransaction(amount numeric.Numeric, accountUUID uuid.UUID, db *postgres.Queries, c echo.Context) (*postgres.DisplayTransaction, error) {
|
||||
if amount.IsZero() {
|
||||
return nil, nil //nolint: nilnil
|
||||
}
|
||||
@ -89,12 +87,12 @@ func (*Handler) CreateReconcilationTransaction(amount numeric.Numeric, accountUU
|
||||
AccountID: accountUUID,
|
||||
Status: "Reconciled",
|
||||
}
|
||||
transactionUUID, err := db.CreateTransaction(c.Request.Context(), createTransaction)
|
||||
transactionUUID, err := db.CreateTransaction(c.Request().Context(), createTransaction)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("insert new transaction: %w", err)
|
||||
}
|
||||
|
||||
transaction, err := db.GetTransaction(c.Request.Context(), transactionUUID)
|
||||
transaction, err := db.GetTransaction(c.Request().Context(), transactionUUID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get created transaction: %w", err)
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -17,8 +17,8 @@ const (
|
||||
ParamName = "token"
|
||||
)
|
||||
|
||||
func MustGetToken(c *gin.Context) budgeteer.Token { //nolint:ireturn
|
||||
token := c.MustGet(ParamName)
|
||||
func MustGetToken(c echo.Context) budgeteer.Token { //nolint:ireturn
|
||||
token := c.Get(ParamName)
|
||||
if token, ok := token.(budgeteer.Token); ok {
|
||||
return token
|
||||
}
|
||||
@ -26,31 +26,32 @@ func MustGetToken(c *gin.Context) budgeteer.Token { //nolint:ireturn
|
||||
panic("Token is not a valid Token")
|
||||
}
|
||||
|
||||
func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, *ErrorResponse) { //nolint:ireturn
|
||||
tokenString := c.GetHeader(HeaderName)
|
||||
func (h *Handler) verifyLogin(c echo.Context) (budgeteer.Token, error) { //nolint:ireturn
|
||||
tokenString := c.Request().Header.Get(HeaderName)
|
||||
if len(tokenString) <= len(Bearer) {
|
||||
return nil, &ErrorResponse{"no authorization header supplied"}
|
||||
return nil, echo.NewHTTPError(http.StatusUnauthorized, "no authorization header supplied")
|
||||
}
|
||||
|
||||
tokenString = tokenString[7:]
|
||||
token, err := h.TokenVerifier.VerifyToken(tokenString)
|
||||
if err != nil {
|
||||
return nil, &ErrorResponse{fmt.Sprintf("verify token '%s': %s", tokenString, err)}
|
||||
return nil, fmt.Errorf("verify token '%s': %w", tokenString, err)
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func (h *Handler) verifyLoginWithForbidden(c *gin.Context) {
|
||||
func (h *Handler) verifyLoginWithForbidden(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
token, err := h.verifyLogin(c)
|
||||
if err != nil {
|
||||
// c.Header("WWW-Authenticate", "Bearer")
|
||||
c.AbortWithStatusJSON(http.StatusForbidden, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusForbidden, err)
|
||||
}
|
||||
|
||||
c.Set(ParamName, token)
|
||||
c.Next()
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
|
||||
type loginInformation struct {
|
||||
@ -58,37 +59,35 @@ type loginInformation struct {
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
func (h *Handler) loginPost(c *gin.Context) {
|
||||
func (h *Handler) loginPost(c echo.Context) error {
|
||||
var login loginInformation
|
||||
err := c.BindJSON(&login)
|
||||
err := c.Bind(&login)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("parse payload: %w", err)
|
||||
}
|
||||
|
||||
user, err := h.Service.GetUserByUsername(c.Request.Context(), login.User)
|
||||
user, err := h.Service.GetUserByUsername(c.Request().Context(), login.User)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return
|
||||
return fmt.Errorf("verify password: %w", err)
|
||||
}
|
||||
|
||||
token, err := h.TokenVerifier.CreateToken(&user)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return fmt.Errorf("create token: %w", err)
|
||||
}
|
||||
|
||||
go h.UpdateLastLogin(user.ID)
|
||||
|
||||
budgets, err := h.Service.GetBudgetsForUser(c.Request.Context(), user.ID)
|
||||
budgets, err := h.Service.GetBudgetsForUser(c.Request().Context(), user.ID)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, LoginResponse{token, user, budgets})
|
||||
return c.JSON(http.StatusOK, LoginResponse{token, user, budgets})
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
@ -103,29 +102,25 @@ type registerInformation struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (h *Handler) registerPost(c *gin.Context) {
|
||||
func (h *Handler) registerPost(c echo.Context) error {
|
||||
var register registerInformation
|
||||
err := c.BindJSON(®ister)
|
||||
err := c.Bind(®ister)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"error parsing body"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "error parsing body")
|
||||
}
|
||||
|
||||
if register.Email == "" || register.Password == "" || register.Name == "" {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"e-mail, password and name are required"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "e-mail, password and name are required")
|
||||
}
|
||||
|
||||
_, err = h.Service.GetUserByUsername(c.Request.Context(), register.Email)
|
||||
_, err = h.Service.GetUserByUsername(c.Request().Context(), register.Email)
|
||||
if err == nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"email is already taken"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "email is already taken")
|
||||
}
|
||||
|
||||
hash, err := h.CredentialsVerifier.Hash(register.Password)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return fmt.Errorf("hash password: %w", err)
|
||||
}
|
||||
|
||||
createUser := postgres.CreateUserParams{
|
||||
@ -133,24 +128,24 @@ func (h *Handler) registerPost(c *gin.Context) {
|
||||
Password: hash,
|
||||
Email: register.Email,
|
||||
}
|
||||
user, err := h.Service.CreateUser(c.Request.Context(), createUser)
|
||||
user, err := h.Service.CreateUser(c.Request().Context(), createUser)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return err
|
||||
}
|
||||
|
||||
token, err := h.TokenVerifier.CreateToken(&user)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return fmt.Errorf("create token: %w", err)
|
||||
}
|
||||
|
||||
go h.UpdateLastLogin(user.ID)
|
||||
|
||||
budgets, err := h.Service.GetBudgetsForUser(c.Request.Context(), user.ID)
|
||||
budgets, err := h.Service.GetBudgetsForUser(c.Request().Context(), user.ID)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, LoginResponse{token, user, budgets})
|
||||
return c.JSON(http.StatusOK, LoginResponse{token, user, budgets})
|
||||
}
|
||||
|
||||
func (h *Handler) UpdateLastLogin(userID uuid.UUID) {
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type NewTransactionPayload struct {
|
||||
@ -27,24 +27,37 @@ type NewTransactionPayload struct {
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
func (h *Handler) newTransaction(c *gin.Context) {
|
||||
func (h *Handler) updateTransaction(c echo.Context) error {
|
||||
var payload NewTransactionPayload
|
||||
err := c.BindJSON(&payload)
|
||||
err := c.Bind(&payload)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
amount, err := numeric.Parse(payload.Amount)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
|
||||
}
|
||||
|
||||
transactionID := c.Param("transactionid")
|
||||
if transactionID != "" {
|
||||
h.UpdateTransaction(payload, amount, transactionID, c)
|
||||
return
|
||||
transactionUUID, err := uuid.Parse(transactionID)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "transactionid missing from URL")
|
||||
}
|
||||
|
||||
return h.UpdateTransaction(payload, amount, transactionUUID, c)
|
||||
}
|
||||
|
||||
func (h *Handler) newTransaction(c echo.Context) error {
|
||||
var payload NewTransactionPayload
|
||||
err := c.Bind(&payload)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
amount, err := numeric.Parse(payload.Amount)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
|
||||
}
|
||||
|
||||
newTransaction := postgres.CreateTransactionParams{
|
||||
@ -59,42 +72,38 @@ func (h *Handler) newTransaction(c *gin.Context) {
|
||||
if payload.Payee.Type == "account" {
|
||||
groupID, err := h.CreateTransferForOtherAccount(newTransaction, amount, payload, c)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
newTransaction.GroupID = groupID
|
||||
} else {
|
||||
payeeID, err := GetPayeeID(c.Request.Context(), payload, h)
|
||||
payeeID, err := GetPayeeID(c.Request().Context(), payload, h)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("create payee: %w", err))
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("create payee: %w", err))
|
||||
}
|
||||
newTransaction.PayeeID = payeeID
|
||||
}
|
||||
|
||||
transactionUUID, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
|
||||
transactionUUID, err := h.Service.CreateTransaction(c.Request().Context(), newTransaction)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("create transaction: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("create transaction: %w", err))
|
||||
}
|
||||
|
||||
transaction, err := h.Service.GetTransaction(c.Request.Context(), transactionUUID)
|
||||
transaction, err := h.Service.GetTransaction(c.Request().Context(), transactionUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, transaction)
|
||||
return c.JSON(http.StatusOK, transaction)
|
||||
}
|
||||
|
||||
func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeric.Numeric, transactionID string, c *gin.Context) {
|
||||
transactionUUID := uuid.MustParse(transactionID)
|
||||
func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeric.Numeric, transactionUUID uuid.UUID, c echo.Context) error {
|
||||
if amount.IsZero() {
|
||||
err := h.Service.DeleteTransaction(c.Request.Context(), transactionUUID)
|
||||
err := h.Service.DeleteTransaction(c.Request().Context(), transactionUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("delete transaction: %w", err))
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("delete transaction: %w", err))
|
||||
}
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
editTransaction := postgres.UpdateTransactionParams{
|
||||
@ -106,22 +115,20 @@ func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeri
|
||||
ID: transactionUUID,
|
||||
}
|
||||
|
||||
err := h.Service.UpdateTransaction(c.Request.Context(), editTransaction)
|
||||
err := h.Service.UpdateTransaction(c.Request().Context(), editTransaction)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("edit transaction: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("edit transaction: %w", err))
|
||||
}
|
||||
|
||||
transaction, err := h.Service.GetTransaction(c.Request.Context(), transactionUUID)
|
||||
transaction, err := h.Service.GetTransaction(c.Request().Context(), transactionUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, transaction)
|
||||
return c.JSON(http.StatusOK, transaction)
|
||||
}
|
||||
|
||||
func (h *Handler) CreateTransferForOtherAccount(newTransaction postgres.CreateTransactionParams, amount numeric.Numeric, payload NewTransactionPayload, c *gin.Context) (uuid.NullUUID, error) {
|
||||
func (h *Handler) CreateTransferForOtherAccount(newTransaction postgres.CreateTransactionParams, amount numeric.Numeric, payload NewTransactionPayload, c echo.Context) (uuid.NullUUID, error) {
|
||||
newTransaction.GroupID = uuid.NullUUID{UUID: uuid.New(), Valid: true}
|
||||
newTransaction.Amount = amount.Neg()
|
||||
newTransaction.AccountID = payload.Payee.ID.UUID
|
||||
@ -129,7 +136,7 @@ func (h *Handler) CreateTransferForOtherAccount(newTransaction postgres.CreateTr
|
||||
// transfer does not need category. Either it's account is off-budget or no category was supplied.
|
||||
newTransaction.CategoryID = uuid.NullUUID{}
|
||||
|
||||
_, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
|
||||
_, err := h.Service.CreateTransaction(c.Request().Context(), newTransaction)
|
||||
if err != nil {
|
||||
return uuid.NullUUID{}, fmt.Errorf("create transfer transaction: %w", err)
|
||||
}
|
||||
|
37
server/util.go
Normal file
37
server/util.go
Normal file
@ -0,0 +1,37 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func getDate(c echo.Context) (Month, error) {
|
||||
var year, month int
|
||||
yearString := c.Param("year")
|
||||
monthString := c.Param("month")
|
||||
if yearString == "" && monthString == "" {
|
||||
return getFirstOfMonthTime(time.Now()), nil
|
||||
}
|
||||
|
||||
year, err := strconv.Atoi(yearString)
|
||||
if err != nil {
|
||||
return Month{}, fmt.Errorf("parse year: %w", err)
|
||||
}
|
||||
|
||||
month, err = strconv.Atoi(monthString)
|
||||
if err != nil {
|
||||
return Month{}, fmt.Errorf("parse month: %w", err)
|
||||
}
|
||||
|
||||
return Month{year, month}, nil
|
||||
}
|
||||
|
||||
func getFirstOfMonthTime(date time.Time) Month {
|
||||
var monthM time.Month
|
||||
year, monthM, _ := date.Date()
|
||||
month := int(monthM)
|
||||
return Month{year, month}
|
||||
}
|
@ -1,117 +1,107 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func (h *Handler) importYNAB(c *gin.Context) {
|
||||
budgetID, succ := c.Params.Get("budgetid")
|
||||
if !succ {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
|
||||
return
|
||||
func (h *Handler) importYNAB(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
if budgetID == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
|
||||
}
|
||||
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if !succ {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
ynab, err := postgres.NewYNABImport(c.Request.Context(), h.Service.Queries, budgetUUID)
|
||||
ynab, err := postgres.NewYNABImport(c.Request().Context(), h.Service.Queries, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
transactionsFile, err := c.FormFile("transactions")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return fmt.Errorf("get transactions: %w", err)
|
||||
}
|
||||
|
||||
transactions, err := transactionsFile.Open()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return fmt.Errorf("open transactions: %w", err)
|
||||
}
|
||||
|
||||
err = ynab.ImportTransactions(c.Request.Context(), transactions)
|
||||
err = ynab.ImportTransactions(c.Request().Context(), transactions)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
assignmentsFile, err := c.FormFile("assignments")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return fmt.Errorf("get assignments: %w", err)
|
||||
}
|
||||
|
||||
assignments, err := assignmentsFile.Open()
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return fmt.Errorf("open assignments: %w", err)
|
||||
}
|
||||
|
||||
err = ynab.ImportAssignments(c.Request.Context(), assignments)
|
||||
err = ynab.ImportAssignments(c.Request().Context(), assignments)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNABTransactions(c *gin.Context) {
|
||||
budgetID, succ := c.Params.Get("budgetid")
|
||||
if !succ {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNABTransactions(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
if budgetID == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
|
||||
}
|
||||
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if !succ {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
ynab, err := postgres.NewYNABExport(c.Request.Context(), h.Service.Queries, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
err = ynab.ExportTransactions(c.Request.Context(), c.Writer)
|
||||
ynab, err := postgres.NewYNABExport(c.Request().Context(), h.Service.Queries, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNABAssignments(c *gin.Context) {
|
||||
budgetID, succ := c.Params.Get("budgetid")
|
||||
if !succ {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
|
||||
return
|
||||
err = ynab.ExportTransactions(c.Request().Context(), c.Response().Writer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNABAssignments(c echo.Context) error {
|
||||
budgetID := c.Param("budgetid")
|
||||
if budgetID == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
|
||||
}
|
||||
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if !succ {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
ynab, err := postgres.NewYNABExport(c.Request.Context(), h.Service.Queries, budgetUUID)
|
||||
ynab, err := postgres.NewYNABExport(c.Request().Context(), h.Service.Queries, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
err = ynab.ExportAssignments(c.Request.Context(), c.Writer)
|
||||
err = ynab.ExportAssignments(c.Request().Context(), c.Response().Writer)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
1
testdata
Submodule
1
testdata
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 8de369b17a81f2e6ed079374ab35f868f259f9c1
|
21
web/.eslintrc.js
Normal file
21
web/.eslintrc.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
// add more generic rulesets here, such as:
|
||||
// 'eslint:recommended',
|
||||
"plugin:vue/vue3-recommended",
|
||||
// 'plugin:vue/recommended' // Use this if you are using Vue.js 2.x.
|
||||
],
|
||||
rules: {
|
||||
// override/add rules settings here, such as:
|
||||
'vue/max-attributes-per-line': 'off',
|
||||
'vue/singleline-html-element-content-newline': 'off',
|
||||
'vue/first-attribute-linebreak': 'off',
|
||||
'vue/html-closing-bracket-newline': 'off',
|
||||
// 'vue/no-unused-vars': 'error'
|
||||
},
|
||||
parser: "vue-eslint-parser",
|
||||
parserOptions: {
|
||||
parser: "@typescript-eslint/parser",
|
||||
sourceType: "module",
|
||||
},
|
||||
};
|
0
web/dist/generate-directory-for-ci
vendored
Normal file
0
web/dist/generate-directory-for-ci
vendored
Normal file
@ -6,7 +6,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body class="bg-slate-200 text-slate-800 dark:bg-slate-800 dark:text-slate-200 box-border w-full">
|
||||
<body
|
||||
class="bg-slate-200 text-slate-800 dark:bg-slate-800 dark:text-slate-200 box-border w-full">
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
|
@ -20,14 +20,22 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/file-saver": "^2.0.5",
|
||||
"@typescript-eslint/parser": "^5.13.0",
|
||||
"@vitejs/plugin-vue": "^2.0.0",
|
||||
"@vue/cli-plugin-babel": "5.0.0-beta.7",
|
||||
"@vue/cli-plugin-typescript": "~4.5.0",
|
||||
"@vue/cli-service": "5.0.0-beta.7",
|
||||
"eslint": "^8.10.0",
|
||||
"eslint-plugin-vue": "^8.5.0",
|
||||
"prettier": "2.5.1",
|
||||
"sass": "^1.38.0",
|
||||
"sass-loader": "^10.0.0",
|
||||
"typescript": "^4.5.5",
|
||||
"vite": "^2.7.2",
|
||||
"vue-tsc": "^0.32.0"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"bracketSameLine": true,
|
||||
"embeddedLanguageFormatting": "off",
|
||||
"tabWidth": 4,
|
||||
"useTabs": false
|
||||
},
|
||||
"eslintIgnore": ["index.css"]
|
||||
}
|
||||
|
@ -3,4 +3,4 @@ module.exports = {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -1,59 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { mapState } from "pinia";
|
||||
import { defineComponent } from "vue";
|
||||
import { useBudgetsStore } from "./stores/budget";
|
||||
import { useSessionStore } from "./stores/session";
|
||||
import { useSettingsStore } from "./stores/settings";
|
||||
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useBudgetsStore, ["CurrentBudgetName"]),
|
||||
...mapState(useSettingsStore, ["Menu"]),
|
||||
...mapState(useSessionStore, ["LoggedIn"]),
|
||||
},
|
||||
methods: {
|
||||
logout() {
|
||||
useSessionStore().logout();
|
||||
this.$router.push("/login");
|
||||
},
|
||||
toggleMenu() {
|
||||
useSettingsStore().toggleMenu();
|
||||
},
|
||||
toggleMenuSize() {
|
||||
useSettingsStore().toggleMenuSize();
|
||||
}
|
||||
},
|
||||
})
|
||||
<script lang="ts" setup>
|
||||
import MainMenu from "./components/MainMenu.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col md:flex-row flex-1">
|
||||
<div
|
||||
:class="[Menu.Expand ? 'md:w-72' : 'md:w-36', Menu.Show ? '' : 'hidden']"
|
||||
class="md:block flex-shrink-0 w-full bg-gray-500 border-r-4 border-black"
|
||||
>
|
||||
<router-view name="sidebar"></router-view>
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row flex-1 h-screen">
|
||||
<router-view name="sidebar" />
|
||||
|
||||
<div class="flex-1">
|
||||
<div class="flex bg-gray-400 dark:bg-gray-600 p-4 fixed md:static top-0 left-0 w-full h-14">
|
||||
<span
|
||||
class="flex-1 font-bold text-5xl -my-3 hidden md:inline"
|
||||
@click="toggleMenuSize"
|
||||
>≡</span>
|
||||
<span class="flex-1 font-bold text-5xl -my-3 md:hidden" @click="toggleMenu">≡</span>
|
||||
|
||||
<span class="flex-1">{{ CurrentBudgetName }}</span>
|
||||
|
||||
<div class="flex flex-1 flex-row justify-end -mx-4">
|
||||
<router-link class="mx-4" v-if="LoggedIn" to="/dashboard">Dashboard</router-link>
|
||||
<router-link class="mx-4" v-if="!LoggedIn" to="/login">Login</router-link>
|
||||
<a class="mx-4" v-if="LoggedIn" @click="logout">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 overflow-auto">
|
||||
<MainMenu />
|
||||
|
||||
<div class="p-3 pl-6">
|
||||
<router-view></router-view>
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,26 +1,29 @@
|
||||
import { useSessionStore } from "./stores/session";
|
||||
|
||||
export const BASE_URL = "/api/v1"
|
||||
export const BASE_URL = "/api/v1";
|
||||
|
||||
export function GET(path: string) {
|
||||
const sessionStore = useSessionStore();
|
||||
return fetch(BASE_URL + path, {
|
||||
headers: sessionStore.AuthHeaders,
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function POST(path: string, body: FormData | string | null) {
|
||||
const sessionStore = useSessionStore();
|
||||
return fetch(BASE_URL + path, {
|
||||
method: "POST",
|
||||
headers: sessionStore.AuthHeaders,
|
||||
headers: {
|
||||
...sessionStore.AuthHeaders,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: body,
|
||||
})
|
||||
});
|
||||
}
|
||||
export function DELETE(path: string) {
|
||||
const sessionStore = useSessionStore();
|
||||
return fetch(BASE_URL + path, {
|
||||
method: "DELETE",
|
||||
headers: sessionStore.AuthHeaders,
|
||||
})
|
||||
});
|
||||
}
|
35
web/src/components/AccountWithReconciled.vue
Normal file
35
web/src/components/AccountWithReconciled.vue
Normal file
@ -0,0 +1,35 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { useBudgetsStore } from '../stores/budget';
|
||||
import { Account } from '../stores/budget-account';
|
||||
|
||||
const props = defineProps<{
|
||||
account: Account
|
||||
}>();
|
||||
|
||||
const budgetStore = useBudgetsStore();
|
||||
const CurrentBudgetID = computed(() => budgetStore.CurrentBudgetID);
|
||||
|
||||
const days = 24 * 60 * 60 * 1000;
|
||||
function daysSinceLastReconciled() {
|
||||
const now = new Date().getTime();
|
||||
const diff = new Date(now).getTime() - props.account.LastReconciled.Time.getTime();
|
||||
return Math.floor(diff / days);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span>
|
||||
<router-link
|
||||
:to="'/budget/' + CurrentBudgetID + '/account/' + account.ID"
|
||||
>
|
||||
{{ account.Name }}
|
||||
</router-link>
|
||||
<span
|
||||
v-if="props.account.LastReconciled.Valid && daysSinceLastReconciled() > 7"
|
||||
class="font-bold bg-gray-500 rounded-md text-sm px-2 mx-2 py-1 no-underline"
|
||||
>
|
||||
{{ daysSinceLastReconciled() }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
@ -11,10 +11,10 @@ export interface Suggestion {
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
text: String,
|
||||
id: String | undefined,
|
||||
model: String,
|
||||
type?: string | undefined,
|
||||
text: string | null,
|
||||
id: string | null,
|
||||
model: string,
|
||||
type?: string | null,
|
||||
}>();
|
||||
|
||||
const SearchQuery = ref(props.text || "");
|
||||
@ -83,19 +83,27 @@ function clear() {
|
||||
<template>
|
||||
<div>
|
||||
<Input
|
||||
type="text"
|
||||
class="border-b-2 border-black"
|
||||
@keypress="keypress"
|
||||
v-if="id == undefined"
|
||||
v-model="SearchQuery"
|
||||
type="text"
|
||||
class="border-b-2 border-black block w-full border-b-2 border-black"
|
||||
@keypress="keypress"
|
||||
/>
|
||||
<span @click="clear" v-if="id != undefined" class="bg-gray-300 dark:bg-gray-700">{{ text }}</span>
|
||||
<div v-if="Suggestions.length > 0" class="absolute bg-gray-400 dark:bg-gray-600 w-64 p-2">
|
||||
<span
|
||||
v-if="id != undefined"
|
||||
class="bg-gray-300 dark:bg-gray-700"
|
||||
@click="clear"
|
||||
>{{ text }}</span>
|
||||
<div
|
||||
v-if="Suggestions.length > 0"
|
||||
class="absolute bg-gray-400 dark:bg-gray-600 w-64 p-2"
|
||||
>
|
||||
<span
|
||||
v-for="suggestion in Suggestions"
|
||||
:key="suggestion.ID"
|
||||
class="block"
|
||||
@click="select"
|
||||
:value="suggestion.ID"
|
||||
@click="select"
|
||||
>{{ suggestion.Name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,10 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="px-4 rounded-md shadow-sm focus:outline-none focus:ring-2"
|
||||
>
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
@ -1,8 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-row items-center bg-gray-300 dark:bg-gray-700 rounded-lg">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
@ -1,11 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
const props = defineProps(["modelValue"]);
|
||||
const props = defineProps<{modelValue?: boolean}>();
|
||||
const emits = defineEmits<{
|
||||
(e: "update:modelValue", value: boolean): void
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="modelValue"
|
||||
@change="$emit('update:modelValue', ($event.target as HTMLInputElement)?.checked)"
|
||||
class="dark:bg-slate-900">
|
||||
class="dark:bg-slate-900"
|
||||
@change="emits('update:modelValue', ($event.target as HTMLInputElement)?.checked)"
|
||||
>
|
||||
</template>
|
@ -1,7 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps<{ value: number | undefined }>();
|
||||
const props = defineProps<{
|
||||
value: number | undefined
|
||||
negativeClass?: string
|
||||
positiveClass?: string
|
||||
}>();
|
||||
|
||||
const internalValue = computed(() => Number(props.value ?? 0));
|
||||
|
||||
@ -11,5 +15,8 @@ const formattedValue = computed(() => internalValue.value.toLocaleString(undefin
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="text-right" :class="internalValue < 0 ? 'negative' : ''">{{ formattedValue }} €</span>
|
||||
<span
|
||||
class="text-right"
|
||||
:class="internalValue < 0 ? (negativeClass ?? 'negative') : positiveClass"
|
||||
>{{ formattedValue }} €</span>
|
||||
</template>
|
@ -1,9 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import Input from './Input.vue';
|
||||
const props = defineProps(["modelValue"]);
|
||||
const props = defineProps<{
|
||||
modelValue?: Date
|
||||
}>();
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
function dateToYYYYMMDD(d: Date) : string {
|
||||
function dateToYYYYMMDD(d: Date | undefined) : string {
|
||||
if(d == null)
|
||||
return "";
|
||||
// alternative implementations in https://stackoverflow.com/q/23593052/1850609
|
||||
@ -27,9 +29,9 @@ function selectAll(event: FocusEvent) {
|
||||
|
||||
<template>
|
||||
<Input
|
||||
type="date"
|
||||
ref="input"
|
||||
v-bind:value="dateToYYYYMMDD(modelValue)"
|
||||
type="date"
|
||||
:value="dateToYYYYMMDD(modelValue)"
|
||||
@input="updateValue"
|
||||
@focus="selectAll"
|
||||
/>
|
||||
|
@ -1,10 +1,26 @@
|
||||
<script lang="ts" setup>
|
||||
const props = defineProps(["modelValue"]);
|
||||
const props = defineProps<{
|
||||
modelValue?: number | string,
|
||||
type: string,
|
||||
}>();
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: "update:modelValue", value: number | string): void
|
||||
}>();
|
||||
|
||||
function valueChanged(e: Event) {
|
||||
const target = <HTMLInputElement>e.target;
|
||||
switch (props.type) {
|
||||
case "number":
|
||||
emits('update:modelValue', target.valueAsNumber);
|
||||
break;
|
||||
default:
|
||||
emits('update:modelValue', target.value)
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
:value="modelValue"
|
||||
@input="$emit('update:modelValue', ($event.target as HTMLInputElement)?.value)"
|
||||
class="dark:bg-slate-900">
|
||||
<input :value="modelValue" :type="type" class="dark:bg-slate-900" @input="valueChanged">
|
||||
</template>
|
44
web/src/components/MainMenu.vue
Normal file
44
web/src/components/MainMenu.vue
Normal file
@ -0,0 +1,44 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
import { useSessionStore } from "../stores/session";
|
||||
import { useSettingsStore } from "../stores/settings";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const CurrentBudgetName = computed(() => useBudgetsStore().CurrentBudgetName);
|
||||
const LoggedIn = computed(() => useSessionStore().LoggedIn);
|
||||
function logout() {
|
||||
useSessionStore().logout();
|
||||
router.push("/login");
|
||||
}
|
||||
|
||||
function toggleMenu() {
|
||||
useSettingsStore().toggleMenu();
|
||||
}
|
||||
function toggleMenuSize() {
|
||||
useSettingsStore().toggleMenuSize();
|
||||
}
|
||||
|
||||
router.afterEach(function(to, from) {
|
||||
useSettingsStore().Menu.Show = false;
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex bg-gray-400 dark:bg-gray-600 p-4 static top-0 left-0 w-full h-14">
|
||||
<span class="flex-1 font-bold text-5xl -my-3 hidden md:inline" @click="toggleMenuSize">≡</span>
|
||||
<span class="flex-1 font-bold text-5xl -my-3 md:hidden" @click="toggleMenu">≡</span>
|
||||
<span class="flex-1">{{ CurrentBudgetName }}</span>
|
||||
<div class="flex flex-1 flex-row justify-end -mx-4">
|
||||
<router-link v-if="LoggedIn" class="mx-4" to="/dashboard">
|
||||
Dashboard
|
||||
</router-link>
|
||||
<router-link v-if="!LoggedIn" class="mx-4" to="/login">
|
||||
Login
|
||||
</router-link>
|
||||
<a v-if="LoggedIn" class="mx-4" @click="logout">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import Card from '../components/Card.vue';
|
||||
import RowCard from './RowCard.vue';
|
||||
import { ref } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
@ -32,29 +32,44 @@ function submitDialog() {
|
||||
<template>
|
||||
<button @click="openDialog">
|
||||
<slot name="placeholder">
|
||||
<Card>
|
||||
<p class="w-24 text-center text-6xl">+</p>
|
||||
<span class="text-lg" dark>{{ buttonText }}</span>
|
||||
</Card>
|
||||
<RowCard>
|
||||
<p class="w-24 text-center text-6xl">
|
||||
+
|
||||
</p>
|
||||
<span
|
||||
class="text-lg"
|
||||
dark
|
||||
>{{ buttonText }}</span>
|
||||
</RowCard>
|
||||
</slot>
|
||||
</button>
|
||||
<div
|
||||
v-if="visible"
|
||||
class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full"
|
||||
>
|
||||
<div class="relative top-20 mx-auto p-5 w-96 shadow-lg rounded-md bg-white dark:bg-black">
|
||||
<div
|
||||
class="relative md:top-20 md:mx-auto p-5 md:w-96 shadow-lg md:h-auto h-full rounded-md bg-white dark:bg-black"
|
||||
>
|
||||
<div class="mt-3 text-center">
|
||||
<h3 class="mt-3 text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">{{ buttonText }}</h3>
|
||||
<slot></slot>
|
||||
<h3
|
||||
class="mt-3 text-lg leading-6 font-medium text-gray-900 dark:text-gray-100"
|
||||
>
|
||||
{{ buttonText }}
|
||||
</h3>
|
||||
<slot />
|
||||
<div class="grid grid-cols-2 gap-6">
|
||||
<button
|
||||
@click="closeDialog"
|
||||
class="px-4 py-2 bg-red-500 text-white text-base font-medium rounded-md shadow-sm hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-300"
|
||||
>Close</button>
|
||||
@click="closeDialog"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
@click="submitDialog"
|
||||
class="px-4 py-2 bg-green-500 text-white text-base font-medium rounded-md shadow-sm hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-300"
|
||||
>Save</button>
|
||||
@click="submitDialog"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
9
web/src/components/RowCard.vue
Normal file
9
web/src/components/RowCard.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<script lang="ts" setup></script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-row items-center bg-gray-300 dark:bg-gray-700 rounded-lg"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
7
web/src/components/SimpleButton.vue
Normal file
7
web/src/components/SimpleButton.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<script lang="ts" setup></script>
|
||||
|
||||
<template>
|
||||
<button class="px-4 rounded-md shadow-sm focus:outline-none focus:ring-2">
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
@ -5,10 +5,11 @@ import { useAccountStore } from '../stores/budget-account'
|
||||
import DateInput from "./DateInput.vue";
|
||||
import { useTransactionsStore } from "../stores/transactions";
|
||||
import Input from "./Input.vue";
|
||||
import Button from "./Button.vue";
|
||||
import Button from "./SimpleButton.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
transactionid: string
|
||||
transactionid: string,
|
||||
withAccount: boolean,
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(["save"]);
|
||||
@ -40,7 +41,10 @@ function saveTransaction(e: MouseEvent) {
|
||||
<template>
|
||||
<tr>
|
||||
<td class="text-sm">
|
||||
<DateInput class="border-b-2 border-black" v-model="TX.Date" />
|
||||
<DateInput v-model="TX.Date" class="border-b-2 border-black" />
|
||||
</td>
|
||||
<td v-if="withAccount">
|
||||
<Autocomplete v-model:text="TX.Account" v-model:id="TX.AccountID" model="accounts" />
|
||||
</td>
|
||||
<td>
|
||||
<Autocomplete v-model:text="TX.Payee" v-model:id="TX.PayeeID" v-model:type="payeeType" model="payees" />
|
||||
@ -49,18 +53,16 @@ function saveTransaction(e: MouseEvent) {
|
||||
<Autocomplete v-model:text="TX.Category" v-model:id="TX.CategoryID" model="categories" />
|
||||
</td>
|
||||
<td>
|
||||
<Input class="block w-full border-b-2 border-black" type="text" v-model="TX.Memo" />
|
||||
<Input v-model="TX.Memo" class="block w-full border-b-2 border-black" type="text" />
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Input
|
||||
class="text-right block w-full border-b-2 border-black"
|
||||
type="currency"
|
||||
v-model="TX.Amount"
|
||||
/>
|
||||
<Input v-model="TX.Amount" class="text-right block w-full border-b-2 border-black" type="currency" />
|
||||
</td>
|
||||
<td>
|
||||
<Button class="bg-blue-500" @click="saveTransaction">Save</Button>
|
||||
<Button class="bg-blue-500" @click="saveTransaction">
|
||||
Save
|
||||
</Button>
|
||||
</td>
|
||||
<td></td>
|
||||
<td />
|
||||
</tr>
|
||||
</template>
|
@ -3,7 +3,7 @@ import { computed, ref } from "vue";
|
||||
import Autocomplete from '../components/Autocomplete.vue'
|
||||
import { Transaction, useTransactionsStore } from "../stores/transactions";
|
||||
import DateInput from "./DateInput.vue";
|
||||
import Button from "./Button.vue";
|
||||
import Button from "./SimpleButton.vue";
|
||||
import Input from "./Input.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
@ -16,15 +16,17 @@ const TX = ref<Transaction>({
|
||||
Memo: "",
|
||||
Amount: 0,
|
||||
Payee: "",
|
||||
PayeeID: undefined,
|
||||
PayeeID: null,
|
||||
Category: "",
|
||||
CategoryID: undefined,
|
||||
CategoryID: null,
|
||||
CategoryGroup: "",
|
||||
GroupID: "",
|
||||
ID: "",
|
||||
Status: "Uncleared",
|
||||
TransferAccount: "",
|
||||
Reconciled: false
|
||||
Reconciled: false,
|
||||
Account: "",
|
||||
AccountID: "",
|
||||
});
|
||||
|
||||
const payeeType = ref<string|undefined>(undefined);
|
||||
@ -47,37 +49,65 @@ const payload = computed(() => JSON.stringify({
|
||||
const transactionsStore = useTransactionsStore();
|
||||
function saveTransaction(e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
Save();
|
||||
}
|
||||
|
||||
function Save() {
|
||||
transactionsStore.saveTransaction(payload.value);
|
||||
}
|
||||
|
||||
defineExpose({Save});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tr>
|
||||
<label class="md:hidden">Date</label>
|
||||
<td class="text-sm">
|
||||
<DateInput class="border-b-2 border-black" v-model="TX.Date" />
|
||||
<DateInput
|
||||
v-model="TX.Date"
|
||||
class="block w-full border-b-2 border-black"
|
||||
/>
|
||||
</td>
|
||||
<label class="md:hidden">Payee</label>
|
||||
<td>
|
||||
<Autocomplete v-model:text="TX.Payee" v-model:id="TX.PayeeID" v-model:type="payeeType" model="payees" />
|
||||
<Autocomplete
|
||||
v-model:text="TX.Payee"
|
||||
v-model:id="TX.PayeeID"
|
||||
v-model:type="payeeType"
|
||||
model="payees"
|
||||
/>
|
||||
</td>
|
||||
<label class="md:hidden">Category</label>
|
||||
<td>
|
||||
<Autocomplete v-model:text="TX.Category" v-model:id="TX.CategoryID" model="categories" />
|
||||
<Autocomplete
|
||||
v-model:text="TX.Category"
|
||||
v-model:id="TX.CategoryID"
|
||||
model="categories"
|
||||
/>
|
||||
</td>
|
||||
<label class="md:hidden">Memo</label>
|
||||
<td class="col-span-2">
|
||||
<Input class="block w-full border-b-2 border-black" type="text" v-model="TX.Memo" />
|
||||
<Input
|
||||
v-model="TX.Memo"
|
||||
class="block w-full border-b-2 border-black"
|
||||
type="text"
|
||||
/>
|
||||
</td>
|
||||
<label class="md:hidden">Amount</label>
|
||||
<td class="text-right">
|
||||
<Input
|
||||
v-model="TX.Amount"
|
||||
class="text-right block w-full border-b-2 border-black"
|
||||
type="currency"
|
||||
v-model="TX.Amount"
|
||||
/>
|
||||
</td>
|
||||
<td class="hidden md:table-cell">
|
||||
<Button class="bg-blue-500" @click="saveTransaction">Save</Button>
|
||||
<Button
|
||||
class="bg-blue-500"
|
||||
@click="saveTransaction"
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
@ -6,12 +6,12 @@ import Currency from "./Currency.vue";
|
||||
import TransactionEditRow from "./TransactionEditRow.vue";
|
||||
import { formatDate } from "../date";
|
||||
import { useAccountStore } from "../stores/budget-account";
|
||||
import Input from "./Input.vue";
|
||||
import Checkbox from "./Checkbox.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
transactionid: string,
|
||||
index: number,
|
||||
withAccount: boolean,
|
||||
}>();
|
||||
|
||||
const edit = ref(false);
|
||||
@ -22,19 +22,6 @@ const Reconciling = computed(() => useTransactionsStore().Reconciling);
|
||||
const transactionsStore = useTransactionsStore();
|
||||
const TX = transactionsStore.Transactions.get(props.transactionid)!;
|
||||
|
||||
function dateChanged() {
|
||||
const currentAccount = useAccountStore().CurrentAccount;
|
||||
if (currentAccount == null)
|
||||
return true;
|
||||
const transactionIndex = currentAccount.Transactions.indexOf(props.transactionid);
|
||||
if(transactionIndex<=0)
|
||||
return true;
|
||||
|
||||
const previousTransactionId = currentAccount.Transactions[transactionIndex-1];
|
||||
const previousTransaction = transactionsStore.Transactions.get(previousTransactionId);
|
||||
return TX.Date.getTime() != previousTransaction?.Date.getTime();
|
||||
}
|
||||
|
||||
function getStatusSymbol() {
|
||||
if(TX.Status == "Reconciled")
|
||||
return "✔";
|
||||
@ -47,34 +34,50 @@ function getStatusSymbol() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tr v-if="dateChanged()" class="table-row md:hidden">
|
||||
<td class="bg-gray-200 dark:bg-gray-800 rounded-lg p-2" colspan="5">{{ formatDate(TX.Date) }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="!edit"
|
||||
class="{{new Date(TX.Date) > new Date() ? 'future' : ''}}"
|
||||
:class="[index % 6 < 3 ? 'md:bg-gray-300 dark:md:bg-gray-700' : 'md:bg-gray-100 dark:md:bg-gray-900']"
|
||||
:class="[index % 2 < 1 ? 'md:bg-gray-300 dark:md:bg-gray-700' : 'md:bg-gray-100 dark:md:bg-gray-900']"
|
||||
>
|
||||
<!--:class="[index % 6 < 3 ? index % 6 === 1 ? 'bg-gray-400' : 'bg-gray-300' : index % 6 !== 4 ? 'bg-gray-100' : '']">-->
|
||||
<td class="hidden md:block">{{ formatDate(TX.Date) }}</td>
|
||||
<td class="pl-2 md:pl-0">{{ TX.TransferAccount ? "Transfer : " + TX.TransferAccount : TX.Payee }}</td>
|
||||
<td>{{ TX.CategoryGroup ? TX.CategoryGroup + " : " + TX.Category : "" }}</td>
|
||||
<td class="hidden md:block">
|
||||
{{ formatDate(TX.Date) }}
|
||||
</td>
|
||||
<td v-if="withAccount" class="pl-2 md:pl-0">
|
||||
{{ TX.Account }}
|
||||
</td>
|
||||
<td class="pl-2 md:pl-0">
|
||||
{{ TX.TransferAccount ? "Transfer : " + TX.TransferAccount : TX.Payee }}
|
||||
</td>
|
||||
<td>
|
||||
{{ TX.CategoryGroup ? TX.CategoryGroup + " : " + TX.Category : "" }}
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
:href="'/budget/' + CurrentBudgetID + '/transaction/' + TX.ID"
|
||||
>{{ TX.Memo }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<Currency class="block" :value="TX.Amount" />
|
||||
<Currency
|
||||
class="block"
|
||||
:value="TX.Amount"
|
||||
/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
{{ TX.GroupID ? "☀" : "" }}
|
||||
{{ getStatusSymbol() }}
|
||||
<a @click="edit = true;">✎</a>
|
||||
<Checkbox v-if="Reconciling && TX.Status != 'Reconciled'" v-model="TX.Reconciled" />
|
||||
<Checkbox
|
||||
v-if="Reconciling && TX.Status != 'Reconciled'"
|
||||
v-model="TX.Reconciled"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<TransactionEditRow v-if="edit" :transactionid="TX.ID" @save="edit = false" />
|
||||
<TransactionEditRow
|
||||
v-if="edit"
|
||||
:transactionid="TX.ID"
|
||||
:with-account="withAccount"
|
||||
@save="edit = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
@ -1,7 +1,17 @@
|
||||
export function formatDate(date: Date): string {
|
||||
return date.toLocaleDateString(undefined, { // you can use undefined as first argument
|
||||
return date.toLocaleDateString(undefined, {
|
||||
// you can use undefined as first argument
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
export function groupBy<T, K extends keyof any>(list: T[], getKey: (item: T) => K) {
|
||||
return list.reduce((previous, currentItem) => {
|
||||
const group = getKey(currentItem);
|
||||
if (!previous[group]) previous[group] = [];
|
||||
previous[group].push(currentItem);
|
||||
return previous;
|
||||
}, {} as Record<K, T[]>);
|
||||
}
|
@ -42,34 +42,43 @@ function openEditAccount(e : any) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal button-text="Edit Account" @open="openEditAccount" @submit="editAccount">
|
||||
<template v-slot:placeholder><span class="ml-2">✎</span></template>
|
||||
<Modal
|
||||
button-text="Edit Account"
|
||||
@open="openEditAccount"
|
||||
@submit="editAccount"
|
||||
>
|
||||
<template #placeholder>
|
||||
<span class="ml-2">✎</span>
|
||||
</template>
|
||||
<div class="mt-2 px-7 py-3">
|
||||
<Input
|
||||
v-model="accountName"
|
||||
class="border-2 dark:border-gray-700"
|
||||
type="text"
|
||||
v-model="accountName"
|
||||
placeholder="Account name"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-2 px-7 py-3">
|
||||
<Checkbox
|
||||
class="border-2"
|
||||
v-model="accountOnBudget"
|
||||
class="border-2"
|
||||
required
|
||||
/>
|
||||
<label>On Budget</label>
|
||||
</div>
|
||||
<div class="mt-2 px-7 py-3">
|
||||
<Checkbox
|
||||
class="border-2"
|
||||
v-model="accountOpen"
|
||||
class="border-2"
|
||||
required
|
||||
/>
|
||||
<label>Open</label>
|
||||
</div>
|
||||
<div v-if="error != ''" class="dark:text-red-300 text-red-700">
|
||||
<div
|
||||
v-if="error != ''"
|
||||
class="dark:text-red-300 text-red-700"
|
||||
>
|
||||
{{ error }}
|
||||
</div>
|
||||
</Modal>
|
||||
|
@ -11,9 +11,18 @@ function saveBudget() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal button-text="New Budget" @submit="saveBudget">
|
||||
<Modal
|
||||
button-text="New Budget"
|
||||
@submit="saveBudget"
|
||||
>
|
||||
<div class="mt-2 px-7 py-3">
|
||||
<Input class="border-2" type="text" v-model="budgetName" placeholder="Budget name" required />
|
||||
<Input
|
||||
v-model="budgetName"
|
||||
class="border-2"
|
||||
type="text"
|
||||
placeholder="Budget name"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
@ -1,28 +1,79 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import './index.css'
|
||||
import router from './router'
|
||||
import { createPinia } from 'pinia'
|
||||
import { useBudgetsStore } from './stores/budget';
|
||||
import { useAccountStore } from './stores/budget-account'
|
||||
import PiniaLogger from './pinia-logger'
|
||||
import { createApp } from "vue";
|
||||
import App from "./App.vue";
|
||||
import "./index.css";
|
||||
import router from "./router";
|
||||
import { createPinia } from "pinia";
|
||||
import { useBudgetsStore } from "./stores/budget";
|
||||
import { useAccountStore } from "./stores/budget-account";
|
||||
import PiniaLogger from "./pinia-logger";
|
||||
import { useSessionStore } from "./stores/session";
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(router)
|
||||
const app = createApp(App);
|
||||
app.use(router);
|
||||
|
||||
const pinia = createPinia()
|
||||
pinia.use(PiniaLogger({
|
||||
const pinia = createPinia();
|
||||
pinia.use(
|
||||
PiniaLogger({
|
||||
expanded: false,
|
||||
showDuration: true
|
||||
}))
|
||||
app.use(pinia)
|
||||
app.mount('#app')
|
||||
showDuration: true,
|
||||
})
|
||||
);
|
||||
app.use(pinia);
|
||||
app.mount("#app");
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const budgetStore = useBudgetsStore();
|
||||
await budgetStore.SetCurrentBudget((<string>to.params.budgetid));
|
||||
await budgetStore.SetCurrentBudget(<string>to.params.budgetid);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
await accountStore.SetCurrentAccount((<string>to.params.budgetid), (<string>to.params.accountid));
|
||||
await accountStore.SetCurrentAccount(
|
||||
<string>to.params.budgetid,
|
||||
<string>to.params.accountid
|
||||
);
|
||||
next();
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const sessionStore = useSessionStore();
|
||||
const token = sessionStore.Session?.Token;
|
||||
let loggedIn = false;
|
||||
|
||||
if (token != null) {
|
||||
const jwt = parseJwt(token);
|
||||
if (jwt.exp > Date.now() / 1000) loggedIn = true;
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||
if (!loggedIn) {
|
||||
next({ path: "/login" });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else if (to.matched.some((record) => record.meta.hideForAuth)) {
|
||||
if (loggedIn) {
|
||||
next({ path: "/dashboard" });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
function parseJwt(token: string) {
|
||||
var base64Url = token.split(".")[1];
|
||||
var base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||
var jsonPayload = decodeURIComponent(
|
||||
atob(base64)
|
||||
.split("")
|
||||
.map(function (c) {
|
||||
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
})
|
||||
.join("")
|
||||
);
|
||||
|
||||
return JSON.parse(jsonPayload);
|
||||
}
|
||||
|
||||
1646426130;
|
||||
1646512855755;
|
||||
|
@ -5,16 +5,24 @@ import TransactionRow from "../components/TransactionRow.vue";
|
||||
import TransactionInputRow from "../components/TransactionInputRow.vue";
|
||||
import { useAccountStore } from "../stores/budget-account";
|
||||
import EditAccount from "../dialogs/EditAccount.vue";
|
||||
import Button from "../components/Button.vue";
|
||||
import Button from "../components/SimpleButton.vue";
|
||||
import { useTransactionsStore } from "../stores/transactions";
|
||||
import Modal from "../components/Modal.vue";
|
||||
import Input from "../components/Input.vue";
|
||||
import Checkbox from "../components/Checkbox.vue";
|
||||
import { formatDate } from "../date";
|
||||
|
||||
defineProps<{
|
||||
budgetid: string
|
||||
accountid: string
|
||||
}>()
|
||||
|
||||
const modalInputRow = ref<typeof TransactionInputRow | null>(null);
|
||||
|
||||
function submitModal() {
|
||||
modalInputRow.value!.Save();
|
||||
}
|
||||
|
||||
const accounts = useAccountStore();
|
||||
const transactions = useTransactionsStore();
|
||||
const TargetReconcilingBalance = ref(0);
|
||||
@ -50,7 +58,9 @@ function createReconcilationTransaction() {
|
||||
<EditAccount />
|
||||
</div>
|
||||
|
||||
<div class="text-right flex flex-wrap flex-col md:flex-row justify-end gap-2 max-w-sm">
|
||||
<div
|
||||
class="text-right flex flex-wrap flex-col md:flex-row justify-end gap-2 max-w-sm"
|
||||
>
|
||||
<span class="rounded-lg p-1 whitespace-nowrap flex-1">
|
||||
Working:
|
||||
<Currency :value="accounts.CurrentAccount?.WorkingBalance" />
|
||||
@ -62,35 +72,45 @@ function createReconcilationTransaction() {
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="rounded-lg bg-blue-500 p-1 whitespace-nowrap flex-1"
|
||||
v-if="!transactions.Reconciling"
|
||||
class="rounded-lg bg-blue-500 p-1 whitespace-nowrap flex-1"
|
||||
@click="transactions.Reconciling = true"
|
||||
>
|
||||
Reconciled:
|
||||
<Currency :value="accounts.CurrentAccount?.ReconciledBalance" />
|
||||
</span>
|
||||
|
||||
<span v-if="transactions.Reconciling" class="contents">
|
||||
<Button @click="submitReconcilation"
|
||||
class="bg-blue-500 p-1 whitespace-nowrap flex-1">
|
||||
<span
|
||||
v-if="transactions.Reconciling"
|
||||
class="contents"
|
||||
>
|
||||
<Button
|
||||
class="bg-blue-500 p-1 whitespace-nowrap flex-1"
|
||||
@click="submitReconcilation"
|
||||
>
|
||||
My current balance is
|
||||
<Currency :value="transactions.ReconcilingBalance" />
|
||||
</Button>
|
||||
|
||||
<Button @click="createReconcilationTransaction"
|
||||
class="bg-orange-500 p-1 whitespace-nowrap flex-1">
|
||||
<Button
|
||||
class="bg-orange-500 p-1 whitespace-nowrap flex-1"
|
||||
@click="createReconcilationTransaction"
|
||||
>
|
||||
No, it's:
|
||||
<Input
|
||||
v-model="TargetReconcilingBalance"
|
||||
class="text-right w-20 bg-transparent dark:bg-transparent border-b-2"
|
||||
type="number"
|
||||
v-model="TargetReconcilingBalance"
|
||||
/>
|
||||
(Difference
|
||||
<Currency
|
||||
:value="transactions.ReconcilingBalance - TargetReconcilingBalance"
|
||||
/>)
|
||||
</Button>
|
||||
<Button class="bg-red-500 p-1 flex-1" @click="cancelReconcilation">Cancel</Button>
|
||||
<Button
|
||||
class="bg-red-500 p-1 flex-1"
|
||||
@click="cancelReconcilation"
|
||||
>Cancel</Button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -103,7 +123,7 @@ function createReconcilationTransaction() {
|
||||
<td>Memo</td>
|
||||
<td class="text-right">Amount</td>
|
||||
<td style="width: 80px;">
|
||||
<Input v-if="transactions.Reconciling" type="checkbox" @input="setReconciled" />
|
||||
<Checkbox v-if="transactions.Reconciling" @input="setReconciled" />
|
||||
</td>
|
||||
</tr>
|
||||
<TransactionInputRow
|
||||
@ -111,20 +131,35 @@ function createReconcilationTransaction() {
|
||||
:budgetid="budgetid"
|
||||
:accountid="accountid"
|
||||
/>
|
||||
<template v-for="(dayTransactions, key, index) in transactions.TransactionsByDate" :key="key">
|
||||
<tr class="table-row md:hidden">
|
||||
<td class="py-2" colspan="5">
|
||||
<span class="bg-gray-400 dark:bg-slate-600 rounded-lg p-1 px-2 w-full block">
|
||||
{{ key }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<TransactionRow
|
||||
v-for="(transaction, index) in transactions.TransactionsList"
|
||||
v-for="transaction in dayTransactions"
|
||||
:key="transaction.ID"
|
||||
:transactionid="transaction.ID"
|
||||
:index="index"
|
||||
:transactionid="transaction.ID"
|
||||
:with-account="false"
|
||||
/>
|
||||
</template>
|
||||
</table>
|
||||
<div class="md:hidden">
|
||||
<Modal>
|
||||
<template v-slot:placeholder>
|
||||
<Button class="fixed right-4 bottom-4 font-bold text-lg bg-blue-500 py-2">+</Button>
|
||||
<Modal @submit="submitModal">
|
||||
<template #placeholder>
|
||||
<Button
|
||||
class="fixed right-4 bottom-4 font-bold text-lg bg-blue-500 py-2"
|
||||
>
|
||||
+
|
||||
</Button>
|
||||
</template>
|
||||
<TransactionInputRow
|
||||
class="grid grid-cols-2"
|
||||
ref="modalInputRow"
|
||||
class="flex flex-col w-full h-full top-0"
|
||||
:budgetid="budgetid"
|
||||
:accountid="accountid"
|
||||
/>
|
||||
|
125
web/src/pages/AllAccounts.vue
Normal file
125
web/src/pages/AllAccounts.vue
Normal file
@ -0,0 +1,125 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, onMounted, watch } from "vue"
|
||||
import Currency from "../components/Currency.vue";
|
||||
import TransactionRow from "../components/TransactionRow.vue";
|
||||
import TransactionInputRow from "../components/TransactionInputRow.vue";
|
||||
import { useAccountStore } from "../stores/budget-account";
|
||||
import EditAccount from "../dialogs/EditAccount.vue";
|
||||
import Button from "../components/SimpleButton.vue";
|
||||
import { useTransactionsStore } from "../stores/transactions";
|
||||
import Modal from "../components/Modal.vue";
|
||||
import Input from "../components/Input.vue";
|
||||
import Checkbox from "../components/Checkbox.vue";
|
||||
import { formatDate } from "../date";
|
||||
import DateInput from "../components/DateInput.vue";
|
||||
import Autocomplete from '../components/Autocomplete.vue'
|
||||
|
||||
defineProps<{
|
||||
budgetid: string
|
||||
}>()
|
||||
|
||||
const modalInputRow = ref<typeof TransactionInputRow | null>(null);
|
||||
|
||||
function submitModal() {
|
||||
modalInputRow.value!.Save();
|
||||
}
|
||||
|
||||
const accounts = useAccountStore();
|
||||
const transactions = useTransactionsStore();
|
||||
|
||||
onMounted(() => {
|
||||
transactions.GetProblematicTransactions();
|
||||
})
|
||||
|
||||
const filters = ref({
|
||||
Account: null,
|
||||
AccountID: null,
|
||||
Payee: null,
|
||||
PayeeID: null,
|
||||
Category: null,
|
||||
CategoryID: null,
|
||||
FromDate: new Date(1900, 0, 2),
|
||||
ToDate: new Date(2999,11,32),
|
||||
});
|
||||
|
||||
watch(() => (filters.value.AccountID ?? "")
|
||||
+ filters.value.PayeeID
|
||||
+ filters.value.CategoryID
|
||||
+ filters.value.FromDate?.toISOString()
|
||||
+ filters.value.ToDate?.toISOString(), function() {
|
||||
if(!hasFilters.value)
|
||||
return;
|
||||
transactions.GetFilteredTransactions(
|
||||
filters.value.AccountID,
|
||||
filters.value.CategoryID,
|
||||
filters.value.PayeeID,
|
||||
filters.value.FromDate?.toISOString(),
|
||||
filters.value.ToDate?.toISOString(),
|
||||
);
|
||||
})
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
filters.value.AccountID != null
|
||||
|| filters.value.PayeeID != null
|
||||
|| filters.value.CategoryID != null
|
||||
|| (filters.value.FromDate != null && filters.value.FromDate.getFullYear() > 1901)
|
||||
|| (filters.value.ToDate != null && filters.value.ToDate.getFullYear() < 2998))
|
||||
|
||||
const transactionsList = computed(() => {
|
||||
if (hasFilters.value){
|
||||
return transactions.FilteredTransactionsList;
|
||||
}
|
||||
return transactions.ProblematicTransactionsList;
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-[1fr_auto]">
|
||||
<div>
|
||||
<h1 class="inline">
|
||||
{{ hasFilters ? "Filtered" : "Problematic" }} Transactions
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 w-96">
|
||||
Account:
|
||||
<Autocomplete v-model:text="filters.Account" v-model:id="filters.AccountID" model="accounts" class="inline-block" /><br>
|
||||
Payee:
|
||||
<Autocomplete v-model:text="filters.Payee" v-model:id="filters.PayeeID" model="payees" class="inline-block" /><br>
|
||||
Category:
|
||||
<Autocomplete v-model:text="filters.Category" v-model:id="filters.CategoryID" model="categories" class="inline-block" /><br>
|
||||
From Date:
|
||||
<DateInput v-model="filters.FromDate" class="inline-block" /><br>
|
||||
To Date:
|
||||
<DateInput v-model="filters.ToDate" class="inline-block" />
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr class="font-bold">
|
||||
<td class="hidden md:block" style="width: 90px;">Date</td>
|
||||
<td style="max-width: 200px;">Account</td>
|
||||
<td style="max-width: 150px;">Payee</td>
|
||||
<td style="max-width: 200px;">Category</td>
|
||||
<td>Memo</td>
|
||||
<td class="text-right">Amount</td>
|
||||
</tr>
|
||||
<TransactionRow
|
||||
v-for="(transaction, index) in transactionsList"
|
||||
:key="transaction.ID"
|
||||
:with-account="true"
|
||||
:transactionid="transaction.ID"
|
||||
:index="index"
|
||||
/>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
table {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.negative {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -1,11 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
import Currency from "../components/Currency.vue"
|
||||
import { useBudgetsStore } from "../stores/budget"
|
||||
import { Account, useAccountStore } from "../stores/budget-account"
|
||||
import { useSettingsStore } from "../stores/settings"
|
||||
import Currency from "../components/Currency.vue";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
import { Account, useAccountStore } from "../stores/budget-account";
|
||||
import { useSettingsStore } from "../stores/settings";
|
||||
import AccountWithReconciled from "../components/AccountWithReconciled.vue";
|
||||
|
||||
const ExpandMenu = computed(() => useSettingsStore().Menu.Expand);
|
||||
const settings = useSettingsStore();
|
||||
const ExpandMenu = computed(() => settings.Menu.Expand);
|
||||
const ShowMenu = computed(() => settings.Menu.Show);
|
||||
|
||||
const budgetStore = useBudgetsStore();
|
||||
const CurrentBudgetName = computed(() => budgetStore.CurrentBudgetName);
|
||||
@ -17,47 +20,46 @@ const OffBudgetAccounts = computed(() => accountStore.OffBudgetAccounts);
|
||||
const OnBudgetAccountsBalance = computed(() => accountStore.OnBudgetAccountsBalance);
|
||||
const OffBudgetAccountsBalance = computed(() => accountStore.OffBudgetAccountsBalance);
|
||||
|
||||
function isRecentlyReconciled(account : Account) {
|
||||
const now = new Date().getTime();
|
||||
const recently = 7 * 24 * 60 * 60 * 1000;
|
||||
return new Date(now - recently).getTime() < account.LastReconciled.getTime();
|
||||
}
|
||||
|
||||
function getAccountName(account : Account) {
|
||||
const reconciledMarker = isRecentlyReconciled(account) ? "" : " *";
|
||||
return account.Name + reconciledMarker;
|
||||
function toggleMenu() {
|
||||
useSettingsStore().toggleMenu();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col mt-14 md:mt-0">
|
||||
<span class="m-2 p-1 px-3 h-10 overflow-hidden" :class="[ExpandMenu ? 'text-2xl' : 'text-md']">
|
||||
<router-link to="/dashboard" style="font-size:150%">⌂</router-link>
|
||||
<div :class="[ExpandMenu ? 'md:w-72' : 'md:w-36', ShowMenu ? '' : 'hidden']"
|
||||
class="md:block flex-shrink-0 w-full bg-gray-500 border-r-4 border-black">
|
||||
<div class="flex flex-col">
|
||||
<div class="m-2 md:px-3 p-1">
|
||||
<span class="font-bold-my-3 md:hidden font-bold text-5xl pr-3" @click="toggleMenu">≡</span>
|
||||
<span class="h-10 overflow-hidden" :class="[ExpandMenu ? 'text-2xl' : 'text-md']">
|
||||
<router-link to="/dashboard" class="text-5xl">⌂</router-link>
|
||||
{{ CurrentBudgetName }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="bg-gray-100 dark:bg-gray-700 p-2 px-3 flex flex-col">
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/budgeting'">Budget</router-link><br />
|
||||
<router-link :to="'/budget/' + CurrentBudgetID + '/budgeting'">Budget</router-link>
|
||||
<br>
|
||||
<!--<router-link :to="'/budget/'+CurrentBudgetID+'/reports'">Reports</router-link>-->
|
||||
<!--<router-link :to="'/budget/'+CurrentBudgetID+'/all-accounts'">All Accounts</router-link>-->
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/problematic-transactions'">Transactions</router-link>
|
||||
</span>
|
||||
<li class="bg-slate-200 dark:bg-slate-700 my-2 p-2 px-3">
|
||||
<div class="flex flex-row justify-between font-bold">
|
||||
<span>On-Budget Accounts</span>
|
||||
<Currency :class="ExpandMenu?'md:inline':'md:hidden'" :value="OnBudgetAccountsBalance" />
|
||||
<Currency :class="ExpandMenu ? 'md:inline' : 'md:hidden'" class="whitespace-nowrap" :value="OnBudgetAccountsBalance" />
|
||||
</div>
|
||||
<div v-for="account in OnBudgetAccounts" class="flex flex-row justify-between">
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/account/'+account.ID">{{getAccountName(account)}}</router-link>
|
||||
<Currency :class="ExpandMenu?'md:inline':'md:hidden'" :value="account.ClearedBalance" />
|
||||
<div v-for="account in OnBudgetAccounts" :key="account.ID" class="flex flex-row justify-between">
|
||||
<AccountWithReconciled class="whitespace-nowrap overflow-hidden mr-4" :account="account" />
|
||||
<Currency :class="ExpandMenu ? 'md:inline' : 'md:hidden'" class="whitespace-nowrap" :value="account.ClearedBalance" />
|
||||
</div>
|
||||
</li>
|
||||
<li class="bg-slate-200 dark:bg-slate-700 my-2 p-2 px-3">
|
||||
<div class="flex flex-row justify-between font-bold">
|
||||
<span>Off-Budget Accounts</span>
|
||||
<Currency :class="ExpandMenu?'md:inline':'md:hidden'" :value="OffBudgetAccountsBalance" />
|
||||
<Currency :class="ExpandMenu ? 'md:inline' : 'md:hidden'" class="whitespace-nowrap" :value="OffBudgetAccountsBalance" />
|
||||
</div>
|
||||
<div v-for="account in OffBudgetAccounts" class="flex flex-row justify-between">
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/account/'+account.ID">{{getAccountName(account)}}</router-link>
|
||||
<Currency :class="ExpandMenu?'md:inline':'md:hidden'" :value="account.ClearedBalance" />
|
||||
<div v-for="account in OffBudgetAccounts" :key="account.ID" class="flex flex-row justify-between">
|
||||
<AccountWithReconciled class="whitespace-nowrap overflow-hidden mr-4" :account="account" />
|
||||
<Currency :class="ExpandMenu ? 'md:inline' : 'md:hidden'" class="whitespace-nowrap" :value="account.ClearedBalance" />
|
||||
</div>
|
||||
</li>
|
||||
<!--
|
||||
@ -72,8 +74,11 @@ function getAccountName(account : Account) {
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/accounts'">Edit accounts</router-link>
|
||||
</li>-->
|
||||
<li class="bg-red-100 dark:bg-slate-600 my-2 p-2 px-3">
|
||||
<router-link :to="'/budget/'+CurrentBudgetID+'/settings'">Budget-Settings</router-link>
|
||||
<router-link :to="'/budget/' + CurrentBudgetID + '/settings'">
|
||||
Budget-Settings
|
||||
</router-link>
|
||||
</li>
|
||||
<!--<li><router-link to="/admin">Admin</router-link></li>-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -1,9 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, defineProps, onMounted, ref, watchEffect } from "vue";
|
||||
import { computed, onMounted, ref, watchEffect } from "vue";
|
||||
import Currency from "../components/Currency.vue";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
import { useAccountStore } from "../stores/budget-account";
|
||||
import { Category, useAccountStore } from "../stores/budget-account";
|
||||
import { useSessionStore } from "../stores/session";
|
||||
import Input from "../components/Input.vue";
|
||||
import { POST } from "../api";
|
||||
|
||||
const props = defineProps<{
|
||||
budgetid: string,
|
||||
@ -63,38 +65,154 @@ function toggleGroup(group: { Name: string, Expand: boolean }) {
|
||||
function getGroupState(group: { Name: string, Expand: boolean }): boolean {
|
||||
return expandedGroups.value.get(group.Name) ?? group.Expand;
|
||||
}
|
||||
|
||||
function assignedChanged(e : Event, category : Category){
|
||||
const target = e.target as HTMLInputElement;
|
||||
const value = target.valueAsNumber;
|
||||
POST("/budget/"+CurrentBudgetID.value+"/category/" + category.ID + "/" + selected.value.Year + "/" + (selected.value.Month+1),
|
||||
JSON.stringify({Assigned: category.Assigned}));
|
||||
}
|
||||
|
||||
const budgeted = computed(() => accountStore.GetBudgeted(selected.value.Year, selected.value.Month))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>Budget for {{ selected.Month + 1 }}/{{ selected.Year }}</h1>
|
||||
<table class="inline-block">
|
||||
<tr>
|
||||
<td>
|
||||
Available last month:
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Currency :value="accountStore.Available-accountStore.OverspentLastMonth+budgeted.Assigned+budgeted.Deassigned" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Overspent last month:
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Currency :value="accountStore.OverspentLastMonth" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Budgeted this month:
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Currency :value="budgeted.Assigned+budgeted.Deassigned" />
|
||||
</td>
|
||||
<td class="text-sm pl-2">
|
||||
= <Currency :value="budgeted.Assigned" /> - <Currency :value="-budgeted.Deassigned" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="font-bold">
|
||||
<td class="py-2">
|
||||
Available balance:
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Currency :value="accountStore.Available" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Activity:
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<Currency :value="budgeted.Income + budgeted.Spent" />
|
||||
</td>
|
||||
<td class="text-sm pl-2">
|
||||
= <Currency :value="budgeted.Income" /> - <Currency :value="-1 * budgeted.Spent" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div>
|
||||
<router-link
|
||||
:to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month"
|
||||
><<</router-link>
|
||||
>
|
||||
<<
|
||||
</router-link>
|
||||
<router-link
|
||||
:to="'/budget/' + CurrentBudgetID + '/budgeting/' + current.Year + '/' + current.Month"
|
||||
>Current Month</router-link>
|
||||
>
|
||||
Current Month
|
||||
</router-link>
|
||||
<router-link
|
||||
:to="'/budget/' + CurrentBudgetID + '/budgeting/' + next.Year + '/' + next.Month"
|
||||
>>></router-link>
|
||||
>
|
||||
>>
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="container col-lg-12 grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-5" id="content">
|
||||
<span class="hidden sm:block"></span>
|
||||
<div
|
||||
id="content"
|
||||
class="container col-lg-12 grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-5"
|
||||
>
|
||||
<span class="hidden sm:block" />
|
||||
<span class="hidden lg:block text-right">Leftover</span>
|
||||
<span class="hidden sm:block text-right">Assigned</span>
|
||||
<span class="hidden sm:block text-right">Activity</span>
|
||||
<span class="hidden sm:block text-right">Available</span>
|
||||
<template v-for="group in GroupsForMonth">
|
||||
<a
|
||||
class="text-lg font-bold col-span-2 sm:col-span-4 lg:col-span-5"
|
||||
<template
|
||||
v-for="group in GroupsForMonth"
|
||||
:key="group.Name"
|
||||
>
|
||||
<span
|
||||
class="text-lg font-bold mt-2"
|
||||
@click="toggleGroup(group)"
|
||||
>{{ (getGroupState(group) ? "−" : "+") + " " + group.Name }}</a>
|
||||
<template v-for="category in GetCategories(group.Name)" v-if="getGroupState(group)">
|
||||
<span class="whitespace-nowrap overflow-hidden">{{ category.Name }}</span>
|
||||
<Currency :value="category.AvailableLastMonth" class="hidden lg:block" />
|
||||
<Currency :value="category.Assigned" class="hidden sm:block" />
|
||||
<Currency :value="category.Activity" class="hidden sm:block" />
|
||||
<Currency :value="category.Available" />
|
||||
>{{ (getGroupState(group) ? "−" : "+") + " " + group.Name }}</span>
|
||||
<Currency
|
||||
:value="group.AvailableLastMonth"
|
||||
class="hidden lg:block mt-2"
|
||||
positive-class="text-slate-500"
|
||||
negative-class="text-red-700 dark:text-red-400"
|
||||
/>
|
||||
<Currency
|
||||
:value="group.Assigned"
|
||||
class="hidden sm:block mx-2 mt-2 text-right"
|
||||
positive-class="text-slate-500"
|
||||
negative-class="text-red-700 dark:text-red-400"
|
||||
/>
|
||||
<Currency
|
||||
:value="group.Activity"
|
||||
class="hidden sm:block mt-2"
|
||||
positive-class="text-slate-500"
|
||||
negative-class="text-red-700 dark:text-red-400"
|
||||
/>
|
||||
<Currency
|
||||
:value="group.Available"
|
||||
class="mt-2"
|
||||
positive-class="text-slate-500"
|
||||
negative-class="text-red-700 dark:text-red-400"
|
||||
/>
|
||||
<template
|
||||
v-for="category in GetCategories(group.Name)"
|
||||
:key="category.ID"
|
||||
>
|
||||
<div
|
||||
v-if="getGroupState(group)"
|
||||
class="contents"
|
||||
>
|
||||
<span
|
||||
class="whitespace-nowrap overflow-hidden"
|
||||
>{{ category.Name }}</span>
|
||||
<Currency
|
||||
:value="category.AvailableLastMonth"
|
||||
class="hidden lg:block"
|
||||
/>
|
||||
<Input
|
||||
v-model="category.Assigned"
|
||||
type="number"
|
||||
class="hidden sm:block mx-2 text-right"
|
||||
@input="(evt) => assignedChanged(evt, category)"
|
||||
/>
|
||||
<Currency
|
||||
:value="category.Activity"
|
||||
class="hidden sm:block"
|
||||
/>
|
||||
<Currency
|
||||
:value="accountStore.GetCategoryAvailable(category)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
|
@ -1,25 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
import NewBudget from '../dialogs/NewBudget.vue';
|
||||
import Card from '../components/Card.vue';
|
||||
import RowCard from '../components/RowCard.vue';
|
||||
import { useSessionStore } from '../stores/session';
|
||||
|
||||
const props = defineProps<{
|
||||
budgetid: string,
|
||||
}>();
|
||||
|
||||
const BudgetsList = useSessionStore().BudgetsList;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>Budgets</h1>
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<Card v-for="budget in BudgetsList">
|
||||
<router-link v-bind:to="'/budget/'+budget.ID+'/budgeting'" class="contents">
|
||||
<RowCard
|
||||
v-for="budget in BudgetsList"
|
||||
:key="budget.ID"
|
||||
>
|
||||
<router-link
|
||||
:to="'/budget/'+budget.ID+'/budgeting'"
|
||||
class="contents"
|
||||
>
|
||||
<!--<svg class="w-24"></svg>-->
|
||||
<p class="w-24 text-center text-6xl"></p>
|
||||
<span class="text-lg">{{budget.Name}}{{budget.ID == budgetid ? " *" : ""}}</span>
|
||||
<p class="w-24 text-center text-6xl" />
|
||||
<span class="text-lg">{{ budget.Name
|
||||
}}</span>
|
||||
</router-link>
|
||||
</Card>
|
||||
</RowCard>
|
||||
<NewBudget />
|
||||
</div>
|
||||
</template>
|
||||
|
@ -1,13 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="font-bold" id="content">
|
||||
Willkommen bei Budgeteer, der neuen App für's Budget!
|
||||
</div>
|
||||
<div class="container col-md-4" id="login">
|
||||
<router-link to="/login">Login</router-link> or <router-link to="/login">register</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -29,17 +29,31 @@ function formSubmit(e: MouseEvent) {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Input type="text" v-model="login.user"
|
||||
<Input
|
||||
v-model="login.user"
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48" />
|
||||
<Input type="password" v-model="login.password"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48"
|
||||
/>
|
||||
<Input
|
||||
v-model="login.password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48" />
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48"
|
||||
/>
|
||||
</div>
|
||||
<div>{{ error }}</div>
|
||||
<button type="submit" @click="formSubmit" class="bg-blue-300 rounded-lg p-2 w-48">Login</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-300 rounded-lg p-2 w-48"
|
||||
@click="formSubmit"
|
||||
>
|
||||
Login
|
||||
</button>
|
||||
<p>
|
||||
New user?
|
||||
<router-link to="/register">Register</router-link> instead!
|
||||
<router-link to="/register">
|
||||
Register
|
||||
</router-link> instead!
|
||||
</p>
|
||||
</template>
|
@ -29,20 +29,37 @@ function formSubmit(e: MouseEvent) {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Input type="text" v-model="login.name"
|
||||
<Input
|
||||
v-model="login.name"
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48" />
|
||||
<Input type="text" v-model="login.email"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48"
|
||||
/>
|
||||
<Input
|
||||
v-model="login.email"
|
||||
type="text"
|
||||
placeholder="Email"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48" />
|
||||
<Input type="password" v-model="login.password"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48"
|
||||
/>
|
||||
<Input
|
||||
v-model="login.password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48" />
|
||||
class="border-2 border-black rounded-lg block px-2 my-2 w-48"
|
||||
/>
|
||||
</div>
|
||||
<div>{{ error }}</div>
|
||||
<button type="submit" @click="formSubmit" class="bg-blue-300 rounded-lg p-2 w-48">Register</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-300 rounded-lg p-2 w-48"
|
||||
@click="formSubmit"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
<p>
|
||||
Existing user?
|
||||
<router-link to="/login">Login</router-link> instead!
|
||||
<router-link to="/login">
|
||||
Login
|
||||
</router-link> instead!
|
||||
</p>
|
||||
</template>
|
@ -4,11 +4,13 @@ import { useRouter } from "vue-router";
|
||||
import { DELETE, POST } from "../api";
|
||||
import { useBudgetsStore } from "../stores/budget";
|
||||
import { useSessionStore } from "../stores/session";
|
||||
import Card from "../components/Card.vue";
|
||||
import Button from "../components/Button.vue";
|
||||
import RowCard from "../components/RowCard.vue";
|
||||
import Button from "../components/SimpleButton.vue";
|
||||
import { saveAs } from 'file-saver';
|
||||
import Input from "../components/Input.vue";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const transactionsFile = ref<File | undefined>(undefined);
|
||||
const assignmentsFile = ref<File | undefined>(undefined);
|
||||
|
||||
@ -39,14 +41,11 @@ function deleteBudget() {
|
||||
|
||||
const budgetStore = useSessionStore();
|
||||
budgetStore.Budgets.delete(CurrentBudgetID.value);
|
||||
useRouter().push("/")
|
||||
router.push("/dashboard")
|
||||
};
|
||||
function clearBudget() {
|
||||
POST("/budget/" + CurrentBudgetID.value + "/settings/clear", null)
|
||||
};
|
||||
function cleanNegative() {
|
||||
// <a href="/budget/{{.Budget.ID}}/settings/clean-negative">Fix all historic negative category-balances</a>
|
||||
};
|
||||
function ynabImport() {
|
||||
if (transactionsFile.value == undefined || assignmentsFile.value == undefined)
|
||||
return
|
||||
@ -72,53 +71,90 @@ function ynabExport() {
|
||||
saveAs(blob, timeStamp + " " + CurrentBudgetName.value + " - Transactions.tsv");
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Danger Zone</h1>
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<Card class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">Clear Budget</h2>
|
||||
<p>This removes transactions and assignments to start from scratch. Accounts and categories are kept. Not undoable!</p>
|
||||
<RowCard class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">
|
||||
Clear Budget
|
||||
</h2>
|
||||
<p>
|
||||
This removes transactions and assignments to start from
|
||||
scratch. Accounts and categories are kept. Not undoable!
|
||||
</p>
|
||||
|
||||
<Button class="bg-red-500 py-2" @click="clearBudget">Clear budget</Button>
|
||||
</Card>
|
||||
<Card class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">Delete Budget</h2>
|
||||
<p>This deletes the whole bugdet including all transactions, assignments, accounts and categories. Not undoable!</p>
|
||||
<Button class="bg-red-500 py-2" @click="deleteBudget">Delete budget</button>
|
||||
</Card>
|
||||
<Card class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">Fix all historic negative category-balances</h2>
|
||||
<p>This restores YNABs functionality, that would substract any overspent categories' balances from next months inflows.</p>
|
||||
<Button class="bg-orange-500 py-2" @click="cleanNegative">Fix negative</button>
|
||||
</Card>
|
||||
<Card class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">Import YNAB Budget</h2>
|
||||
<Button
|
||||
class="bg-red-500 py-2"
|
||||
@click="clearBudget"
|
||||
>
|
||||
Clear budget
|
||||
</Button>
|
||||
</RowCard>
|
||||
<RowCard class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">
|
||||
Delete Budget
|
||||
</h2>
|
||||
<p>
|
||||
This deletes the whole bugdet including all transactions,
|
||||
assignments, accounts and categories. Not undoable!
|
||||
</p>
|
||||
<Button
|
||||
class="bg-red-500 py-2"
|
||||
@click="deleteBudget"
|
||||
>
|
||||
Delete budget
|
||||
</Button>
|
||||
</RowCard>
|
||||
<RowCard class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">
|
||||
Import YNAB Budget
|
||||
</h2>
|
||||
|
||||
<div>
|
||||
<label for="transactions_file">
|
||||
Transaktionen:
|
||||
<input type="file" @change="gotTransactions" accept="text/*" />
|
||||
<input
|
||||
type="file"
|
||||
accept="text/*"
|
||||
@change="gotTransactions"
|
||||
>
|
||||
</label>
|
||||
<br />
|
||||
<br>
|
||||
<label for="assignments_file">
|
||||
Budget:
|
||||
<input type="file" @change="gotAssignments" accept="text/*" />
|
||||
<input
|
||||
type="file"
|
||||
accept="text/*"
|
||||
@change="gotAssignments"
|
||||
>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<Button class="bg-blue-500 py-2" :disabled="filesIncomplete" @click="ynabImport">Importieren</Button>
|
||||
</Card>
|
||||
<Card class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">Export as YNAB TSV</h2>
|
||||
<Button
|
||||
class="bg-blue-500 py-2"
|
||||
:disabled="filesIncomplete"
|
||||
@click="ynabImport"
|
||||
>
|
||||
Importieren
|
||||
</Button>
|
||||
</RowCard>
|
||||
<RowCard class="flex-col p-3">
|
||||
<h2 class="text-lg font-bold">
|
||||
Export as YNAB TSV
|
||||
</h2>
|
||||
|
||||
<div class="flex flex-row">
|
||||
<Button class="bg-blue-500 py-2" @click="ynabExport">Export</Button>
|
||||
<Button
|
||||
class="bg-blue-500 py-2"
|
||||
@click="ynabExport"
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</RowCard>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
24
web/src/pages/WelcomePage.vue
Normal file
24
web/src/pages/WelcomePage.vue
Normal file
@ -0,0 +1,24 @@
|
||||
<script lang="ts" setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
id="content"
|
||||
class="font-bold"
|
||||
>
|
||||
Willkommen bei Budgeteer, der neuen App für's Budget!
|
||||
</div>
|
||||
<div
|
||||
id="login"
|
||||
class="container col-md-4"
|
||||
>
|
||||
<router-link to="/login">
|
||||
Login
|
||||
</router-link> or
|
||||
<router-link to="/login">
|
||||
register
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -1,4 +1,9 @@
|
||||
import { PiniaPluginContext, StoreGeneric, _ActionsTree, _StoreOnActionListenerContext } from 'pinia';
|
||||
import {
|
||||
PiniaPluginContext,
|
||||
StoreGeneric,
|
||||
_ActionsTree,
|
||||
_StoreOnActionListenerContext,
|
||||
} from "pinia";
|
||||
|
||||
const cloneDeep = <T>(obj: T): T => {
|
||||
try {
|
||||
@ -8,9 +13,9 @@ const cloneDeep = <T>(obj: T): T => {
|
||||
}
|
||||
};
|
||||
const formatTime = (date = new Date()) => {
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
const seconds = date.getSeconds().toString().padStart(2, '0');
|
||||
const hours = date.getHours().toString().padStart(2, "0");
|
||||
const minutes = date.getMinutes().toString().padStart(2, "0");
|
||||
const seconds = date.getSeconds().toString().padStart(2, "0");
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
};
|
||||
@ -18,12 +23,16 @@ const formatTime = (date = new Date()) => {
|
||||
export interface PiniaLoggerOptions {
|
||||
disabled?: boolean;
|
||||
expanded?: boolean;
|
||||
showDuration?: boolean
|
||||
showDuration?: boolean;
|
||||
showStoreName?: boolean;
|
||||
logErrors?: boolean;
|
||||
}
|
||||
|
||||
export type PiniaActionListenerContext = _StoreOnActionListenerContext<StoreGeneric, string, _ActionsTree>;
|
||||
export type PiniaActionListenerContext = _StoreOnActionListenerContext<
|
||||
StoreGeneric,
|
||||
string,
|
||||
_ActionsTree
|
||||
>;
|
||||
|
||||
const defaultOptions: PiniaLoggerOptions = {
|
||||
logErrors: true,
|
||||
@ -33,7 +42,9 @@ const defaultOptions: PiniaLoggerOptions = {
|
||||
showDuration: false,
|
||||
};
|
||||
|
||||
export const PiniaLogger = (config = defaultOptions) => (ctx: PiniaPluginContext) => {
|
||||
export const PiniaLogger =
|
||||
(config = defaultOptions) =>
|
||||
(ctx: PiniaPluginContext) => {
|
||||
const options = {
|
||||
...defaultOptions,
|
||||
...config,
|
||||
@ -41,28 +52,43 @@ export const PiniaLogger = (config = defaultOptions) => (ctx: PiniaPluginContext
|
||||
|
||||
if (options.disabled) return;
|
||||
|
||||
|
||||
ctx.store.$onAction((action: PiniaActionListenerContext) => {
|
||||
const startTime = Date.now();
|
||||
const prevState = cloneDeep(ctx.store.$state);
|
||||
|
||||
const log = (isError?: boolean, error?: any) => {
|
||||
const endTime = Date.now();
|
||||
const duration = endTime - startTime + 'ms';
|
||||
const duration = endTime - startTime + "ms";
|
||||
const nextState = cloneDeep(ctx.store.$state);
|
||||
const storeName = action.store.$id;
|
||||
const title = `${formatTime()} action 🍍 ${options.showStoreName ? `[${storeName}] ` : ''}${action.name} ${isError ? `failed after ` : ''}in ${duration}`;
|
||||
const title = `${formatTime()} action 🍍 ${
|
||||
options.showStoreName ? `[${storeName}] ` : ""
|
||||
}${action.name} ${
|
||||
isError ? `failed after ` : ""
|
||||
}in ${duration}`;
|
||||
|
||||
console[options.expanded ? 'group' : 'groupCollapsed'](`%c${title}`, `font-weight: bold; ${isError ? 'color: #ed4981;' : ''}`);
|
||||
console.log('%cprev state', 'font-weight: bold; color: grey;', prevState);
|
||||
console.log('%caction', 'font-weight: bold; color: #69B7FF;', {
|
||||
console[options.expanded ? "group" : "groupCollapsed"](
|
||||
`%c${title}`,
|
||||
`font-weight: bold; ${isError ? "color: #ed4981;" : ""}`
|
||||
);
|
||||
console.log(
|
||||
"%cprev state",
|
||||
"font-weight: bold; color: grey;",
|
||||
prevState
|
||||
);
|
||||
console.log("%caction", "font-weight: bold; color: #69B7FF;", {
|
||||
type: action.name,
|
||||
args: action.args.length > 0 ? { ...action.args } : undefined,
|
||||
args:
|
||||
action.args.length > 0 ? { ...action.args } : undefined,
|
||||
...(options.showStoreName && { store: action.store.$id }),
|
||||
...(options.showDuration && { duration }),
|
||||
...(isError && { error }),
|
||||
});
|
||||
console.log('%cnext state', 'font-weight: bold; color: #4caf50;', nextState);
|
||||
console.log(
|
||||
"%cnext state",
|
||||
"font-weight: bold; color: #4caf50;",
|
||||
nextState
|
||||
);
|
||||
console.groupEnd();
|
||||
};
|
||||
|
||||
|
@ -1,29 +1,88 @@
|
||||
import { createRouter, createWebHistory, RouteLocationNormalized } from 'vue-router'
|
||||
import Dashboard from '../pages/Dashboard.vue';
|
||||
import Login from '../pages/Login.vue';
|
||||
import Index from '../pages/Index.vue';
|
||||
import Register from '../pages/Register.vue';
|
||||
import Account from '@/pages/Account.vue';
|
||||
import Settings from '../pages/Settings.vue';
|
||||
import Budgeting from '../pages/Budgeting.vue';
|
||||
import BudgetSidebar from '../pages/BudgetSidebar.vue';
|
||||
import {
|
||||
createRouter,
|
||||
createWebHistory,
|
||||
RouteLocationNormalized,
|
||||
} from "vue-router";
|
||||
import Account from "../pages/Account.vue";
|
||||
import AllAccounts from "../pages/AllAccounts.vue";
|
||||
import Budgeting from "../pages/Budgeting.vue";
|
||||
import BudgetSidebar from "../pages/BudgetSidebar.vue";
|
||||
import Dashboard from "../pages/Dashboard.vue";
|
||||
import Login from "../pages/Login.vue";
|
||||
import Register from "../pages/Register.vue";
|
||||
import Settings from "../pages/Settings.vue";
|
||||
import WelcomePage from "../pages/WelcomePage.vue";
|
||||
|
||||
const routes = [
|
||||
{ path: "/", name: "Index", component: Index },
|
||||
{ path: "/dashboard", name: "Dashboard", component: Dashboard },
|
||||
{ path: "/login", name: "Login", component: Login },
|
||||
{ path: "/register", name: "Register", component: Register },
|
||||
{ path: "/budget/:budgetid/budgeting", name: "Budget", redirect: (to : RouteLocationNormalized) =>
|
||||
'/budget/' + to.params.budgetid + '/budgeting/' + new Date().getFullYear() + '/' + new Date().getMonth()
|
||||
{
|
||||
path: "/",
|
||||
name: "Index",
|
||||
component: WelcomePage,
|
||||
meta: { hideForAuth: true },
|
||||
},
|
||||
{ path: "/budget/:budgetid/budgeting/:year/:month", name: "Budget with date", components: { default: Budgeting, sidebar: BudgetSidebar }, props: true },
|
||||
{ path: "/budget/:budgetid/Settings", name: "Budget Settings", components: { default: Settings, sidebar: BudgetSidebar }, props: true },
|
||||
{ path: "/budget/:budgetid/account/:accountid", name: "Account", components: { default: Account, sidebar: BudgetSidebar }, props: true },
|
||||
]
|
||||
{
|
||||
path: "/dashboard",
|
||||
name: "Dashboard",
|
||||
component: Dashboard,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
component: Login,
|
||||
meta: { hideForAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/register",
|
||||
name: "Register",
|
||||
component: Register,
|
||||
meta: { hideForAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/budget/:budgetid/budgeting",
|
||||
name: "Budget",
|
||||
redirect: (to: RouteLocationNormalized) =>
|
||||
"/budget/" +
|
||||
to.params.budgetid +
|
||||
"/budgeting/" +
|
||||
new Date().getFullYear() +
|
||||
"/" +
|
||||
new Date().getMonth(),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/budget/:budgetid/budgeting/:year/:month",
|
||||
name: "Budget with date",
|
||||
components: { default: Budgeting, sidebar: BudgetSidebar },
|
||||
props: true,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/budget/:budgetid/Settings",
|
||||
name: "Budget Settings",
|
||||
components: { default: Settings, sidebar: BudgetSidebar },
|
||||
props: true,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/budget/:budgetid/problematic-transactions",
|
||||
name: "Problematic Transactions",
|
||||
components: { default: AllAccounts, sidebar: BudgetSidebar },
|
||||
props: true,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/budget/:budgetid/account/:accountid",
|
||||
name: "Account",
|
||||
components: { default: Account, sidebar: BudgetSidebar },
|
||||
props: true,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
})
|
||||
});
|
||||
|
||||
export default router
|
||||
export default router;
|
||||
|
@ -1,37 +1,50 @@
|
||||
import { defineStore } from "pinia"
|
||||
import { defineStore } from "pinia";
|
||||
import { GET, POST } from "../api";
|
||||
import { useBudgetsStore } from "./budget";
|
||||
import { useSessionStore } from "./session";
|
||||
import { useTransactionsStore } from "./transactions";
|
||||
import { Transaction, useTransactionsStore } from "./transactions";
|
||||
|
||||
interface State {
|
||||
Accounts: Map<string, Account>
|
||||
CurrentAccountID: string | null
|
||||
Categories: Map<string, Category>
|
||||
Months: Map<number, Map<number, Map<string, Category>>>
|
||||
Assignments: []
|
||||
Accounts: Map<string, Account>;
|
||||
CurrentAccountID: string | null;
|
||||
Categories: Map<string, Category>;
|
||||
Months: Map<number, Map<number, Map<string, Category>>>;
|
||||
Available: number,
|
||||
OverspentLastMonth: number,
|
||||
Assignments: [];
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
ID: string
|
||||
Name: string
|
||||
OnBudget: boolean
|
||||
IsOpen: boolean
|
||||
ClearedBalance: number
|
||||
WorkingBalance: number
|
||||
ReconciledBalance: number
|
||||
Transactions: string[]
|
||||
LastReconciled: Date
|
||||
ID: string;
|
||||
Name: string;
|
||||
OnBudget: boolean;
|
||||
IsOpen: boolean;
|
||||
ClearedBalance: number;
|
||||
WorkingBalance: number;
|
||||
ReconciledBalance: number;
|
||||
Transactions: string[];
|
||||
LastReconciled: NullDate;
|
||||
}
|
||||
|
||||
interface NullDate {
|
||||
Valid: boolean;
|
||||
Time: Date;
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
ID: string
|
||||
Group: string
|
||||
Name: string
|
||||
AvailableLastMonth: number
|
||||
Assigned: number
|
||||
Activity: number
|
||||
Available: number
|
||||
ID: string;
|
||||
Group: string;
|
||||
Name: string;
|
||||
AvailableLastMonth: number;
|
||||
Assigned: number;
|
||||
Activity: number;
|
||||
}
|
||||
|
||||
interface BudgetedAmounts {
|
||||
Assigned: number,
|
||||
Deassigned: number,
|
||||
Spent: number,
|
||||
Income: number,
|
||||
}
|
||||
|
||||
export const useAccountStore = defineStore("budget/account", {
|
||||
@ -39,6 +52,8 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
Accounts: new Map<string, Account>(),
|
||||
CurrentAccountID: null,
|
||||
Months: new Map<number, Map<number, Map<string, Category>>>(),
|
||||
Available: 0,
|
||||
OverspentLastMonth: 0,
|
||||
Categories: new Map<string, Category>(),
|
||||
Assignments: [],
|
||||
}),
|
||||
@ -49,7 +64,50 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
AllCategoriesForMonth: (state) => (year: number, month: number) => {
|
||||
const yearMap = state.Months.get(year);
|
||||
const monthMap = yearMap?.get(month);
|
||||
return [...monthMap?.values() || []];
|
||||
return [...(monthMap?.values() || [])];
|
||||
},
|
||||
GetCategoryAvailable(state) {
|
||||
return (category: Category): number => {
|
||||
return (
|
||||
category.AvailableLastMonth +
|
||||
category.Assigned +
|
||||
category.Activity
|
||||
);
|
||||
};
|
||||
},
|
||||
GetIncomeCategoryID(state) {
|
||||
const budget = useBudgetsStore();
|
||||
return budget.CurrentBudget?.IncomeCategoryID;
|
||||
},
|
||||
GetBudgeted(state) {
|
||||
return (year: number, month: number) : BudgetedAmounts => {
|
||||
const IncomeCategoryID = this.GetIncomeCategoryID;
|
||||
if (IncomeCategoryID == null) return {Spent: 0, Income: 0, Assigned: 0, Deassigned: 0};
|
||||
|
||||
const categories = this.AllCategoriesForMonth(year, month);
|
||||
|
||||
let assigned = 0, deassigned = 0;
|
||||
let spent = 0, income = 0;
|
||||
for (const category of categories) {
|
||||
if (category.ID == IncomeCategoryID)
|
||||
continue;
|
||||
|
||||
if(category.Activity > 0)
|
||||
income += category.Activity;
|
||||
else
|
||||
spent += category.Activity;
|
||||
if(category.Assigned > 0)
|
||||
assigned += category.Assigned;
|
||||
else
|
||||
deassigned += category.Assigned;
|
||||
}
|
||||
return {
|
||||
Assigned: assigned,
|
||||
Deassigned: deassigned,
|
||||
Spent: spent,
|
||||
Income: income
|
||||
};
|
||||
};
|
||||
},
|
||||
CategoryGroupsForMonth(state) {
|
||||
return (year: number, month: number) => {
|
||||
@ -57,75 +115,119 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
const categoryGroups = [];
|
||||
let prev = undefined;
|
||||
for (const category of categories) {
|
||||
if (category.Group != prev)
|
||||
categoryGroups.push({
|
||||
//if (category.ID == this.GetIncomeCategoryID) continue;
|
||||
|
||||
if (prev == undefined || category.Group != prev.Name) {
|
||||
prev = {
|
||||
Name: category.Group,
|
||||
Expand: category.Group != "Hidden Categories",
|
||||
Available: this.GetCategoryAvailable(category),
|
||||
AvailableLastMonth: category.AvailableLastMonth,
|
||||
Activity: category.Activity,
|
||||
Assigned: category.Assigned,
|
||||
};
|
||||
categoryGroups.push({
|
||||
...prev,
|
||||
Expand: prev.Name != "Hidden Categories",
|
||||
});
|
||||
prev = category.Group;
|
||||
} else {
|
||||
categoryGroups[categoryGroups.length - 1].Available +=
|
||||
this.GetCategoryAvailable(category);
|
||||
categoryGroups[
|
||||
categoryGroups.length - 1
|
||||
].AvailableLastMonth += category.AvailableLastMonth;
|
||||
categoryGroups[categoryGroups.length - 1].Activity +=
|
||||
category.Activity;
|
||||
categoryGroups[categoryGroups.length - 1].Assigned +=
|
||||
category.Assigned;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return categoryGroups;
|
||||
}
|
||||
};
|
||||
},
|
||||
CategoriesForMonthAndGroup(state) {
|
||||
return (year: number, month: number, group: string) => {
|
||||
const categories = this.AllCategoriesForMonth(year, month);
|
||||
return categories.filter(x => x.Group == group);
|
||||
}
|
||||
return categories.filter((x) => x.Group == group);
|
||||
};
|
||||
},
|
||||
GetAccount(state) {
|
||||
return (accountid: string) => {
|
||||
return this.Accounts.get(accountid);
|
||||
}
|
||||
};
|
||||
},
|
||||
CurrentAccount(state): Account | undefined {
|
||||
if (state.CurrentAccountID == null)
|
||||
return undefined;
|
||||
if (state.CurrentAccountID == null) return undefined;
|
||||
|
||||
return this.GetAccount(state.CurrentAccountID);
|
||||
},
|
||||
OnBudgetAccounts(state) {
|
||||
return [...state.Accounts.values()].filter(x => x.OnBudget);
|
||||
return [...state.Accounts.values()].filter((x) => x.OnBudget);
|
||||
},
|
||||
OnBudgetAccountsBalance(state): number {
|
||||
return this.OnBudgetAccounts.reduce((prev, curr) => prev + Number(curr.ClearedBalance), 0);
|
||||
return this.OnBudgetAccounts.reduce(
|
||||
(prev, curr) => prev + Number(curr.ClearedBalance),
|
||||
0
|
||||
);
|
||||
},
|
||||
OffBudgetAccounts(state) {
|
||||
return [...state.Accounts.values()].filter(x => !x.OnBudget);
|
||||
return [...state.Accounts.values()].filter((x) => !x.OnBudget);
|
||||
},
|
||||
OffBudgetAccountsBalance(state): number {
|
||||
return this.OffBudgetAccounts.reduce((prev, curr) => prev + Number(curr.ClearedBalance), 0);
|
||||
return this.OffBudgetAccounts.reduce(
|
||||
(prev, curr) => prev + Number(curr.ClearedBalance),
|
||||
0
|
||||
);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async SetCurrentAccount(budgetid: string, accountid: string) {
|
||||
if (budgetid == null)
|
||||
return;
|
||||
if (budgetid == null) return;
|
||||
|
||||
this.CurrentAccountID = accountid;
|
||||
|
||||
if (accountid == null)
|
||||
return;
|
||||
if (accountid == null) return;
|
||||
const account = this.GetAccount(accountid)!;
|
||||
useSessionStore().setTitle(account.Name);
|
||||
await this.FetchAccount(account);
|
||||
},
|
||||
async FetchAccount(account: Account) {
|
||||
const result = await GET("/account/" + account.ID + "/transactions");
|
||||
const result = await GET(
|
||||
"/account/" + account.ID + "/transactions"
|
||||
);
|
||||
const response = await result.json();
|
||||
const transactionsStore = useTransactionsStore()
|
||||
const transactions = transactionsStore.AddTransactions(response.Transactions);
|
||||
account.Transactions = transactions;
|
||||
const transactionsStore = useTransactionsStore();
|
||||
transactionsStore.AddTransactions(
|
||||
response.Transactions
|
||||
);
|
||||
account.Transactions = response.Transactions.map((x : Transaction) =>x.ID);
|
||||
},
|
||||
async FetchMonthBudget(budgetid: string, year: number, month: number) {
|
||||
const result = await GET("/budget/" + budgetid + "/" + year + "/" + (month+1));
|
||||
const result = await GET(
|
||||
"/budget/" + budgetid + "/" + year + "/" + (month + 1)
|
||||
);
|
||||
const response = await result.json();
|
||||
if (response.Categories == undefined || response.Categories.length <= 0)
|
||||
if (
|
||||
response.Categories == undefined ||
|
||||
response.Categories.length <= 0
|
||||
)
|
||||
return;
|
||||
this.addCategoriesForMonth(year, month, response.Categories);
|
||||
this.addCategoriesForMonth(year, month, response.Categories, response.AvailableBalance, response.OverspentLastMonth);
|
||||
},
|
||||
async EditAccount(accountid: string, name: string, onBudget: boolean, isOpen: boolean) {
|
||||
const result = await POST("/account/" + accountid, JSON.stringify({ name: name, onBudget: onBudget, isOpen: isOpen }));
|
||||
async EditAccount(
|
||||
accountid: string,
|
||||
name: string,
|
||||
onBudget: boolean,
|
||||
isOpen: boolean
|
||||
) {
|
||||
const result = await POST(
|
||||
"/account/" + accountid,
|
||||
JSON.stringify({
|
||||
name: name,
|
||||
onBudget: onBudget,
|
||||
isOpen: isOpen,
|
||||
})
|
||||
);
|
||||
const response = await result.json();
|
||||
useBudgetsStore().MergeBudgetingData(response);
|
||||
|
||||
@ -133,21 +235,32 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
this.Accounts.delete(accountid);
|
||||
}
|
||||
},
|
||||
addCategoriesForMonth(year: number, month: number, categories: Category[]): void {
|
||||
addCategoriesForMonth(
|
||||
year: number,
|
||||
month: number,
|
||||
categories: Category[],
|
||||
available: number,
|
||||
overspentLastMonth: number,
|
||||
): void {
|
||||
this.$patch((state) => {
|
||||
const yearMap = state.Months.get(year) || new Map<number, Map<string, Category>>();
|
||||
const monthMap = yearMap.get(month) || new Map<string, Category>();
|
||||
const yearMap =
|
||||
state.Months.get(year) ||
|
||||
new Map<number, Map<string, Category>>();
|
||||
const monthMap =
|
||||
yearMap.get(month) || new Map<string, Category>();
|
||||
for (const category of categories) {
|
||||
monthMap.set(category.ID, category);
|
||||
}
|
||||
|
||||
yearMap.set(month, monthMap);
|
||||
state.Months.set(year, yearMap);
|
||||
|
||||
state.Available = available;
|
||||
state.OverspentLastMonth = overspentLastMonth;
|
||||
});
|
||||
},
|
||||
logout() {
|
||||
this.$reset()
|
||||
this.$reset();
|
||||
},
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
});
|
||||
|
@ -4,17 +4,16 @@ import { useAccountStore } from "./budget-account";
|
||||
import { Budget, useSessionStore } from "./session";
|
||||
|
||||
interface State {
|
||||
CurrentBudgetID: string | null,
|
||||
CurrentBudgetID: string | null;
|
||||
}
|
||||
|
||||
export const useBudgetsStore = defineStore('budget', {
|
||||
export const useBudgetsStore = defineStore("budget", {
|
||||
state: (): State => ({
|
||||
CurrentBudgetID: null,
|
||||
}),
|
||||
getters: {
|
||||
CurrentBudget(): Budget | undefined {
|
||||
if (this.CurrentBudgetID == null)
|
||||
return undefined;
|
||||
if (this.CurrentBudgetID == null) return undefined;
|
||||
|
||||
const sessionStore = useSessionStore();
|
||||
return sessionStore.Budgets.get(this.CurrentBudgetID);
|
||||
@ -27,7 +26,7 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
ImportYNAB(formData: FormData) {
|
||||
return POST(
|
||||
"/budget/" + this.CurrentBudgetID + "/import/ynab",
|
||||
formData,
|
||||
formData
|
||||
);
|
||||
},
|
||||
async NewBudget(budgetName: string): Promise<void> {
|
||||
@ -43,8 +42,7 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
async SetCurrentBudget(budgetid: string): Promise<void> {
|
||||
this.CurrentBudgetID = budgetid;
|
||||
|
||||
if (budgetid == null)
|
||||
return
|
||||
if (budgetid == null) return;
|
||||
|
||||
await this.FetchBudget(budgetid);
|
||||
},
|
||||
@ -58,12 +56,15 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
for (const account of response.Accounts || []) {
|
||||
const existingAccount = accounts.Accounts.get(account.ID);
|
||||
account.Transactions = existingAccount?.Transactions ?? [];
|
||||
account.LastReconciled = new Date(account.LastReconciled);
|
||||
if (account.LastReconciled.Valid)
|
||||
account.LastReconciled.Time = new Date(
|
||||
account.LastReconciled.Time
|
||||
);
|
||||
accounts.Accounts.set(account.ID, account);
|
||||
}
|
||||
for (const category of response.Categories || []) {
|
||||
accounts.Categories.set(category.ID, category);
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
@ -1,31 +1,41 @@
|
||||
import { StorageSerializers, useStorage } from '@vueuse/core';
|
||||
import { defineStore } from 'pinia'
|
||||
import { POST } from '../api';
|
||||
import { StorageSerializers, useStorage } from "@vueuse/core";
|
||||
import { defineStore } from "pinia";
|
||||
import { POST } from "../api";
|
||||
|
||||
interface State {
|
||||
Session: Session | null
|
||||
Budgets: Map<string, Budget>,
|
||||
Session: Session | null;
|
||||
Budgets: Map<string, Budget>;
|
||||
}
|
||||
|
||||
interface Session {
|
||||
Token: string
|
||||
User: string
|
||||
Token: string;
|
||||
User: string;
|
||||
}
|
||||
|
||||
export interface Budget {
|
||||
ID: string
|
||||
Name: string
|
||||
AvailableBalance: number
|
||||
ID: string;
|
||||
Name: string;
|
||||
AvailableBalance: number;
|
||||
IncomeCategoryID: string;
|
||||
}
|
||||
|
||||
export const useSessionStore = defineStore('session', {
|
||||
export const useSessionStore = defineStore("session", {
|
||||
state: () => ({
|
||||
Session: useStorage<Session | null>('session', null, undefined, { serializer: StorageSerializers.object }),
|
||||
Budgets: useStorage<Map<string, Budget>>('budgets', new Map<string, Budget>(), undefined, { serializer: StorageSerializers.map }),
|
||||
Session: useStorage<Session | null>("session", null, undefined, {
|
||||
serializer: StorageSerializers.object,
|
||||
}),
|
||||
Budgets: useStorage<Map<string, Budget>>(
|
||||
"budgets",
|
||||
new Map<string, Budget>(),
|
||||
undefined,
|
||||
{ serializer: StorageSerializers.map }
|
||||
),
|
||||
}),
|
||||
getters: {
|
||||
BudgetsList: (state) => [...state.Budgets.values()],
|
||||
AuthHeaders: (state) => ({'Authorization': 'Bearer ' + state.Session?.Token}),
|
||||
AuthHeaders: (state) => ({
|
||||
Authorization: "Bearer " + state.Session?.Token,
|
||||
}),
|
||||
LoggedIn: (state) => state.Session != null,
|
||||
},
|
||||
actions: {
|
||||
@ -36,7 +46,7 @@ export const useSessionStore = defineStore('session', {
|
||||
this.Session = {
|
||||
User: x.User,
|
||||
Token: x.Token,
|
||||
}
|
||||
};
|
||||
for (const budget of x.Budgets) {
|
||||
this.Budgets.set(budget.ID, budget);
|
||||
}
|
||||
@ -48,7 +58,10 @@ export const useSessionStore = defineStore('session', {
|
||||
return result;
|
||||
},
|
||||
async register(login: any) {
|
||||
const response = await POST("/user/register", JSON.stringify(login));
|
||||
const response = await POST(
|
||||
"/user/register",
|
||||
JSON.stringify(login)
|
||||
);
|
||||
const result = await response.json();
|
||||
this.loginSuccess(result);
|
||||
return result;
|
||||
@ -57,5 +70,5 @@ export const useSessionStore = defineStore('session', {
|
||||
this.Session = null;
|
||||
this.Budgets.clear();
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
@ -2,17 +2,17 @@ import { useStorage } from "@vueuse/core";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
interface State {
|
||||
Menu: MenuSettings
|
||||
Menu: MenuSettings;
|
||||
}
|
||||
|
||||
interface MenuSettings {
|
||||
Show: boolean | null,
|
||||
Expand: boolean | null,
|
||||
Show: boolean | null;
|
||||
Expand: boolean | null;
|
||||
}
|
||||
|
||||
export const useSettingsStore = defineStore('settings', {
|
||||
export const useSettingsStore = defineStore("settings", {
|
||||
state: () => ({
|
||||
Menu: useStorage<MenuSettings>('settings', {
|
||||
Menu: useStorage<MenuSettings>("settings", {
|
||||
Show: null,
|
||||
Expand: false,
|
||||
}),
|
||||
@ -24,5 +24,5 @@ export const useSettingsStore = defineStore('settings', {
|
||||
toggleMenuSize() {
|
||||
this.Menu.Expand = !this.Menu.Expand;
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
@ -1,83 +1,131 @@
|
||||
import { defineStore } from "pinia"
|
||||
import { POST } from "../api";
|
||||
import { defineStore } from "pinia";
|
||||
import { GET, POST } from "../api";
|
||||
import { formatDate, groupBy } from "../date";
|
||||
import { useBudgetsStore } from "./budget";
|
||||
import { useAccountStore } from "./budget-account";
|
||||
|
||||
interface State {
|
||||
Transactions: Map<string, Transaction>
|
||||
Reconciling: boolean
|
||||
Transactions: Map<string, Transaction>;
|
||||
Reconciling: boolean;
|
||||
ProblematicTransactions: Array<string>;
|
||||
FilteredTransactions: Array<string>;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
ID: string
|
||||
Date: Date
|
||||
TransferAccount: string
|
||||
CategoryGroup: string
|
||||
Category: string
|
||||
CategoryID: string | undefined
|
||||
Memo: string
|
||||
Status: string
|
||||
GroupID: string
|
||||
Payee: string
|
||||
PayeeID: string | undefined
|
||||
Amount: number
|
||||
Reconciled: boolean
|
||||
ID: string;
|
||||
Date: Date;
|
||||
TransferAccount: string;
|
||||
CategoryGroup: string;
|
||||
Category: string;
|
||||
CategoryID: string | null;
|
||||
Memo: string;
|
||||
Status: string;
|
||||
GroupID: string;
|
||||
Payee: string;
|
||||
PayeeID: string | null;
|
||||
Amount: number;
|
||||
Reconciled: boolean;
|
||||
Account: string;
|
||||
AccountID: string;
|
||||
}
|
||||
|
||||
export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
state: (): State => ({
|
||||
Transactions: new Map<string, Transaction>(),
|
||||
Reconciling: false,
|
||||
ProblematicTransactions: new Array<string>(),
|
||||
FilteredTransactions: new Array<string>(),
|
||||
}),
|
||||
getters: {
|
||||
ReconcilingBalance(state): number {
|
||||
const accountsStore = useAccountStore()
|
||||
let reconciledBalance = accountsStore.CurrentAccount!.ReconciledBalance;
|
||||
const accountsStore = useAccountStore();
|
||||
let reconciledBalance =
|
||||
accountsStore.CurrentAccount!.ReconciledBalance;
|
||||
for (const transaction of this.TransactionsList) {
|
||||
if (transaction.Reconciled)
|
||||
reconciledBalance += transaction.Amount;
|
||||
}
|
||||
return reconciledBalance;
|
||||
},
|
||||
TransactionsList(state): Transaction[] {
|
||||
const accountsStore = useAccountStore()
|
||||
return accountsStore.CurrentAccount!.Transactions.map(x => {
|
||||
return this.Transactions.get(x)!
|
||||
});
|
||||
TransactionsByDate(state) : Record<string, Transaction[]>|undefined{
|
||||
const accountsStore = useAccountStore();
|
||||
const account = accountsStore.CurrentAccount;
|
||||
if(account === undefined)
|
||||
return undefined;
|
||||
const allTransactions = account!.Transactions.map(x => this.Transactions.get(x) ?? {} as Transaction);
|
||||
return groupBy(allTransactions, x => formatDate(x.Date));
|
||||
},
|
||||
TransactionsList(state) : Transaction[] {
|
||||
const accountsStore = useAccountStore();
|
||||
const accountID = accountsStore.CurrentAccountID;
|
||||
const allTransactions = [...this.Transactions.values()];
|
||||
return allTransactions.filter(x => x.AccountID == accountID);
|
||||
},
|
||||
ProblematicTransactionsList(state) : Transaction[] {
|
||||
return [...state.ProblematicTransactions.map(x => state.Transactions!.get(x)!)];
|
||||
},
|
||||
FilteredTransactionsList(state) : Transaction[] {
|
||||
return [...state.FilteredTransactions.map(x => state.Transactions!.get(x)!)];
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
AddTransactions(transactions: Array<Transaction>) {
|
||||
const transactionIds = [] as Array<string>;
|
||||
this.$patch(() => {
|
||||
for (const transaction of transactions) {
|
||||
transaction.Date = new Date(transaction.Date);
|
||||
this.Transactions.set(transaction.ID, transaction);
|
||||
transactionIds.push(transaction.ID);
|
||||
}
|
||||
});
|
||||
return transactionIds;
|
||||
},
|
||||
SetReconciledForAllTransactions(value: boolean) {
|
||||
for (const transaction of this.TransactionsList) {
|
||||
if (transaction.Status == "Reconciled")
|
||||
continue;
|
||||
if (transaction.Status == "Reconciled") continue;
|
||||
|
||||
transaction.Reconciled = value;
|
||||
}
|
||||
},
|
||||
async GetProblematicTransactions() {
|
||||
const budgetStore = useBudgetsStore();
|
||||
const result = await GET("/budget/" + budgetStore.CurrentBudgetID + "/problematic-transactions");
|
||||
const response = await result.json();
|
||||
const transactions = response.Transactions ?? [];
|
||||
this.AddTransactions(transactions);
|
||||
this.ProblematicTransactions = [...transactions?.map((x : Transaction) => x.ID)];
|
||||
},
|
||||
async GetFilteredTransactions(accountID : string | null, categoryID : string | null, payeeID : string | null, fromDate : string, toDate : string) {
|
||||
const budgetStore = useBudgetsStore();
|
||||
const payload = JSON.stringify({
|
||||
categoryId: categoryID,
|
||||
payeeId: payeeID,
|
||||
accountId: accountID,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
});
|
||||
const result = await POST("/budget/" + budgetStore.CurrentBudgetID + "/filtered-transactions", payload);
|
||||
const response = await result.json();
|
||||
const transactions = response.Transactions ?? [];
|
||||
this.AddTransactions(transactions);
|
||||
this.FilteredTransactions = [...transactions.map((x : Transaction) => x.ID)];
|
||||
},
|
||||
async SubmitReconcilation(reconciliationTransactionAmount: number) {
|
||||
const accountsStore = useAccountStore()
|
||||
const accountsStore = useAccountStore();
|
||||
const account = accountsStore.CurrentAccount!;
|
||||
const reconciledTransactions = this.TransactionsList.filter(x => x.Reconciled);
|
||||
const reconciledTransactions = this.TransactionsList.filter(
|
||||
(x) => x.Reconciled
|
||||
);
|
||||
for (const transaction of reconciledTransactions) {
|
||||
account.ReconciledBalance += transaction.Amount;
|
||||
transaction.Status = "Reconciled";
|
||||
transaction.Reconciled = false;
|
||||
}
|
||||
const result = await POST("/account/" + accountsStore.CurrentAccountID + "/reconcile", JSON.stringify({
|
||||
transactionIDs: reconciledTransactions.map(x => x.ID),
|
||||
reconciliationTransactionAmount: reconciliationTransactionAmount.toString(),
|
||||
}));
|
||||
const result = await POST(
|
||||
"/account/" + accountsStore.CurrentAccountID + "/reconcile",
|
||||
JSON.stringify({
|
||||
transactionIDs: reconciledTransactions.map((x) => x.ID),
|
||||
reconciliationTransactionAmount:
|
||||
reconciliationTransactionAmount.toString(),
|
||||
})
|
||||
);
|
||||
const response = await result.json();
|
||||
const recTrans = response.ReconciliationTransaction;
|
||||
if (recTrans) {
|
||||
@ -86,20 +134,19 @@ export const useTransactionsStore = defineStore("budget/transactions", {
|
||||
}
|
||||
},
|
||||
logout() {
|
||||
this.$reset()
|
||||
this.$reset();
|
||||
},
|
||||
async saveTransaction(payload: string) {
|
||||
const accountsStore = useAccountStore()
|
||||
const accountsStore = useAccountStore();
|
||||
const result = await POST("/transaction/new", payload);
|
||||
const response = await result.json() as Transaction;
|
||||
const response = (await result.json()) as Transaction;
|
||||
this.AddTransactions([response]);
|
||||
accountsStore.CurrentAccount?.Transactions.unshift(response.ID);
|
||||
},
|
||||
async editTransaction(transactionid: string, payload: string) {
|
||||
const result = await POST("/transaction/" + transactionid, payload);
|
||||
const response = await result.json() as Transaction;
|
||||
const response = (await result.json()) as Transaction;
|
||||
this.AddTransactions([response]);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -1,10 +1,7 @@
|
||||
module.exports = {
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{vue,js,ts,jsx,tsx}"
|
||||
],
|
||||
content: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
|
||||
import path from 'path'
|
||||
import path from "path";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
@ -9,21 +9,21 @@ export default defineConfig({
|
||||
vue(),
|
||||
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
|
||||
],
|
||||
define: { 'process.env': {} },
|
||||
define: { "process.env": {} },
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
"@": path.resolve(__dirname, "src"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
host: "0.0.0.0",
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://10.0.0.162:1323/',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
"/api": {
|
||||
target: "http://backend:1323/",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
/* remove the need to specify .vue files https://vitejs.dev/config/#resolve-extensions
|
||||
resolve: {
|
||||
extensions: [
|
||||
@ -37,4 +37,4 @@ export default defineConfig({
|
||||
]
|
||||
},
|
||||
*/
|
||||
})
|
||||
});
|
||||
|
351
web/yarn.lock
351
web/yarn.lock
@ -957,6 +957,21 @@
|
||||
resolved "https://registry.yarnpkg.com/@emmetio/scanner/-/scanner-1.0.0.tgz#065b2af6233fe7474d44823e3deb89724af42b5f"
|
||||
integrity sha512-8HqW8EVqjnCmWXVpqAOZf+EGESdkR27odcMMMGefgKXtar00SoYNSryGv//TELI4T3QFsECo78p+0lmalk/CFA==
|
||||
|
||||
"@eslint/eslintrc@^1.2.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.0.tgz#7ce1547a5c46dfe56e1e45c3c9ed18038c721c6a"
|
||||
integrity sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w==
|
||||
dependencies:
|
||||
ajv "^6.12.4"
|
||||
debug "^4.3.2"
|
||||
espree "^9.3.1"
|
||||
globals "^13.9.0"
|
||||
ignore "^4.0.6"
|
||||
import-fresh "^3.2.1"
|
||||
js-yaml "^4.1.0"
|
||||
minimatch "^3.0.4"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@hapi/address@2.x.x":
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
|
||||
@ -1001,6 +1016,20 @@
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@humanwhocodes/config-array@^0.9.2":
|
||||
version "0.9.5"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.5.tgz#2cbaf9a89460da24b5ca6531b8bbfc23e1df50c7"
|
||||
integrity sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==
|
||||
dependencies:
|
||||
"@humanwhocodes/object-schema" "^1.2.1"
|
||||
debug "^4.1.1"
|
||||
minimatch "^3.0.4"
|
||||
|
||||
"@humanwhocodes/object-schema@^1.2.1":
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
||||
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
||||
|
||||
"@jridgewell/resolve-uri@^3.0.3":
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.4.tgz#b876e3feefb9c8d3aa84014da28b5e52a0640d72"
|
||||
@ -1281,6 +1310,50 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@typescript-eslint/parser@^5.13.0":
|
||||
version "5.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.13.0.tgz#0394ed8f2f849273c0bf4b811994d177112ced5c"
|
||||
integrity sha512-GdrU4GvBE29tm2RqWOM0P5QfCtgCyN4hXICj/X9ibKED16136l9ZpoJvCL5pSKtmJzA+NRDzQ312wWMejCVVfg==
|
||||
dependencies:
|
||||
"@typescript-eslint/scope-manager" "5.13.0"
|
||||
"@typescript-eslint/types" "5.13.0"
|
||||
"@typescript-eslint/typescript-estree" "5.13.0"
|
||||
debug "^4.3.2"
|
||||
|
||||
"@typescript-eslint/scope-manager@5.13.0":
|
||||
version "5.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.13.0.tgz#cf6aff61ca497cb19f0397eea8444a58f46156b6"
|
||||
integrity sha512-T4N8UvKYDSfVYdmJq7g2IPJYCRzwtp74KyDZytkR4OL3NRupvswvmJQJ4CX5tDSurW2cvCc1Ia1qM7d0jpa7IA==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "5.13.0"
|
||||
"@typescript-eslint/visitor-keys" "5.13.0"
|
||||
|
||||
"@typescript-eslint/types@5.13.0":
|
||||
version "5.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.13.0.tgz#da1de4ae905b1b9ff682cab0bed6b2e3be9c04e5"
|
||||
integrity sha512-LmE/KO6DUy0nFY/OoQU0XelnmDt+V8lPQhh8MOVa7Y5k2gGRd6U9Kp3wAjhB4OHg57tUO0nOnwYQhRRyEAyOyg==
|
||||
|
||||
"@typescript-eslint/typescript-estree@5.13.0":
|
||||
version "5.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.13.0.tgz#b37c07b748ff030a3e93d87c842714e020b78141"
|
||||
integrity sha512-Q9cQow0DeLjnp5DuEDjLZ6JIkwGx3oYZe+BfcNuw/POhtpcxMTy18Icl6BJqTSd+3ftsrfuVb7mNHRZf7xiaNA==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "5.13.0"
|
||||
"@typescript-eslint/visitor-keys" "5.13.0"
|
||||
debug "^4.3.2"
|
||||
globby "^11.0.4"
|
||||
is-glob "^4.0.3"
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@5.13.0":
|
||||
version "5.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.13.0.tgz#f45ff55bcce16403b221ac9240fbeeae4764f0fd"
|
||||
integrity sha512-HLKEAS/qA1V7d9EzcpLFykTePmOQqOFim8oCvhY3pZgQ8Hi38hYpHd9e5GN6nQBFQNecNhws5wkS9Y5XIO0s/g==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "5.13.0"
|
||||
eslint-visitor-keys "^3.0.0"
|
||||
|
||||
"@vitejs/plugin-vue@^2.0.0":
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.1.0.tgz#ddf5e0059f84f2ff649afc25ce5a59211e670542"
|
||||
@ -2089,6 +2162,11 @@ acorn-import-assertions@^1.7.6:
|
||||
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9"
|
||||
integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==
|
||||
|
||||
acorn-jsx@^5.3.1:
|
||||
version "5.3.2"
|
||||
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
|
||||
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
|
||||
|
||||
acorn-node@^1.6.1:
|
||||
version "1.8.2"
|
||||
resolved "https://registry.yarnpkg.com/acorn-node/-/acorn-node-1.8.2.tgz#114c95d64539e53dede23de8b9d96df7c7ae2af8"
|
||||
@ -2118,7 +2196,7 @@ acorn@^7.0.0, acorn@^7.1.1:
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
|
||||
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
||||
|
||||
acorn@^8.0.4, acorn@^8.0.5, acorn@^8.4.1:
|
||||
acorn@^8.0.4, acorn@^8.0.5, acorn@^8.4.1, acorn@^8.7.0:
|
||||
version "8.7.0"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
|
||||
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==
|
||||
@ -2160,7 +2238,7 @@ ajv-keywords@^5.0.0:
|
||||
dependencies:
|
||||
fast-deep-equal "^3.1.3"
|
||||
|
||||
ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
|
||||
ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
|
||||
version "6.12.6"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
|
||||
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
|
||||
@ -2277,6 +2355,11 @@ argparse@^1.0.7:
|
||||
dependencies:
|
||||
sprintf-js "~1.0.2"
|
||||
|
||||
argparse@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
|
||||
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
||||
|
||||
arr-diff@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
|
||||
@ -3351,7 +3434,7 @@ cross-spawn@^6.0.0:
|
||||
shebang-command "^1.2.0"
|
||||
which "^1.2.9"
|
||||
|
||||
cross-spawn@^7.0.3:
|
||||
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
||||
@ -3528,7 +3611,7 @@ debug@^3.1.1:
|
||||
dependencies:
|
||||
ms "^2.1.1"
|
||||
|
||||
debug@^4.1.0, debug@^4.1.1:
|
||||
debug@^4.1.0, debug@^4.1.1, debug@^4.3.2:
|
||||
version "4.3.3"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
|
||||
integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
|
||||
@ -3552,6 +3635,11 @@ deep-equal@^1.0.1:
|
||||
object-keys "^1.1.1"
|
||||
regexp.prototype.flags "^1.2.0"
|
||||
|
||||
deep-is@^0.1.3:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831"
|
||||
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==
|
||||
|
||||
deepmerge@^1.5.2:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753"
|
||||
@ -3724,6 +3812,13 @@ dns-txt@^2.0.2:
|
||||
dependencies:
|
||||
buffer-indexof "^1.0.0"
|
||||
|
||||
doctrine@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
|
||||
integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==
|
||||
dependencies:
|
||||
esutils "^2.0.2"
|
||||
|
||||
doctypes@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/doctypes/-/doctypes-1.1.0.tgz#ea80b106a87538774e8a3a4a5afe293de489e0a9"
|
||||
@ -4046,6 +4141,21 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
|
||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
||||
|
||||
escape-string-regexp@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
|
||||
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
|
||||
|
||||
eslint-plugin-vue@^8.5.0:
|
||||
version "8.5.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-8.5.0.tgz#65832bba43ca713fa5da16bdfcf55d0095677f6f"
|
||||
integrity sha512-i1uHCTAKOoEj12RDvdtONWrGzjFm/djkzqfhmQ0d6M/W8KM81mhswd/z+iTZ0jCpdUedW3YRgcVfQ37/J4zoYQ==
|
||||
dependencies:
|
||||
eslint-utils "^3.0.0"
|
||||
natural-compare "^1.4.0"
|
||||
semver "^7.3.5"
|
||||
vue-eslint-parser "^8.0.1"
|
||||
|
||||
eslint-scope@5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
|
||||
@ -4062,11 +4172,93 @@ eslint-scope@^4.0.3:
|
||||
esrecurse "^4.1.0"
|
||||
estraverse "^4.1.1"
|
||||
|
||||
eslint-scope@^7.0.0, eslint-scope@^7.1.1:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642"
|
||||
integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==
|
||||
dependencies:
|
||||
esrecurse "^4.3.0"
|
||||
estraverse "^5.2.0"
|
||||
|
||||
eslint-utils@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672"
|
||||
integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==
|
||||
dependencies:
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
eslint-visitor-keys@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
|
||||
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
|
||||
|
||||
eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.1.0, eslint-visitor-keys@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
|
||||
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
|
||||
|
||||
eslint@^8.10.0:
|
||||
version "8.10.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.10.0.tgz#931be395eb60f900c01658b278e05b6dae47199d"
|
||||
integrity sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw==
|
||||
dependencies:
|
||||
"@eslint/eslintrc" "^1.2.0"
|
||||
"@humanwhocodes/config-array" "^0.9.2"
|
||||
ajv "^6.10.0"
|
||||
chalk "^4.0.0"
|
||||
cross-spawn "^7.0.2"
|
||||
debug "^4.3.2"
|
||||
doctrine "^3.0.0"
|
||||
escape-string-regexp "^4.0.0"
|
||||
eslint-scope "^7.1.1"
|
||||
eslint-utils "^3.0.0"
|
||||
eslint-visitor-keys "^3.3.0"
|
||||
espree "^9.3.1"
|
||||
esquery "^1.4.0"
|
||||
esutils "^2.0.2"
|
||||
fast-deep-equal "^3.1.3"
|
||||
file-entry-cache "^6.0.1"
|
||||
functional-red-black-tree "^1.0.1"
|
||||
glob-parent "^6.0.1"
|
||||
globals "^13.6.0"
|
||||
ignore "^5.2.0"
|
||||
import-fresh "^3.0.0"
|
||||
imurmurhash "^0.1.4"
|
||||
is-glob "^4.0.0"
|
||||
js-yaml "^4.1.0"
|
||||
json-stable-stringify-without-jsonify "^1.0.1"
|
||||
levn "^0.4.1"
|
||||
lodash.merge "^4.6.2"
|
||||
minimatch "^3.0.4"
|
||||
natural-compare "^1.4.0"
|
||||
optionator "^0.9.1"
|
||||
regexpp "^3.2.0"
|
||||
strip-ansi "^6.0.1"
|
||||
strip-json-comments "^3.1.0"
|
||||
text-table "^0.2.0"
|
||||
v8-compile-cache "^2.0.3"
|
||||
|
||||
espree@^9.0.0, espree@^9.3.1:
|
||||
version "9.3.1"
|
||||
resolved "https://registry.yarnpkg.com/espree/-/espree-9.3.1.tgz#8793b4bc27ea4c778c19908e0719e7b8f4115bcd"
|
||||
integrity sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==
|
||||
dependencies:
|
||||
acorn "^8.7.0"
|
||||
acorn-jsx "^5.3.1"
|
||||
eslint-visitor-keys "^3.3.0"
|
||||
|
||||
esprima@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
||||
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
|
||||
|
||||
esquery@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5"
|
||||
integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==
|
||||
dependencies:
|
||||
estraverse "^5.1.0"
|
||||
|
||||
esrecurse@^4.1.0, esrecurse@^4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
|
||||
@ -4079,7 +4271,7 @@ estraverse@^4.1.1:
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
|
||||
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==
|
||||
|
||||
estraverse@^5.2.0:
|
||||
estraverse@^5.1.0, estraverse@^5.2.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
|
||||
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
|
||||
@ -4289,6 +4481,11 @@ fast-json-stable-stringify@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
|
||||
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
||||
|
||||
fast-levenshtein@^2.0.6:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
|
||||
|
||||
fastq@^1.6.0:
|
||||
version "1.13.0"
|
||||
resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c"
|
||||
@ -4315,6 +4512,13 @@ figures@^2.0.0:
|
||||
dependencies:
|
||||
escape-string-regexp "^1.0.5"
|
||||
|
||||
file-entry-cache@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027"
|
||||
integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==
|
||||
dependencies:
|
||||
flat-cache "^3.0.4"
|
||||
|
||||
file-saver@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38"
|
||||
@ -4388,6 +4592,19 @@ find-up@^4.0.0, find-up@^4.1.0:
|
||||
locate-path "^5.0.0"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
flat-cache@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
|
||||
integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==
|
||||
dependencies:
|
||||
flatted "^3.1.0"
|
||||
rimraf "^3.0.2"
|
||||
|
||||
flatted@^3.1.0:
|
||||
version "3.2.5"
|
||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
|
||||
integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
|
||||
|
||||
flush-write-stream@^1.0.0:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"
|
||||
@ -4529,6 +4746,11 @@ function-bind@^1.1.1:
|
||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
|
||||
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
|
||||
|
||||
functional-red-black-tree@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
|
||||
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
|
||||
|
||||
gensync@^1.0.0-beta.2:
|
||||
version "1.0.0-beta.2"
|
||||
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
|
||||
@ -4626,7 +4848,14 @@ globals@^11.1.0:
|
||||
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
|
||||
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
|
||||
|
||||
globby@^11.0.1, globby@^11.0.2, globby@^11.0.3:
|
||||
globals@^13.6.0, globals@^13.9.0:
|
||||
version "13.12.1"
|
||||
resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb"
|
||||
integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==
|
||||
dependencies:
|
||||
type-fest "^0.20.2"
|
||||
|
||||
globby@^11.0.1, globby@^11.0.2, globby@^11.0.3, globby@^11.0.4:
|
||||
version "11.1.0"
|
||||
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
|
||||
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
|
||||
@ -4961,7 +5190,7 @@ iferr@^0.1.5:
|
||||
resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
|
||||
integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE=
|
||||
|
||||
ignore@^4.0.3:
|
||||
ignore@^4.0.3, ignore@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
|
||||
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
|
||||
@ -4976,7 +5205,7 @@ immutable@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23"
|
||||
integrity sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw==
|
||||
|
||||
import-fresh@^3.1.0, import-fresh@^3.2.1:
|
||||
import-fresh@^3.0.0, import-fresh@^3.1.0, import-fresh@^3.2.1:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
|
||||
integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==
|
||||
@ -5373,6 +5602,13 @@ js-yaml@^3.13.1:
|
||||
argparse "^1.0.7"
|
||||
esprima "^4.0.0"
|
||||
|
||||
js-yaml@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
|
||||
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
|
||||
dependencies:
|
||||
argparse "^2.0.1"
|
||||
|
||||
jsbn@~0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
|
||||
@ -5413,6 +5649,11 @@ json-schema@0.4.0:
|
||||
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5"
|
||||
integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==
|
||||
|
||||
json-stable-stringify-without-jsonify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
|
||||
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
|
||||
|
||||
json-stringify-safe@~5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
|
||||
@ -5513,6 +5754,14 @@ launch-editor@^2.2.1, launch-editor@^2.3.0:
|
||||
picocolors "^1.0.0"
|
||||
shell-quote "^1.6.1"
|
||||
|
||||
levn@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
|
||||
integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==
|
||||
dependencies:
|
||||
prelude-ls "^1.2.1"
|
||||
type-check "~0.4.0"
|
||||
|
||||
lilconfig@^2.0.3, lilconfig@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082"
|
||||
@ -5591,6 +5840,11 @@ lodash.memoize@^4.1.2:
|
||||
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
||||
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
|
||||
|
||||
lodash.merge@^4.6.2:
|
||||
version "4.6.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
|
||||
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
|
||||
|
||||
lodash.uniq@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
@ -5979,6 +6233,11 @@ nanomatch@^1.2.9:
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
natural-compare@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
||||
|
||||
negotiator@0.6.3:
|
||||
version "0.6.3"
|
||||
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
|
||||
@ -6235,6 +6494,18 @@ opener@^1.5.2:
|
||||
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598"
|
||||
integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==
|
||||
|
||||
optionator@^0.9.1:
|
||||
version "0.9.1"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499"
|
||||
integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==
|
||||
dependencies:
|
||||
deep-is "^0.1.3"
|
||||
fast-levenshtein "^2.0.6"
|
||||
levn "^0.4.1"
|
||||
prelude-ls "^1.2.1"
|
||||
type-check "^0.4.0"
|
||||
word-wrap "^1.2.3"
|
||||
|
||||
ora@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/ora/-/ora-3.4.0.tgz#bf0752491059a3ef3ed4c85097531de9fdbcd318"
|
||||
@ -6817,7 +7088,12 @@ postcss@^8.1.10, postcss@^8.2.15, postcss@^8.2.6, postcss@^8.3.5, postcss@^8.4.5
|
||||
picocolors "^1.0.0"
|
||||
source-map-js "^1.0.2"
|
||||
|
||||
"prettier@^1.18.2 || ^2.0.0":
|
||||
prelude-ls@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||
|
||||
prettier@2.5.1, "prettier@^1.18.2 || ^2.0.0":
|
||||
version "2.5.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
|
||||
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
|
||||
@ -7196,6 +7472,11 @@ regexp.prototype.flags@^1.2.0:
|
||||
call-bind "^1.0.2"
|
||||
define-properties "^1.1.3"
|
||||
|
||||
regexpp@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||
integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==
|
||||
|
||||
regexpu-core@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.0.1.tgz#c531122a7840de743dcf9c83e923b5560323ced3"
|
||||
@ -7975,6 +8256,11 @@ strip-indent@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"
|
||||
integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=
|
||||
|
||||
strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
|
||||
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
|
||||
|
||||
stylehacks@^5.0.2:
|
||||
version "5.0.2"
|
||||
resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.0.2.tgz#fa10e5181c6e8dc0bddb4a3fb372e9ac42bba2ad"
|
||||
@ -8112,6 +8398,11 @@ terser@^5.10.0, terser@^5.7.2:
|
||||
source-map "~0.7.2"
|
||||
source-map-support "~0.5.20"
|
||||
|
||||
text-table@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
|
||||
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
|
||||
|
||||
thenify-all@^1.0.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
|
||||
@ -8288,6 +8579,13 @@ tsutils@^2.29.0:
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tsutils@^3.21.0:
|
||||
version "3.21.0"
|
||||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
|
||||
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tty-browserify@0.0.0:
|
||||
version "0.0.0"
|
||||
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
|
||||
@ -8305,6 +8603,18 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
|
||||
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
|
||||
integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=
|
||||
|
||||
type-check@^0.4.0, type-check@~0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
|
||||
integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==
|
||||
dependencies:
|
||||
prelude-ls "^1.2.1"
|
||||
|
||||
type-fest@^0.20.2:
|
||||
version "0.20.2"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
|
||||
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
|
||||
|
||||
type-fest@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
|
||||
@ -8472,6 +8782,11 @@ uuid@^8.3.2:
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
v8-compile-cache@^2.0.3:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
|
||||
integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
|
||||
|
||||
validate-npm-package-license@^3.0.1:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
|
||||
@ -8644,6 +8959,19 @@ vue-demi@*:
|
||||
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.12.1.tgz#f7e18efbecffd11ab069d1472d7a06e319b4174c"
|
||||
integrity sha512-QL3ny+wX8c6Xm1/EZylbgzdoDolye+VpCXRhI2hug9dJTP3OUJ3lmiKN3CsVV3mOJKwFi0nsstbgob0vG7aoIw==
|
||||
|
||||
vue-eslint-parser@^8.0.1:
|
||||
version "8.3.0"
|
||||
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz#5d31129a1b3dd89c0069ca0a1c88f970c360bd0d"
|
||||
integrity sha512-dzHGG3+sYwSf6zFBa0Gi9ZDshD7+ad14DGOdTLjruRVgZXe2J+DcZ9iUhyR48z5g1PqRa20yt3Njna/veLJL/g==
|
||||
dependencies:
|
||||
debug "^4.3.2"
|
||||
eslint-scope "^7.0.0"
|
||||
eslint-visitor-keys "^3.1.0"
|
||||
espree "^9.0.0"
|
||||
esquery "^1.4.0"
|
||||
lodash "^4.17.21"
|
||||
semver "^7.3.5"
|
||||
|
||||
vue-hot-reload-api@^2.3.0:
|
||||
version "2.3.4"
|
||||
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"
|
||||
@ -8953,6 +9281,11 @@ with@^7.0.0:
|
||||
assert-never "^1.2.1"
|
||||
babel-walk "3.0.0-canary-5"
|
||||
|
||||
word-wrap@^1.2.3:
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
|
||||
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
|
||||
|
||||
worker-farm@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8"
|
||||
|
Loading…
x
Reference in New Issue
Block a user