Compare commits
	
		
			60 Commits
		
	
	
		
			4ee82dce26
			...
			create-cat
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					adc6e0a2cf | ||
| 
						 | 
					4d04529ae2 | ||
| 
						 | 
					2559d2dbdb | ||
| 
						 | 
					ac39ec07a4 | ||
| 
						 | 
					5792aed089 | ||
| 
						 | 
					69cb27fc51 | ||
| 
						 | 
					907be875c8 | ||
| 
						 | 
					cfe8599ed0 | ||
| 
						 | 
					98e1fbb071 | ||
| 
						 | 
					5d57045efb | ||
| 
						 | 
					5456e0223a | ||
| a0e6dc0f1b | |||
| 88283a8817 | |||
| 31a4135f2e | |||
| 94c2465109 | |||
| 6a5bf419e2 | |||
| b55744aad7 | |||
| 5658f31457 | |||
| fc15d8b56e | |||
| 403544e99f | |||
| 99979a35b0 | |||
| 49cf6a65da | |||
| 2b15231ed1 | |||
| bae9f030b2 | |||
| a06d0df142 | |||
| 0567619408 | |||
| 0c375884aa | |||
| ca964f1c5f | |||
| b2542fa6d1 | |||
| 77de2a833e | |||
| 10a870a300 | |||
| 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 | 
@@ -1,5 +1,5 @@
 | 
				
			|||||||
build/
 | 
					build/
 | 
				
			||||||
.git/
 | 
					docker/
 | 
				
			||||||
docker-compose.yml
 | 
					docker-compose.yml
 | 
				
			||||||
README.md
 | 
					README.md
 | 
				
			||||||
Earthfile
 | 
					Earthfile
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@ linters:
 | 
				
			|||||||
    - gci # not working, shows errors on freshly formatted file
 | 
					    - gci # not working, shows errors on freshly formatted file
 | 
				
			||||||
    - varnamelen
 | 
					    - varnamelen
 | 
				
			||||||
    - lll
 | 
					    - lll
 | 
				
			||||||
 | 
					
 | 
				
			||||||
linters-settings:
 | 
					linters-settings:
 | 
				
			||||||
  errcheck:
 | 
					  errcheck:
 | 
				
			||||||
    exclude-functions:
 | 
					    exclude-functions:
 | 
				
			||||||
@@ -25,3 +26,18 @@ linters-settings:
 | 
				
			|||||||
  varnamelen:
 | 
					  varnamelen:
 | 
				
			||||||
    ignore-decls:
 | 
					    ignore-decls:
 | 
				
			||||||
      - c *gin.Context
 | 
					      - 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
 | 
				
			||||||
							
								
								
									
										26
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								README.md
									
									
									
									
									
								
							@@ -1,20 +1,18 @@
 | 
				
			|||||||
# Budgeteer
 | 
					# Budgeteer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Budgeting Web-Application
 | 
					Budgeting Web-Application written in Go and inspired by [YNAB](https://youneedabudget.com).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Data structure
 | 
					## Getting started
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1 User
 | 
					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 Budgets
 | 
					 | 
				
			||||||
        AccountID[]
 | 
					 | 
				
			||||||
        CategoryID[]
 | 
					 | 
				
			||||||
        PayeeID[]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
N Accounts
 | 
					## Known issues
 | 
				
			||||||
        TransactionID[]
 | 
					 | 
				
			||||||
N Categories
 | 
					 | 
				
			||||||
        AssignmentID[]
 | 
					 | 
				
			||||||
N Payees
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
N Transactions
 | 
					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.
 | 
				
			||||||
N Assignments
 | 
					
 | 
				
			||||||
 | 
					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. 
 | 
				
			||||||
@@ -139,4 +139,4 @@ tasks:
 | 
				
			|||||||
    desc: Run dev environment in docker
 | 
					    desc: Run dev environment in docker
 | 
				
			||||||
    deps: [dev-docker]
 | 
					    deps: [dev-docker]
 | 
				
			||||||
    cmds:
 | 
					    cmds:
 | 
				
			||||||
      - docker-compose -f docker/docker-compose.dev.yml -p budgeteer up -d
 | 
					      - docker-compose -f docker/docker-compose.dev.yml up -d
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,9 @@
 | 
				
			|||||||
FROM alpine as godeps
 | 
					FROM nixos/nix
 | 
				
			||||||
RUN apk --no-cache add go
 | 
					 | 
				
			||||||
RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
 | 
					 | 
				
			||||||
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
 | 
					 | 
				
			||||||
ENV PATH="/root/.yarn/bin/:${PATH}"
 | 
					ENV PATH="/root/.yarn/bin/:${PATH}"
 | 
				
			||||||
WORKDIR /src/web
 | 
					RUN nix-env --install go go-task sqlc nodejs yarn git
 | 
				
			||||||
ADD web/package.json web/yarn.lock /src/web/
 | 
					ADD web/package.json web/yarn.lock /src/web/
 | 
				
			||||||
 | 
					WORKDIR /src/web
 | 
				
			||||||
 | 
					RUN yarn
 | 
				
			||||||
WORKDIR /src
 | 
					WORKDIR /src
 | 
				
			||||||
VOLUME /go
 | 
					VOLUME /go
 | 
				
			||||||
VOLUME /.cache
 | 
					VOLUME /.cache
 | 
				
			||||||
COPY --from=godeps /root/go/bin/task /root/go/bin/sqlc /root/go/bin/golangci-lint /usr/local/bin/
 | 
					 | 
				
			||||||
@@ -2,6 +2,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
tmux new-session -d -s watch 'cd web; yarn dev'
 | 
					tmux new-session -d -s watch 'cd web; yarn dev'
 | 
				
			||||||
tmux split-window;
 | 
					tmux split-window;
 | 
				
			||||||
tmux send 'task -w run' ENTER;
 | 
					tmux send 'go-task -w run' ENTER;
 | 
				
			||||||
tmux split-window;
 | 
					tmux split-window;
 | 
				
			||||||
tmux a;
 | 
					tmux a;
 | 
				
			||||||
@@ -1,5 +1,7 @@
 | 
				
			|||||||
version: '3.7'
 | 
					version: '3.7'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					name: "budgeteer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
services:
 | 
					services:
 | 
				
			||||||
        backend:
 | 
					        backend:
 | 
				
			||||||
                image: hub.javil.eu/budgeteer:dev
 | 
					                image: hub.javil.eu/budgeteer:dev
 | 
				
			||||||
@@ -7,7 +9,7 @@ services:
 | 
				
			|||||||
                ports:
 | 
					                ports:
 | 
				
			||||||
                        - 1323:1323
 | 
					                        - 1323:1323
 | 
				
			||||||
                volumes:
 | 
					                volumes:
 | 
				
			||||||
                        - ~/budgeteer:/src
 | 
					                        - ../:/src
 | 
				
			||||||
                        - go-cache:/go
 | 
					                        - go-cache:/go
 | 
				
			||||||
                        - yarn-cache:/.cache
 | 
					                        - yarn-cache:/.cache
 | 
				
			||||||
                environment:
 | 
					                environment:
 | 
				
			||||||
@@ -22,7 +24,7 @@ services:
 | 
				
			|||||||
                ports:
 | 
					                ports:
 | 
				
			||||||
                        - 3000:3000
 | 
					                        - 3000:3000
 | 
				
			||||||
                volumes:
 | 
					                volumes:
 | 
				
			||||||
                        - ~/budgeteer:/src
 | 
					                        - ../:/src
 | 
				
			||||||
                depends_on:
 | 
					                depends_on:
 | 
				
			||||||
                        - backend
 | 
					                        - backend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,7 @@
 | 
				
			|||||||
version: '3.7'
 | 
					version: '3.7'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					name: "budgeteer"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
services:
 | 
					services:
 | 
				
			||||||
        app:
 | 
					        app:
 | 
				
			||||||
                image: hub.javil.eu/budgeteer:latest
 | 
					                image: hub.javil.eu/budgeteer:latest
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								go.mod
									
									
									
									
									
								
							@@ -4,21 +4,28 @@ go 1.17
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require (
 | 
					require (
 | 
				
			||||||
	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 | 
						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/google/uuid v1.3.0
 | 
				
			||||||
	github.com/jackc/pgx/v4 v4.13.0
 | 
						github.com/jackc/pgx/v4 v4.13.0
 | 
				
			||||||
	github.com/pressly/goose/v3 v3.3.1
 | 
						github.com/pressly/goose/v3 v3.3.1
 | 
				
			||||||
	golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
 | 
						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 (
 | 
					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/chunkreader/v2 v2.0.1 // indirect
 | 
				
			||||||
	github.com/jackc/pgconn v1.10.0 // indirect
 | 
						github.com/jackc/pgconn v1.10.0 // indirect
 | 
				
			||||||
	github.com/jackc/pgio v1.0.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/pgproto3/v2 v2.1.1 // indirect
 | 
				
			||||||
	github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
 | 
						github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
 | 
				
			||||||
	github.com/jackc/pgtype v1.8.1 // direct
 | 
						github.com/jackc/pgtype v1.8.1 // direct
 | 
				
			||||||
	github.com/json-iterator/go v1.1.9 // indirect
 | 
						github.com/mattn/go-isatty v0.0.14 // 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/pkg/errors v0.9.1 // indirect
 | 
						github.com/pkg/errors v0.9.1 // indirect
 | 
				
			||||||
	github.com/shopspring/decimal v1.3.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-20211103235746-7861aae1554b // indirect
 | 
				
			||||||
	golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
 | 
						golang.org/x/text v0.3.7 // 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
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										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/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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 | 
				
			||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 | 
					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/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 | 
				
			||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
 | 
					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.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.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
 | 
				
			||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
 | 
					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.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 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
 | 
				
			||||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 | 
					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.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.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
 | 
				
			||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
 | 
					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-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/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/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/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.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.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.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/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
 | 
				
			||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
 | 
					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-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.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
 | 
				
			||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
 | 
					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/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/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 | 
				
			||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 | 
					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.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.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.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/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/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 | 
				
			||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
 | 
					github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
 | 
				
			||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
 | 
					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/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/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/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/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.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 | 
				
			||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
 | 
					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/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/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.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/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.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 | 
				
			||||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
 | 
					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/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/labstack/echo/v4 v4.8.0 h1:wdc6yKVaHxkNOEdz4cRZs1pQkwSXPiRjq69yWP4QQS8=
 | 
				
			||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
 | 
					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 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.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 | 
				
			||||||
github.com/lib/pq v1.1.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/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.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.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.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.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.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.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 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
 | 
				
			||||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 | 
					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/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/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/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/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/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=
 | 
					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/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/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.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/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/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
 | 
				
			||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
 | 
					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=
 | 
					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-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-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-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 h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
					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=
 | 
					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-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-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-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/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/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=
 | 
					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-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-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-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-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-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 | 
				
			||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
					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.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.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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
				
			||||||
golang.org/x/text v0.3.4/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.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-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-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-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/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-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-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-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=
 | 
					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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 | 
				
			||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 | 
					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.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
 | 
				
			||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 | 
					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-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=
 | 
					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/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 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/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/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=
 | 
					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.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.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.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.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-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.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
 | 
				
			||||||
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
 | 
					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=
 | 
					honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,6 +91,24 @@ func (q *Queries) GetCategories(ctx context.Context, budgetID uuid.UUID) ([]GetC
 | 
				
			|||||||
	return items, nil
 | 
						return items, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getCategoryGroupByName = `-- name: GetCategoryGroupByName :one
 | 
				
			||||||
 | 
					SELECT category_groups.id, category_groups.budget_id, category_groups.name FROM category_groups 
 | 
				
			||||||
 | 
					WHERE category_groups.budget_id = $1
 | 
				
			||||||
 | 
					AND category_groups.name = $2
 | 
				
			||||||
 | 
					`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type GetCategoryGroupByNameParams struct {
 | 
				
			||||||
 | 
						BudgetID uuid.UUID
 | 
				
			||||||
 | 
						Name     string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (q *Queries) GetCategoryGroupByName(ctx context.Context, arg GetCategoryGroupByNameParams) (CategoryGroup, error) {
 | 
				
			||||||
 | 
						row := q.db.QueryRowContext(ctx, getCategoryGroupByName, arg.BudgetID, arg.Name)
 | 
				
			||||||
 | 
						var i CategoryGroup
 | 
				
			||||||
 | 
						err := row.Scan(&i.ID, &i.BudgetID, &i.Name)
 | 
				
			||||||
 | 
						return i, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getCategoryGroups = `-- name: GetCategoryGroups :many
 | 
					const getCategoryGroups = `-- name: GetCategoryGroups :many
 | 
				
			||||||
SELECT category_groups.id, category_groups.budget_id, category_groups.name FROM category_groups 
 | 
					SELECT category_groups.id, category_groups.budget_id, category_groups.name FROM category_groups 
 | 
				
			||||||
WHERE category_groups.budget_id = $1
 | 
					WHERE category_groups.budget_id = $1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,9 @@ type CreatePayeeParams struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (q *Queries) CreatePayee(ctx context.Context, arg CreatePayeeParams) (Payee, error) {
 | 
					func (q *Queries) CreatePayee(ctx context.Context, arg CreatePayeeParams) (Payee, error) {
 | 
				
			||||||
 | 
						if len(arg.Name) > 50 {
 | 
				
			||||||
 | 
							arg.Name = arg.Name[:50]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	row := q.db.QueryRowContext(ctx, createPayee, arg.Name, arg.BudgetID)
 | 
						row := q.db.QueryRowContext(ctx, createPayee, arg.Name, arg.BudgetID)
 | 
				
			||||||
	var i Payee
 | 
						var i Payee
 | 
				
			||||||
	err := row.Scan(&i.ID, &i.BudgetID, &i.Name)
 | 
						err := row.Scan(&i.ID, &i.BudgetID, &i.Name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,11 @@ RETURNING *;
 | 
				
			|||||||
SELECT category_groups.* FROM category_groups 
 | 
					SELECT category_groups.* FROM category_groups 
 | 
				
			||||||
WHERE category_groups.budget_id = $1;
 | 
					WHERE category_groups.budget_id = $1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- name: GetCategoryGroupByName :one
 | 
				
			||||||
 | 
					SELECT category_groups.* FROM category_groups 
 | 
				
			||||||
 | 
					WHERE category_groups.budget_id = $1
 | 
				
			||||||
 | 
					AND category_groups.name = $2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- name: CreateCategory :one
 | 
					-- name: CreateCategory :one
 | 
				
			||||||
INSERT INTO categories
 | 
					INSERT INTO categories
 | 
				
			||||||
(name, category_group_id)
 | 
					(name, category_group_id)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,3 +62,12 @@ WHERE transactions.category_id IS NULL
 | 
				
			|||||||
AND accounts.on_budget
 | 
					AND accounts.on_budget
 | 
				
			||||||
AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget)
 | 
					AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget)
 | 
				
			||||||
AND accounts.budget_id = $1;
 | 
					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;
 | 
				
			||||||
@@ -117,6 +117,77 @@ func (q *Queries) GetAllTransactionsForBudget(ctx context.Context, budgetID uuid
 | 
				
			|||||||
	return items, nil
 | 
						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
 | 
					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
 | 
					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
 | 
					FROM display_transactions AS transactions
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,50 +2,98 @@ package server
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) problematicTransactions(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")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactions, err := h.Service.GetProblematicTransactions(c.Request.Context(), budgetUUID)
 | 
						var request FilterTransactionsRequest
 | 
				
			||||||
 | 
						err = c.Bind(&request)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, TransactionsResponse{nil, transactions})
 | 
						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 (h *Handler) transactionsForAccount(c *gin.Context) {
 | 
					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")
 | 
						accountID := c.Param("accountid")
 | 
				
			||||||
	accountUUID, err := uuid.Parse(accountID)
 | 
						accountUUID, err := uuid.Parse(accountID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	account, err := h.Service.GetAccount(c.Request.Context(), accountUUID)
 | 
						account, err := h.Service.GetAccount(c.Request().Context(), accountUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusNotFound, err)
 | 
							return echo.NewHTTPError(http.StatusNotFound, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactions, err := h.Service.GetTransactionsForAccount(c.Request.Context(), accountUUID)
 | 
						transactions, err := h.Service.GetTransactionsForAccount(c.Request().Context(), accountUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusNotFound, err)
 | 
							return echo.NewHTTPError(http.StatusNotFound, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, TransactionsResponse{&account, transactions})
 | 
						return c.JSON(http.StatusOK, TransactionsResponse{&account, transactions})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type TransactionsResponse struct {
 | 
					type TransactionsResponse struct {
 | 
				
			||||||
@@ -59,19 +107,17 @@ type EditAccountRequest struct {
 | 
				
			|||||||
	IsOpen   bool   `json:"isOpen"`
 | 
						IsOpen   bool   `json:"isOpen"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) editAccount(c *gin.Context) {
 | 
					func (h *Handler) editAccount(c echo.Context) error {
 | 
				
			||||||
	accountID := c.Param("accountid")
 | 
						accountID := c.Param("accountid")
 | 
				
			||||||
	accountUUID, err := uuid.Parse(accountID)
 | 
						accountUUID, err := uuid.Parse(accountID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var request EditAccountRequest
 | 
						var request EditAccountRequest
 | 
				
			||||||
	err = c.BindJSON(&request)
 | 
						err = c.Bind(&request)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	updateParams := postgres.UpdateAccountParams{
 | 
						updateParams := postgres.UpdateAccountParams{
 | 
				
			||||||
@@ -80,11 +126,10 @@ func (h *Handler) editAccount(c *gin.Context) {
 | 
				
			|||||||
		IsOpen:   request.IsOpen,
 | 
							IsOpen:   request.IsOpen,
 | 
				
			||||||
		ID:       accountUUID,
 | 
							ID:       accountUUID,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	account, err := h.Service.UpdateAccount(c.Request.Context(), updateParams)
 | 
						account, err := h.Service.UpdateAccount(c.Request().Context(), updateParams)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusNotFound, err)
 | 
							return echo.NewHTTPError(http.StatusNotFound, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h.getBudget(c, account.BudgetID)
 | 
						return h.getBudget(c, account.BudgetID)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package server
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/http/httptest"
 | 
						"net/http/httptest"
 | 
				
			||||||
@@ -10,7 +11,8 @@ import (
 | 
				
			|||||||
	"git.javil.eu/jacob1123/budgeteer/bcrypt"
 | 
						"git.javil.eu/jacob1123/budgeteer/bcrypt"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/jwt"
 | 
						"git.javil.eu/jacob1123/budgeteer/jwt"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestRegisterUser(t *testing.T) {
 | 
					func TestRegisterUser(t *testing.T) {
 | 
				
			||||||
@@ -29,21 +31,28 @@ func TestRegisterUser(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	recorder := httptest.NewRecorder()
 | 
						recorder := httptest.NewRecorder()
 | 
				
			||||||
	context, engine := gin.CreateTestContext(recorder)
 | 
						engine := echo.New()
 | 
				
			||||||
	h.LoadRoutes(engine)
 | 
						h.LoadRoutes(engine)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.Run("RegisterUser", func(t *testing.T) {
 | 
						t.Run("RegisterUser", func(t *testing.T) {
 | 
				
			||||||
		t.Parallel()
 | 
							t.Parallel()
 | 
				
			||||||
		context.Request, err = http.NewRequest(
 | 
							request, err := http.NewRequestWithContext(context.Background(),
 | 
				
			||||||
			http.MethodPost,
 | 
								http.MethodPost,
 | 
				
			||||||
			"/api/v1/user/register",
 | 
								"/api/v1/user/register",
 | 
				
			||||||
			strings.NewReader(`{"password":"pass","email":"info@example.com","name":"Test"}`))
 | 
								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 {
 | 
							if err != nil {
 | 
				
			||||||
			t.Errorf("error creating request: %s", err)
 | 
								t.Errorf("error creating request: %s", err)
 | 
				
			||||||
			return
 | 
								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 {
 | 
							if recorder.Code != http.StatusOK {
 | 
				
			||||||
			t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)
 | 
								t.Errorf("handler returned wrong status code: got %v want %v", recorder.Code, http.StatusOK)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,63 +4,66 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
	"github.com/pressly/goose/v3"
 | 
						"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 {
 | 
						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 {
 | 
						if err := goose.Up(h.Service.DB, "schema"); err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) deleteBudget(c *gin.Context) {
 | 
					func (h *Handler) deleteBudget(c echo.Context) error {
 | 
				
			||||||
	budgetID := c.Param("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatus(http.StatusBadRequest)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h.clearBudgetData(c, budgetUUID)
 | 
						err = h.clearBudgetData(c, budgetUUID)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	err = h.Service.DeleteBudget(c.Request.Context(), budgetUUID)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = h.Service.DeleteBudget(c.Request().Context(), budgetUUID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) clearBudgetData(c *gin.Context, budgetUUID uuid.UUID) {
 | 
					func (h *Handler) clearBudgetData(c echo.Context, budgetUUID uuid.UUID) error {
 | 
				
			||||||
	rows, err := h.Service.DeleteAllAssignments(c.Request.Context(), budgetUUID)
 | 
						rows, err := h.Service.DeleteAllAssignments(c.Request().Context(), budgetUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fmt.Printf("Deleted %d assignments\n", rows)
 | 
						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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fmt.Printf("Deleted %d transactions\n", rows)
 | 
						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")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatus(http.StatusBadRequest)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h.clearBudgetData(c, budgetUUID)
 | 
						return h.clearBudgetData(c, budgetUUID)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,63 +5,58 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) autocompleteAccounts(c *gin.Context) {
 | 
					func (h *Handler) autocompleteAccounts(c echo.Context) error {
 | 
				
			||||||
	budgetID := c.Param("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	query := c.Request.URL.Query().Get("s")
 | 
						query := c.Request().URL.Query().Get("s")
 | 
				
			||||||
	searchParams := postgres.SearchAccountsParams{
 | 
						searchParams := postgres.SearchAccountsParams{
 | 
				
			||||||
		BudgetID: budgetUUID,
 | 
							BudgetID: budgetUUID,
 | 
				
			||||||
		Search:   "%" + query + "%",
 | 
							Search:   "%" + query + "%",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	categories, err := h.Service.SearchAccounts(c.Request.Context(), searchParams)
 | 
						categories, err := h.Service.SearchAccounts(c.Request().Context(), searchParams)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, categories)
 | 
						return c.JSON(http.StatusOK, categories)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) autocompleteCategories(c *gin.Context) {
 | 
					func (h *Handler) autocompleteCategories(c echo.Context) error {
 | 
				
			||||||
	budgetID := c.Param("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	query := c.Request.URL.Query().Get("s")
 | 
						query := c.Request().URL.Query().Get("s")
 | 
				
			||||||
	searchParams := postgres.SearchCategoriesParams{
 | 
						searchParams := postgres.SearchCategoriesParams{
 | 
				
			||||||
		BudgetID: budgetUUID,
 | 
							BudgetID: budgetUUID,
 | 
				
			||||||
		Search:   "%" + query + "%",
 | 
							Search:   "%" + query + "%",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	categories, err := h.Service.SearchCategories(c.Request.Context(), searchParams)
 | 
						categories, err := h.Service.SearchCategories(c.Request().Context(), searchParams)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	query := c.Request.URL.Query().Get("s")
 | 
						query := c.Request().URL.Query().Get("s")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transferPrefix := "Transfer"
 | 
						transferPrefix := "Transfer"
 | 
				
			||||||
	if strings.HasPrefix(query, transferPrefix) {
 | 
						if strings.HasPrefix(query, transferPrefix) {
 | 
				
			||||||
@@ -70,25 +65,23 @@ func (h *Handler) autocompletePayee(c *gin.Context) {
 | 
				
			|||||||
			Search:   "%" + strings.Trim(query[len(transferPrefix):], " \t\n:") + "%",
 | 
								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 {
 | 
							if err != nil {
 | 
				
			||||||
			c.AbortWithError(http.StatusInternalServerError, err)
 | 
								return err
 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c.JSON(http.StatusOK, accounts)
 | 
							return c.JSON(http.StatusOK, accounts)
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		searchParams := postgres.SearchPayeesParams{
 | 
					 | 
				
			||||||
			BudgetID: budgetUUID,
 | 
					 | 
				
			||||||
			Search:   query + "%",
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		payees, err := h.Service.SearchPayees(c.Request.Context(), searchParams)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			c.AbortWithError(http.StatusInternalServerError, err)
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		c.JSON(http.StatusOK, payees)
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						searchParams := postgres.SearchPayeesParams{
 | 
				
			||||||
 | 
							BudgetID: budgetUUID,
 | 
				
			||||||
 | 
							Search:   query + "%",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						payees, err := h.Service.SearchPayees(c.Request().Context(), searchParams)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return c.JSON(http.StatusOK, payees)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,31 +3,28 @@ package server
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type newBudgetInformation struct {
 | 
					type newBudgetInformation struct {
 | 
				
			||||||
	Name string `json:"name"`
 | 
						Name string `json:"name"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) newBudget(c *gin.Context) {
 | 
					func (h *Handler) newBudget(c echo.Context) error {
 | 
				
			||||||
	var newBudget newBudgetInformation
 | 
						var newBudget newBudgetInformation
 | 
				
			||||||
	if err := c.BindJSON(&newBudget); err != nil {
 | 
						if err := c.Bind(&newBudget); err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusNotAcceptable, err)
 | 
							return echo.NewHTTPError(http.StatusNotAcceptable, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if newBudget.Name == "" {
 | 
						if newBudget.Name == "" {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budget name is required"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budget name is required")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	userID := MustGetToken(c).GetID()
 | 
						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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, budget)
 | 
						return c.JSON(http.StatusOK, budget)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,8 +7,8 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type CategoryWithBalance struct {
 | 
					type CategoryWithBalance struct {
 | 
				
			||||||
@@ -27,32 +27,29 @@ func NewCategoryWithBalance(category *postgres.GetCategoriesRow) CategoryWithBal
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) budgetingForMonth(c *gin.Context) {
 | 
					func (h *Handler) budgetingForMonth(c echo.Context) error {
 | 
				
			||||||
	budgetID := c.Param("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
 | 
						budget, err := h.Service.GetBudget(c.Request().Context(), budgetUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	month, err := getDate(c)
 | 
						month, err := getDate(c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String())
 | 
							return c.Redirect(http.StatusTemporaryRedirect, "/budget/"+budget.ID.String())
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data, err := h.getBudgetingViewForMonth(c.Request.Context(), budget, month)
 | 
						data, err := h.getBudgetingViewForMonth(c.Request().Context(), budget, month)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	c.JSON(http.StatusOK, data)
 | 
					
 | 
				
			||||||
 | 
						return c.JSON(http.StatusOK, data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) getBudgetingViewForMonth(ctx context.Context, budget postgres.Budget, month Month) (BudgetingForMonthResponse, error) {
 | 
					func (h *Handler) getBudgetingViewForMonth(ctx context.Context, budget postgres.Budget, month Month) (BudgetingForMonthResponse, error) {
 | 
				
			||||||
@@ -105,33 +102,30 @@ type BudgetingResponse struct {
 | 
				
			|||||||
	Budget   postgres.Budget
 | 
						Budget   postgres.Budget
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) budget(c *gin.Context) {
 | 
					func (h *Handler) budget(c echo.Context) error {
 | 
				
			||||||
	budgetID := c.Param("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "budgetid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h.getBudget(c, budgetUUID)
 | 
						return h.getBudget(c, budgetUUID)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) getBudget(c *gin.Context, budgetUUID uuid.UUID) {
 | 
					func (h *Handler) getBudget(c echo.Context, budgetUUID uuid.UUID) error {
 | 
				
			||||||
	budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
 | 
						budget, err := h.Service.GetBudget(c.Request().Context(), budgetUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusNotFound, err)
 | 
							return echo.NewHTTPError(http.StatusNotFound, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	accounts, err := h.Service.GetAccountsWithBalance(c.Request.Context(), budgetUUID)
 | 
						accounts, err := h.Service.GetAccountsWithBalance(c.Request().Context(), budgetUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data := BudgetingResponse{accounts, budget}
 | 
						data := BudgetingResponse{accounts, budget}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, data)
 | 
						return c.JSON(http.StatusOK, data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) calculateBalances(budget postgres.Budget, month Month,
 | 
					func (h *Handler) calculateBalances(budget postgres.Budget, month Month,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,40 +6,36 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type SetCategoryAssignmentRequest struct {
 | 
					type SetCategoryAssignmentRequest struct {
 | 
				
			||||||
	Assigned float64
 | 
						Assigned float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) setCategoryAssignment(c *gin.Context) {
 | 
					func (h *Handler) setCategoryAssignment(c echo.Context) error {
 | 
				
			||||||
	categoryID := c.Param("categoryid")
 | 
						categoryID := c.Param("categoryid")
 | 
				
			||||||
	categoryUUID, err := uuid.Parse(categoryID)
 | 
						categoryUUID, err := uuid.Parse(categoryID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"categoryid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "categoryid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var request SetCategoryAssignmentRequest
 | 
						var request SetCategoryAssignmentRequest
 | 
				
			||||||
	err = c.BindJSON(&request)
 | 
						err = c.Bind(&request)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid payload: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("invalid payload: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	date, err := getDate(c)
 | 
						date, err := getDate(c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("date invalid: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("date invalid: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var amount numeric.Numeric
 | 
						var amount numeric.Numeric
 | 
				
			||||||
	err = amount.Set(request.Assigned)
 | 
						err = amount.Set(request.Assigned)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("parse amount: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse amount: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	updateArgs := postgres.UpdateAssignmentParams{
 | 
						updateArgs := postgres.UpdateAssignmentParams{
 | 
				
			||||||
@@ -47,9 +43,10 @@ func (h *Handler) setCategoryAssignment(c *gin.Context) {
 | 
				
			|||||||
		Date:       date.FirstOfMonth(),
 | 
							Date:       date.FirstOfMonth(),
 | 
				
			||||||
		Amount:     amount,
 | 
							Amount:     amount,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	err = h.Service.UpdateAssignment(c.Request.Context(), updateArgs)
 | 
						err = h.Service.UpdateAssignment(c.Request().Context(), updateArgs)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("update assignment: %w", err))
 | 
							return fmt.Errorf("update assignment: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										35
									
								
								server/category_group_new.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/category_group_new.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type newCategoryGroupInformation struct {
 | 
				
			||||||
 | 
						BudgetID uuid.UUID `json:"budgetId"`
 | 
				
			||||||
 | 
						Group    string    `json:"group"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (h *Handler) newCategoryGroup(c echo.Context) error {
 | 
				
			||||||
 | 
						var newCategory newCategoryGroupInformation
 | 
				
			||||||
 | 
						if err := c.Bind(&newCategory); err != nil {
 | 
				
			||||||
 | 
							return echo.NewHTTPError(http.StatusNotAcceptable, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if newCategory.Group == "" {
 | 
				
			||||||
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "category group is required")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						categoryGroup, err := h.Service.CreateCategoryGroup(c.Request().Context(), postgres.CreateCategoryGroupParams{
 | 
				
			||||||
 | 
							BudgetID: newCategory.BudgetID,
 | 
				
			||||||
 | 
							Name:     newCategory.Group,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return c.JSON(http.StatusOK, categoryGroup)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										48
									
								
								server/category_new.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								server/category_new.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type newCategoryInformation struct {
 | 
				
			||||||
 | 
						BudgetID uuid.UUID `json:"budgetId"`
 | 
				
			||||||
 | 
						Name     string    `json:"name"`
 | 
				
			||||||
 | 
						Group    string    `json:"group"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (h *Handler) newCategory(c echo.Context) error {
 | 
				
			||||||
 | 
						var newCategory newCategoryInformation
 | 
				
			||||||
 | 
						if err := c.Bind(&newCategory); err != nil {
 | 
				
			||||||
 | 
							return echo.NewHTTPError(http.StatusNotAcceptable, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if newCategory.Name == "" {
 | 
				
			||||||
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "category name is required")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if newCategory.Group == "" {
 | 
				
			||||||
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "category group is required")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						categoryGroup, err := h.Service.GetCategoryGroupByName(c.Request().Context(), postgres.GetCategoryGroupByNameParams{
 | 
				
			||||||
 | 
							BudgetID: newCategory.BudgetID,
 | 
				
			||||||
 | 
							Name:     newCategory.Group,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						category, err := h.Service.CreateCategory(c.Request().Context(), postgres.CreateCategoryParams{
 | 
				
			||||||
 | 
							CategoryGroupID: categoryGroup.ID,
 | 
				
			||||||
 | 
							Name:            newCategory.Name,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return c.JSON(http.StatusOK, category)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,17 +1,16 @@
 | 
				
			|||||||
package server
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
	"io/fs"
 | 
					 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"path"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer"
 | 
						"git.javil.eu/jacob1123/budgeteer"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/bcrypt"
 | 
						"git.javil.eu/jacob1123/budgeteer/bcrypt"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"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.
 | 
					// Handler handles incoming requests.
 | 
				
			||||||
@@ -24,26 +23,22 @@ type Handler struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Serve starts the http server.
 | 
					// Serve starts the http server.
 | 
				
			||||||
func (h *Handler) Serve() {
 | 
					func (h *Handler) Serve() {
 | 
				
			||||||
	router := gin.Default()
 | 
						router := echo.New()
 | 
				
			||||||
	h.LoadRoutes(router)
 | 
						h.LoadRoutes(router)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := router.Run(":1323"); err != nil {
 | 
						if err := router.Start(":1323"); err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ErrorResponse struct {
 | 
					 | 
				
			||||||
	Message string
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type SuccessResponse struct {
 | 
					 | 
				
			||||||
	Message string
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// LoadRoutes initializes all the routes.
 | 
					// LoadRoutes initializes all the routes.
 | 
				
			||||||
func (h *Handler) LoadRoutes(router *gin.Engine) {
 | 
					func (h *Handler) LoadRoutes(router *echo.Echo) {
 | 
				
			||||||
 | 
						router.Use(middleware.Logger())
 | 
				
			||||||
	router.Use(enableCachingForStaticFiles())
 | 
						router.Use(enableCachingForStaticFiles())
 | 
				
			||||||
	router.NoRoute(h.ServeStatic)
 | 
						router.Use(middleware.StaticWithConfig(middleware.StaticConfig{
 | 
				
			||||||
 | 
							Filesystem: h.StaticFS,
 | 
				
			||||||
 | 
							HTML5:      true,
 | 
				
			||||||
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	api := router.Group("/api/v1")
 | 
						api := router.Group("/api/v1")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,10 +49,16 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
 | 
				
			|||||||
	authenticated := api.Group("")
 | 
						authenticated := api.Group("")
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		authenticated.Use(h.verifyLoginWithForbidden)
 | 
							authenticated.Use(h.verifyLoginWithForbidden)
 | 
				
			||||||
		authenticated.GET("/account/:accountid/transactions", h.transactionsForAccount)
 | 
							account := authenticated.Group("/account")
 | 
				
			||||||
		authenticated.POST("/account/:accountid/reconcile", h.reconcileTransactions)
 | 
							account.GET("/:accountid/transactions", h.transactionsForAccount)
 | 
				
			||||||
		authenticated.POST("/account/:accountid", h.editAccount)
 | 
							account.POST("/:accountid/reconcile", h.reconcileTransactions)
 | 
				
			||||||
		authenticated.GET("/admin/clear-database", h.clearDatabase)
 | 
							account.POST("/:accountid", h.editAccount)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							category := authenticated.Group("/category")
 | 
				
			||||||
 | 
							category.POST("/new", h.newCategory)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							categoryGroup := authenticated.Group("/category-group")
 | 
				
			||||||
 | 
							categoryGroup.POST("/new", h.newCategoryGroup)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		budget := authenticated.Group("/budget")
 | 
							budget := authenticated.Group("/budget")
 | 
				
			||||||
		budget.POST("/new", h.newBudget)
 | 
							budget.POST("/new", h.newBudget)
 | 
				
			||||||
@@ -68,6 +69,7 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
 | 
				
			|||||||
		budget.GET("/:budgetid/autocomplete/accounts", h.autocompleteAccounts)
 | 
							budget.GET("/:budgetid/autocomplete/accounts", h.autocompleteAccounts)
 | 
				
			||||||
		budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
 | 
							budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
 | 
				
			||||||
		budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
 | 
							budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
 | 
				
			||||||
 | 
							budget.POST("/:budgetid/filtered-transactions", h.filteredTransactions)
 | 
				
			||||||
		budget.DELETE("/:budgetid", h.deleteBudget)
 | 
							budget.DELETE("/:budgetid", h.deleteBudget)
 | 
				
			||||||
		budget.POST("/:budgetid/import/ynab", h.importYNAB)
 | 
							budget.POST("/:budgetid/import/ynab", h.importYNAB)
 | 
				
			||||||
		budget.POST("/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
 | 
							budget.POST("/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
 | 
				
			||||||
@@ -77,47 +79,26 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
 | 
				
			|||||||
		transaction := authenticated.Group("/transaction")
 | 
							transaction := authenticated.Group("/transaction")
 | 
				
			||||||
		transaction.POST("/new", h.newTransaction)
 | 
							transaction.POST("/new", h.newTransaction)
 | 
				
			||||||
		transaction.POST("/:transactionid", h.updateTransaction)
 | 
							transaction.POST("/:transactionid", h.updateTransaction)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							authenticated.GET("/admin/clear-database", h.clearDatabase)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						api.Any("/*", h.notFound)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) ServeStatic(c *gin.Context) {
 | 
					func (h *Handler) notFound(c echo.Context) error {
 | 
				
			||||||
	h.ServeStaticFile(c, c.Request.URL.Path)
 | 
						fmt.Println("not found?")
 | 
				
			||||||
 | 
						return echo.NewHTTPError(http.StatusNotImplemented, "not found")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) ServeStaticFile(c *gin.Context, fullPath string) {
 | 
					func enableCachingForStaticFiles() echo.MiddlewareFunc {
 | 
				
			||||||
	file, err := h.StaticFS.Open(fullPath)
 | 
						return func(next echo.HandlerFunc) echo.HandlerFunc {
 | 
				
			||||||
	if errors.Is(err, fs.ErrNotExist) {
 | 
							return func(c echo.Context) error {
 | 
				
			||||||
		h.ServeStaticFile(c, path.Join("/", "/index.html"))
 | 
								if strings.HasPrefix(c.Path(), "/static/") {
 | 
				
			||||||
		return
 | 
									c.Response().Header().Set("Cache-Control", "max-age=86400")
 | 
				
			||||||
	}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
								return next(c)
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	stat, err := file.Stat()
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if stat.IsDir() {
 | 
					 | 
				
			||||||
		h.ServeStaticFile(c, path.Join(fullPath, "index.html"))
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if file, ok := file.(io.ReadSeeker); ok {
 | 
					 | 
				
			||||||
		http.ServeContent(c.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")
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,8 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ReconcileTransactionsRequest struct {
 | 
					type ReconcileTransactionsRequest struct {
 | 
				
			||||||
@@ -22,68 +22,60 @@ type ReconcileTransactionsResponse struct {
 | 
				
			|||||||
	ReconciliationTransaction *postgres.DisplayTransaction
 | 
						ReconciliationTransaction *postgres.DisplayTransaction
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) reconcileTransactions(c *gin.Context) {
 | 
					func (h *Handler) reconcileTransactions(c echo.Context) error {
 | 
				
			||||||
	accountID := c.Param("accountid")
 | 
						accountID := c.Param("accountid")
 | 
				
			||||||
	accountUUID, err := uuid.Parse(accountID)
 | 
						accountUUID, err := uuid.Parse(accountID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var request ReconcileTransactionsRequest
 | 
						var request ReconcileTransactionsRequest
 | 
				
			||||||
	err = c.BindJSON(&request)
 | 
						err = c.Bind(&request)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var amount numeric.Numeric
 | 
						var amount numeric.Numeric
 | 
				
			||||||
	err = amount.Set(request.ReconcilationTransactionAmount)
 | 
						err = amount.Set(request.ReconcilationTransactionAmount)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse request: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tx, err := h.Service.BeginTx(c.Request.Context(), &sql.TxOptions{})
 | 
						tx, err := h.Service.BeginTx(c.Request().Context(), &sql.TxOptions{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("begin tx: %w", err))
 | 
							return fmt.Errorf("begin tx: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	db := h.Service.WithTx(tx)
 | 
						db := h.Service.WithTx(tx)
 | 
				
			||||||
	for _, transactionID := range request.TransactionIDs {
 | 
						for _, transactionID := range request.TransactionIDs {
 | 
				
			||||||
		err := db.SetTransactionReconciled(c.Request.Context(), transactionID)
 | 
							err := db.SetTransactionReconciled(c.Request().Context(), transactionID)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("update transaction: %w", err))
 | 
								return fmt.Errorf("update transaction: %w", err)
 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reconciliationTransaction, err := h.CreateReconcilationTransaction(amount, accountUUID, db, c)
 | 
						reconciliationTransaction, err := h.CreateReconcilationTransaction(amount, accountUUID, db, c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("insert new transaction: %w", err))
 | 
							return fmt.Errorf("insert new transaction: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = h.Service.SetLastReconciled(c.Request.Context(), accountUUID)
 | 
						err = h.Service.SetLastReconciled(c.Request().Context(), accountUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("set last reconciled: %w", err))
 | 
							return fmt.Errorf("set last reconciled: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tx.Commit()
 | 
						err = tx.Commit()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("commit: %w", err))
 | 
							return fmt.Errorf("commit: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, ReconcileTransactionsResponse{
 | 
						return c.JSON(http.StatusOK, ReconcileTransactionsResponse{
 | 
				
			||||||
		Message:                   fmt.Sprintf("Set status for %d transactions", len(request.TransactionIDs)),
 | 
							Message:                   fmt.Sprintf("Set status for %d transactions", len(request.TransactionIDs)),
 | 
				
			||||||
		ReconciliationTransaction: reconciliationTransaction,
 | 
							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() {
 | 
						if amount.IsZero() {
 | 
				
			||||||
		return nil, nil //nolint: nilnil
 | 
							return nil, nil //nolint: nilnil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -95,12 +87,12 @@ func (*Handler) CreateReconcilationTransaction(amount numeric.Numeric, accountUU
 | 
				
			|||||||
		AccountID: accountUUID,
 | 
							AccountID: accountUUID,
 | 
				
			||||||
		Status:    "Reconciled",
 | 
							Status:    "Reconciled",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	transactionUUID, err := db.CreateTransaction(c.Request.Context(), createTransaction)
 | 
						transactionUUID, err := db.CreateTransaction(c.Request().Context(), createTransaction)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("insert new transaction: %w", err)
 | 
							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 {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("get created transaction: %w", err)
 | 
							return nil, fmt.Errorf("get created transaction: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,8 +7,8 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer"
 | 
						"git.javil.eu/jacob1123/budgeteer"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -17,8 +17,8 @@ const (
 | 
				
			|||||||
	ParamName  = "token"
 | 
						ParamName  = "token"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func MustGetToken(c *gin.Context) budgeteer.Token { //nolint:ireturn
 | 
					func MustGetToken(c echo.Context) budgeteer.Token { //nolint:ireturn
 | 
				
			||||||
	token := c.MustGet(ParamName)
 | 
						token := c.Get(ParamName)
 | 
				
			||||||
	if token, ok := token.(budgeteer.Token); ok {
 | 
						if token, ok := token.(budgeteer.Token); ok {
 | 
				
			||||||
		return token
 | 
							return token
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -26,31 +26,32 @@ func MustGetToken(c *gin.Context) budgeteer.Token { //nolint:ireturn
 | 
				
			|||||||
	panic("Token is not a valid Token")
 | 
						panic("Token is not a valid Token")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, *ErrorResponse) { //nolint:ireturn
 | 
					func (h *Handler) verifyLogin(c echo.Context) (budgeteer.Token, error) { //nolint:ireturn
 | 
				
			||||||
	tokenString := c.GetHeader(HeaderName)
 | 
						tokenString := c.Request().Header.Get(HeaderName)
 | 
				
			||||||
	if len(tokenString) <= len(Bearer) {
 | 
						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:]
 | 
						tokenString = tokenString[7:]
 | 
				
			||||||
	token, err := h.TokenVerifier.VerifyToken(tokenString)
 | 
						token, err := h.TokenVerifier.VerifyToken(tokenString)
 | 
				
			||||||
	if err != nil {
 | 
						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
 | 
						return token, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) verifyLoginWithForbidden(c *gin.Context) {
 | 
					func (h *Handler) verifyLoginWithForbidden(next echo.HandlerFunc) echo.HandlerFunc {
 | 
				
			||||||
	token, err := h.verifyLogin(c)
 | 
						return func(c echo.Context) error {
 | 
				
			||||||
	if err != nil {
 | 
							token, err := h.verifyLogin(c)
 | 
				
			||||||
		// c.Header("WWW-Authenticate", "Bearer")
 | 
							if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusForbidden, err)
 | 
								// c.Header("WWW-Authenticate", "Bearer")
 | 
				
			||||||
		return
 | 
								return echo.NewHTTPError(http.StatusForbidden, err)
 | 
				
			||||||
	}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.Set(ParamName, token)
 | 
							c.Set(ParamName, token)
 | 
				
			||||||
	c.Next()
 | 
							return next(c)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type loginInformation struct {
 | 
					type loginInformation struct {
 | 
				
			||||||
@@ -58,37 +59,35 @@ type loginInformation struct {
 | 
				
			|||||||
	User     string `json:"user"`
 | 
						User     string `json:"user"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) loginPost(c *gin.Context) {
 | 
					func (h *Handler) loginPost(c echo.Context) error {
 | 
				
			||||||
	var login loginInformation
 | 
						var login loginInformation
 | 
				
			||||||
	err := c.BindJSON(&login)
 | 
						err := c.Bind(&login)
 | 
				
			||||||
	if err != nil {
 | 
						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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusUnauthorized, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
 | 
						if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusUnauthorized, err)
 | 
							return fmt.Errorf("verify password: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	token, err := h.TokenVerifier.CreateToken(&user)
 | 
						token, err := h.TokenVerifier.CreateToken(&user)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusUnauthorized, err)
 | 
							return fmt.Errorf("create token: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	go h.UpdateLastLogin(user.ID)
 | 
						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 {
 | 
						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 {
 | 
					type LoginResponse struct {
 | 
				
			||||||
@@ -103,29 +102,25 @@ type registerInformation struct {
 | 
				
			|||||||
	Name     string `json:"name"`
 | 
						Name     string `json:"name"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) registerPost(c *gin.Context) {
 | 
					func (h *Handler) registerPost(c echo.Context) error {
 | 
				
			||||||
	var register registerInformation
 | 
						var register registerInformation
 | 
				
			||||||
	err := c.BindJSON(®ister)
 | 
						err := c.Bind(®ister)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"error parsing body"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "error parsing body")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if register.Email == "" || register.Password == "" || register.Name == "" {
 | 
						if register.Email == "" || register.Password == "" || register.Name == "" {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"e-mail, password and name are required"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "e-mail, password and name are required")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err = h.Service.GetUserByUsername(c.Request.Context(), register.Email)
 | 
						_, err = h.Service.GetUserByUsername(c.Request().Context(), register.Email)
 | 
				
			||||||
	if err == nil {
 | 
						if err == nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"email is already taken"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "email is already taken")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hash, err := h.CredentialsVerifier.Hash(register.Password)
 | 
						hash, err := h.CredentialsVerifier.Hash(register.Password)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return fmt.Errorf("hash password: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	createUser := postgres.CreateUserParams{
 | 
						createUser := postgres.CreateUserParams{
 | 
				
			||||||
@@ -133,24 +128,24 @@ func (h *Handler) registerPost(c *gin.Context) {
 | 
				
			|||||||
		Password: hash,
 | 
							Password: hash,
 | 
				
			||||||
		Email:    register.Email,
 | 
							Email:    register.Email,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	user, err := h.Service.CreateUser(c.Request.Context(), createUser)
 | 
						user, err := h.Service.CreateUser(c.Request().Context(), createUser)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	token, err := h.TokenVerifier.CreateToken(&user)
 | 
						token, err := h.TokenVerifier.CreateToken(&user)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusUnauthorized, err)
 | 
							return fmt.Errorf("create token: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	go h.UpdateLastLogin(user.ID)
 | 
						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 {
 | 
						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) {
 | 
					func (h *Handler) UpdateLastLogin(userID uuid.UUID) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,8 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type NewTransactionPayload struct {
 | 
					type NewTransactionPayload struct {
 | 
				
			||||||
@@ -27,42 +27,37 @@ type NewTransactionPayload struct {
 | 
				
			|||||||
	State      string        `json:"state"`
 | 
						State      string        `json:"state"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) updateTransaction(c *gin.Context) {
 | 
					func (h *Handler) updateTransaction(c echo.Context) error {
 | 
				
			||||||
	var payload NewTransactionPayload
 | 
						var payload NewTransactionPayload
 | 
				
			||||||
	err := c.BindJSON(&payload)
 | 
						err := c.Bind(&payload)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amount, err := numeric.Parse(payload.Amount)
 | 
						amount, err := numeric.Parse(payload.Amount)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactionID := c.Param("transactionid")
 | 
						transactionID := c.Param("transactionid")
 | 
				
			||||||
	transactionUUID, err := uuid.Parse(transactionID)
 | 
						transactionUUID, err := uuid.Parse(transactionID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"transactionid missing from URL"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "transactionid missing from URL")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h.UpdateTransaction(payload, amount, transactionUUID, c)
 | 
						return h.UpdateTransaction(payload, amount, transactionUUID, c)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) newTransaction(c *gin.Context) {
 | 
					func (h *Handler) newTransaction(c echo.Context) error {
 | 
				
			||||||
	var payload NewTransactionPayload
 | 
						var payload NewTransactionPayload
 | 
				
			||||||
	err := c.BindJSON(&payload)
 | 
						err := c.Bind(&payload)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amount, err := numeric.Parse(payload.Amount)
 | 
						amount, err := numeric.Parse(payload.Amount)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
 | 
							return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("amount: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	newTransaction := postgres.CreateTransactionParams{
 | 
						newTransaction := postgres.CreateTransactionParams{
 | 
				
			||||||
@@ -77,41 +72,38 @@ func (h *Handler) newTransaction(c *gin.Context) {
 | 
				
			|||||||
	if payload.Payee.Type == "account" {
 | 
						if payload.Payee.Type == "account" {
 | 
				
			||||||
		groupID, err := h.CreateTransferForOtherAccount(newTransaction, amount, payload, c)
 | 
							groupID, err := h.CreateTransferForOtherAccount(newTransaction, amount, payload, c)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			c.AbortWithError(http.StatusInternalServerError, err)
 | 
								return echo.NewHTTPError(http.StatusInternalServerError, err)
 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		newTransaction.GroupID = groupID
 | 
							newTransaction.GroupID = groupID
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		payeeID, err := GetPayeeID(c.Request.Context(), payload, h)
 | 
							payeeID, err := GetPayeeID(c.Request().Context(), payload, h)
 | 
				
			||||||
		if err != nil {
 | 
							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
 | 
							newTransaction.PayeeID = payeeID
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactionUUID, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
 | 
						transactionUUID, err := h.Service.CreateTransaction(c.Request().Context(), newTransaction)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("create transaction: %w", err))
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("create transaction: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transaction, err := h.Service.GetTransaction(c.Request.Context(), transactionUUID)
 | 
						transaction, err := h.Service.GetTransaction(c.Request().Context(), transactionUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.JSON(http.StatusOK, transaction)
 | 
						return c.JSON(http.StatusOK, transaction)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeric.Numeric, transactionUUID uuid.UUID, c *gin.Context) {
 | 
					func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeric.Numeric, transactionUUID uuid.UUID, c echo.Context) error {
 | 
				
			||||||
	if amount.IsZero() {
 | 
						if amount.IsZero() {
 | 
				
			||||||
		err := h.Service.DeleteTransaction(c.Request.Context(), transactionUUID)
 | 
							err := h.Service.DeleteTransaction(c.Request().Context(), transactionUUID)
 | 
				
			||||||
		if err != nil {
 | 
							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{
 | 
						editTransaction := postgres.UpdateTransactionParams{
 | 
				
			||||||
@@ -123,22 +115,20 @@ func (h *Handler) UpdateTransaction(payload NewTransactionPayload, amount numeri
 | 
				
			|||||||
		ID:         transactionUUID,
 | 
							ID:         transactionUUID,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err := h.Service.UpdateTransaction(c.Request.Context(), editTransaction)
 | 
						err := h.Service.UpdateTransaction(c.Request().Context(), editTransaction)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("edit transaction: %w", err))
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("edit transaction: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transaction, err := h.Service.GetTransaction(c.Request.Context(), transactionUUID)
 | 
						transaction, err := h.Service.GetTransaction(c.Request().Context(), transactionUUID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("get transaction: %w", err))
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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.GroupID = uuid.NullUUID{UUID: uuid.New(), Valid: true}
 | 
				
			||||||
	newTransaction.Amount = amount.Neg()
 | 
						newTransaction.Amount = amount.Neg()
 | 
				
			||||||
	newTransaction.AccountID = payload.Payee.ID.UUID
 | 
						newTransaction.AccountID = payload.Payee.ID.UUID
 | 
				
			||||||
@@ -146,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.
 | 
						// transfer does not need category. Either it's account is off-budget or no category was supplied.
 | 
				
			||||||
	newTransaction.CategoryID = uuid.NullUUID{}
 | 
						newTransaction.CategoryID = uuid.NullUUID{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
 | 
						_, err := h.Service.CreateTransaction(c.Request().Context(), newTransaction)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return uuid.NullUUID{}, fmt.Errorf("create transfer transaction: %w", err)
 | 
							return uuid.NullUUID{}, fmt.Errorf("create transfer transaction: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,10 +5,10 @@ import (
 | 
				
			|||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getDate(c *gin.Context) (Month, error) {
 | 
					func getDate(c echo.Context) (Month, error) {
 | 
				
			||||||
	var year, month int
 | 
						var year, month int
 | 
				
			||||||
	yearString := c.Param("year")
 | 
						yearString := c.Param("year")
 | 
				
			||||||
	monthString := c.Param("month")
 | 
						monthString := c.Param("month")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,117 +1,107 @@
 | 
				
			|||||||
package server
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
						"git.javil.eu/jacob1123/budgeteer/postgres"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
					 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) importYNAB(c *gin.Context) {
 | 
					func (h *Handler) importYNAB(c echo.Context) error {
 | 
				
			||||||
	budgetID, succ := c.Params.Get("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	if !succ {
 | 
						if budgetID == "" {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if !succ {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactionsFile, err := c.FormFile("transactions")
 | 
						transactionsFile, err := c.FormFile("transactions")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return fmt.Errorf("get transactions: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	transactions, err := transactionsFile.Open()
 | 
						transactions, err := transactionsFile.Open()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return fmt.Errorf("open transactions: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = ynab.ImportTransactions(c.Request.Context(), transactions)
 | 
						err = ynab.ImportTransactions(c.Request().Context(), transactions)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assignmentsFile, err := c.FormFile("assignments")
 | 
						assignmentsFile, err := c.FormFile("assignments")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return fmt.Errorf("get assignments: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assignments, err := assignmentsFile.Open()
 | 
						assignments, err := assignmentsFile.Open()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return fmt.Errorf("open assignments: %w", err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = ynab.ImportAssignments(c.Request.Context(), assignments)
 | 
						err = ynab.ImportAssignments(c.Request().Context(), assignments)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) exportYNABTransactions(c *gin.Context) {
 | 
					func (h *Handler) exportYNABTransactions(c echo.Context) error {
 | 
				
			||||||
	budgetID, succ := c.Params.Get("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	if !succ {
 | 
						if budgetID == "" {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if !succ {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = ynab.ExportTransactions(c.Request.Context(), c.Writer)
 | 
						err = ynab.ExportTransactions(c.Request().Context(), c.Response().Writer)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return err
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (h *Handler) exportYNABAssignments(c *gin.Context) {
 | 
					func (h *Handler) exportYNABAssignments(c echo.Context) error {
 | 
				
			||||||
	budgetID, succ := c.Params.Get("budgetid")
 | 
						budgetID := c.Param("budgetid")
 | 
				
			||||||
	if !succ {
 | 
						if budgetID == "" {
 | 
				
			||||||
		c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
 | 
							return echo.NewHTTPError(http.StatusBadRequest, "no budget_id specified")
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	budgetUUID, err := uuid.Parse(budgetID)
 | 
						budgetUUID, err := uuid.Parse(budgetID)
 | 
				
			||||||
	if !succ {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusBadRequest, err)
 | 
							return echo.NewHTTPError(http.StatusBadRequest, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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 {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = ynab.ExportAssignments(c.Request.Context(), c.Writer)
 | 
						err = ynab.ExportAssignments(c.Request().Context(), c.Response().Writer)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		c.AbortWithError(http.StatusInternalServerError, err)
 | 
							return echo.NewHTTPError(http.StatusInternalServerError, err)
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,11 +9,25 @@ export function GET(path: string) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function POST(path: string, body: FormData | string | null) {
 | 
					export function FORM(path: string, body: FormData) {
 | 
				
			||||||
    const sessionStore = useSessionStore();
 | 
					    const sessionStore = useSessionStore();
 | 
				
			||||||
    return fetch(BASE_URL + path, {
 | 
					    return fetch(BASE_URL + path, {
 | 
				
			||||||
        method: "POST",
 | 
					        method: "POST",
 | 
				
			||||||
        headers: sessionStore.AuthHeaders,
 | 
					        headers: {
 | 
				
			||||||
 | 
					          ...sessionStore.AuthHeaders,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        body: body,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function POST(path: string, body: string | null) {
 | 
				
			||||||
 | 
					    const sessionStore = useSessionStore();
 | 
				
			||||||
 | 
					    return fetch(BASE_URL + path, {
 | 
				
			||||||
 | 
					        method: "POST",
 | 
				
			||||||
 | 
					        headers: {
 | 
				
			||||||
 | 
					          ...sessionStore.AuthHeaders,
 | 
				
			||||||
 | 
							  "Content-Type": "application/json"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        body: body,
 | 
					        body: body,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,10 +11,10 @@ export interface Suggestion {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = defineProps<{
 | 
					const props = defineProps<{
 | 
				
			||||||
    text: string,
 | 
					    text: string | null,
 | 
				
			||||||
    id: string | undefined,
 | 
					    id: string | null,
 | 
				
			||||||
    model: string,
 | 
					    model: string,
 | 
				
			||||||
    type?: string | undefined,
 | 
					    type?: string | null,
 | 
				
			||||||
}>();
 | 
					}>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const SearchQuery = ref(props.text || "");
 | 
					const SearchQuery = ref(props.text || "");
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										49
									
								
								web/src/components/BudgetingCategory.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								web/src/components/BudgetingCategory.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					<script lang="ts" setup>
 | 
				
			||||||
 | 
					import { computed, ref, watch } from 'vue';
 | 
				
			||||||
 | 
					import { useAccountStore } from '../stores/budget-account';
 | 
				
			||||||
 | 
					import { Category, useCategoryStore } from '../stores/category';
 | 
				
			||||||
 | 
					import Currency from './Currency.vue'
 | 
				
			||||||
 | 
					import Input from './Input.vue';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = defineProps<{category:Category, year: number, month: number}>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const assigned = ref(props.category.Assigned);
 | 
				
			||||||
 | 
					watch(() => props.category.Assigned, () =>{ assigned.value = props.category.Assigned});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const accountStore = useAccountStore();
 | 
				
			||||||
 | 
					const categoryStore = useCategoryStore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function assignedChanged(_e : Event, category : Category){
 | 
				
			||||||
 | 
					  categoryStore.SetAssigned(category, props.year, props.month, assigned.value);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template
 | 
				
			||||||
 | 
					  v-for="category in getCategoriesForGroup(group)"
 | 
				
			||||||
 | 
					  :key="category.ID"
 | 
				
			||||||
 | 
					>
 | 
				
			||||||
 | 
					  <div
 | 
				
			||||||
 | 
					    class="contents"
 | 
				
			||||||
 | 
					  >
 | 
				
			||||||
 | 
					    <span
 | 
				
			||||||
 | 
					      class="whitespace-nowrap overflow-hidden"
 | 
				
			||||||
 | 
					    >{{ category.Name }}</span>
 | 
				
			||||||
 | 
					    <Currency
 | 
				
			||||||
 | 
					      :value="category.AvailableLastMonth"
 | 
				
			||||||
 | 
					      class="hidden lg:block"
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
 | 
					    <Input
 | 
				
			||||||
 | 
					      v-model="assigned"
 | 
				
			||||||
 | 
					      type="number"
 | 
				
			||||||
 | 
					      class="hidden sm:block mx-2 text-right"
 | 
				
			||||||
 | 
					      @input="(evt : Event) => assignedChanged(evt, category)"
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
 | 
					    <Currency
 | 
				
			||||||
 | 
					      :value="category.Activity"
 | 
				
			||||||
 | 
					      class="hidden sm:block"
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
 | 
					    <Currency
 | 
				
			||||||
 | 
					      :value="accountStore.GetCategoryAvailable(category)"
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
							
								
								
									
										66
									
								
								web/src/components/BudgetingCategoryGroup.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								web/src/components/BudgetingCategoryGroup.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					<script lang="ts" setup>
 | 
				
			||||||
 | 
					import { computed, ref } from 'vue';
 | 
				
			||||||
 | 
					import { useCategoryStore } from '../stores/category';
 | 
				
			||||||
 | 
					import { CategoryGroup } from '../stores/category-group';
 | 
				
			||||||
 | 
					import BudgetingCategory from './BudgetingCategory.vue';
 | 
				
			||||||
 | 
					import Currency from './Currency.vue'
 | 
				
			||||||
 | 
					import CreateCategory from '../dialogs/CreateCategory.vue';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = defineProps<{group: CategoryGroup, year: number, month: number}>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryStore = useCategoryStore();
 | 
				
			||||||
 | 
					const categoriesForGroup = computed(() => categoryStore.GetCategoriesForGroup(props.group));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const expanded = ref(true)
 | 
				
			||||||
 | 
					function toggleGroup() {
 | 
				
			||||||
 | 
					    expanded.value = !expanded.value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const availableLastMonth = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.AvailableLastMonth, 0))
 | 
				
			||||||
 | 
					const assigned = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.Assigned, 0))
 | 
				
			||||||
 | 
					const activity = computed(() => categoriesForGroup.value.reduce((prev, current) => prev + current.Activity, 0))
 | 
				
			||||||
 | 
					const available = computed(() => activity.value+assigned.value+availableLastMonth.value);
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <span
 | 
				
			||||||
 | 
					    class="text-lg font-bold mt-2"
 | 
				
			||||||
 | 
					    @click="toggleGroup()"
 | 
				
			||||||
 | 
					  >{{ (expanded ? "−" : "+") + " " + group.Name }}
 | 
				
			||||||
 | 
					    <CreateCategory :category-group="group.Name" />
 | 
				
			||||||
 | 
					  </span>
 | 
				
			||||||
 | 
					  <Currency
 | 
				
			||||||
 | 
					    :value="availableLastMonth"
 | 
				
			||||||
 | 
					    class="hidden lg:block mt-2"
 | 
				
			||||||
 | 
					    positive-class="text-slate-500"
 | 
				
			||||||
 | 
					    negative-class="text-red-700 dark:text-red-400"
 | 
				
			||||||
 | 
					  />
 | 
				
			||||||
 | 
					  <Currency
 | 
				
			||||||
 | 
					    :value="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="activity"
 | 
				
			||||||
 | 
					    class="hidden sm:block mt-2"
 | 
				
			||||||
 | 
					    positive-class="text-slate-500"
 | 
				
			||||||
 | 
					    negative-class="text-red-700 dark:text-red-400"
 | 
				
			||||||
 | 
					  />
 | 
				
			||||||
 | 
					  <Currency
 | 
				
			||||||
 | 
					    :value="available"
 | 
				
			||||||
 | 
					    class="mt-2"
 | 
				
			||||||
 | 
					    positive-class="text-slate-500"
 | 
				
			||||||
 | 
					    negative-class="text-red-700 dark:text-red-400"
 | 
				
			||||||
 | 
					  />
 | 
				
			||||||
 | 
					  <template
 | 
				
			||||||
 | 
					    v-if="expanded">
 | 
				
			||||||
 | 
					    <BudgetingCategory 
 | 
				
			||||||
 | 
					      v-for="category in categoriesForGroup"
 | 
				
			||||||
 | 
					      :key="category.ID"
 | 
				
			||||||
 | 
					      :category="category"
 | 
				
			||||||
 | 
					      :year="year"
 | 
				
			||||||
 | 
					      :month="month"
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
 | 
					  </template>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
							
								
								
									
										62
									
								
								web/src/components/BudgetingSummary.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								web/src/components/BudgetingSummary.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					<script lang="ts" setup>
 | 
				
			||||||
 | 
					import { computed } from 'vue';
 | 
				
			||||||
 | 
					import { useAccountStore } from '../stores/budget-account';
 | 
				
			||||||
 | 
					import Currency from './Currency.vue';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = defineProps<{
 | 
				
			||||||
 | 
					  year:number,
 | 
				
			||||||
 | 
					  month:number
 | 
				
			||||||
 | 
					}>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const accountStore = useAccountStore();
 | 
				
			||||||
 | 
					const budgeted = computed(() => accountStore.GetBudgeted(props.year, props.month))
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <h1>Budget for {{ month + 1 }}/{{ 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.Assigned+budgeted.Deassigned)>=0?"Budgeted":"Freed" }} this month:
 | 
				
			||||||
 | 
					      </td>
 | 
				
			||||||
 | 
					      <td class="text-right">
 | 
				
			||||||
 | 
					        <Currency :value="-1*(budgeted.Assigned+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>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
@@ -15,7 +15,6 @@ function valueChanged(e: Event) {
 | 
				
			|||||||
      emits('update:modelValue', target.valueAsNumber);
 | 
					      emits('update:modelValue', target.valueAsNumber);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      console.log("STR-INPUT", props.type)
 | 
					 | 
				
			||||||
      emits('update:modelValue', target.value)
 | 
					      emits('update:modelValue', target.value)
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,10 +15,13 @@ const visible = ref(false);
 | 
				
			|||||||
function closeDialog() {
 | 
					function closeDialog() {
 | 
				
			||||||
    visible.value = false;
 | 
					    visible.value = false;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
function openDialog() {
 | 
					
 | 
				
			||||||
    emit("open");
 | 
					function openDialog(e : MouseEvent) {
 | 
				
			||||||
    visible.value = true;
 | 
					  e.stopPropagation();
 | 
				
			||||||
 | 
					  emit("open");
 | 
				
			||||||
 | 
					  visible.value = true;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function submitDialog() {
 | 
					function submitDialog() {
 | 
				
			||||||
    const e = {cancel: false};
 | 
					    const e = {cancel: false};
 | 
				
			||||||
    emit("submit", e);
 | 
					    emit("submit", e);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,9 +16,9 @@ const TX = ref<Transaction>({
 | 
				
			|||||||
    Memo: "",
 | 
					    Memo: "",
 | 
				
			||||||
    Amount: 0,
 | 
					    Amount: 0,
 | 
				
			||||||
    Payee: "",
 | 
					    Payee: "",
 | 
				
			||||||
    PayeeID: undefined,
 | 
					    PayeeID: null,
 | 
				
			||||||
    Category: "",
 | 
					    Category: "",
 | 
				
			||||||
    CategoryID: undefined,
 | 
					    CategoryID: null,
 | 
				
			||||||
    CategoryGroup: "",
 | 
					    CategoryGroup: "",
 | 
				
			||||||
    GroupID: "",
 | 
					    GroupID: "",
 | 
				
			||||||
    ID: "",
 | 
					    ID: "",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										53
									
								
								web/src/dialogs/CreateCategory.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								web/src/dialogs/CreateCategory.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					<script lang="ts" setup>
 | 
				
			||||||
 | 
					import { computed, ref } from 'vue';
 | 
				
			||||||
 | 
					import Modal from '../components/Modal.vue';
 | 
				
			||||||
 | 
					import { useAccountStore } from '../stores/budget-account';
 | 
				
			||||||
 | 
					import Input from '../components/Input.vue';
 | 
				
			||||||
 | 
					import { useCategoryStore } from '../stores/category';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryStore = useCategoryStore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = defineProps<{
 | 
				
			||||||
 | 
					  categoryGroup: string
 | 
				
			||||||
 | 
					}>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryName = ref("");
 | 
				
			||||||
 | 
					const error = ref("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function createCategory(e : {cancel:boolean}) : boolean {
 | 
				
			||||||
 | 
					  error.value = "";
 | 
				
			||||||
 | 
					  categoryStore.CreateCategory(props.categoryGroup, categoryName.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <Modal
 | 
				
			||||||
 | 
					    button-text="Create Category"
 | 
				
			||||||
 | 
					    @submit="createCategory"
 | 
				
			||||||
 | 
					  >
 | 
				
			||||||
 | 
					    <template #placeholder>
 | 
				
			||||||
 | 
					      <span class="ml-2">+</span>
 | 
				
			||||||
 | 
					    </template>
 | 
				
			||||||
 | 
					    <div class="mt-2 px-7 py-3">
 | 
				
			||||||
 | 
					      Parent: {{ categoryGroup }}
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="mt-2 px-7 py-3">
 | 
				
			||||||
 | 
					      <Input
 | 
				
			||||||
 | 
					        v-model="categoryName"
 | 
				
			||||||
 | 
					        class="border-2 dark:border-gray-700"
 | 
				
			||||||
 | 
					        type="text"
 | 
				
			||||||
 | 
					        placeholder="Category name"
 | 
				
			||||||
 | 
					        required
 | 
				
			||||||
 | 
					      />
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div
 | 
				
			||||||
 | 
					      v-if="error != ''"
 | 
				
			||||||
 | 
					      class="dark:text-red-300 text-red-700"
 | 
				
			||||||
 | 
					    >
 | 
				
			||||||
 | 
					      {{ error }}
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </Modal>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
							
								
								
									
										44
									
								
								web/src/dialogs/CreateCategoryGroup.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								web/src/dialogs/CreateCategoryGroup.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					<script lang="ts" setup>
 | 
				
			||||||
 | 
					import { ref } from 'vue';
 | 
				
			||||||
 | 
					import Modal from '../components/Modal.vue';
 | 
				
			||||||
 | 
					import Input from '../components/Input.vue';
 | 
				
			||||||
 | 
					import { useCategoryGroupStore } from '../stores/category-group';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryGroupStore = useCategoryGroupStore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryGroupName = ref("");
 | 
				
			||||||
 | 
					const error = ref("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function createCategoryGroup(e : {cancel:boolean}) : boolean {
 | 
				
			||||||
 | 
					  error.value = "";
 | 
				
			||||||
 | 
					  categoryGroupStore.CreateCategoryGroup(categoryGroupName.value);
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <Modal
 | 
				
			||||||
 | 
					    button-text="Create Category Group"
 | 
				
			||||||
 | 
					    @submit="createCategoryGroup"
 | 
				
			||||||
 | 
					  >
 | 
				
			||||||
 | 
					    <template #placeholder>
 | 
				
			||||||
 | 
					      <button class="px-2 py-0 w-full bg-slate-400 rounded-md mt-4">Add Group</button>
 | 
				
			||||||
 | 
					    </template>
 | 
				
			||||||
 | 
					    <div class="mt-2 px-7 py-3">
 | 
				
			||||||
 | 
					      <Input
 | 
				
			||||||
 | 
					        v-model="categoryGroupName"
 | 
				
			||||||
 | 
					        class="border-2 dark:border-gray-700"
 | 
				
			||||||
 | 
					        type="text"
 | 
				
			||||||
 | 
					        placeholder="Category name"
 | 
				
			||||||
 | 
					        required
 | 
				
			||||||
 | 
					      />
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div
 | 
				
			||||||
 | 
					      v-if="error != ''"
 | 
				
			||||||
 | 
					      class="dark:text-red-300 text-red-700"
 | 
				
			||||||
 | 
					    >
 | 
				
			||||||
 | 
					      {{ error }}
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </Modal>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
<script lang="ts" setup>
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { computed, ref, onMounted } from "vue"
 | 
					import { computed, ref, onMounted, watch } from "vue"
 | 
				
			||||||
import Currency from "../components/Currency.vue";
 | 
					import Currency from "../components/Currency.vue";
 | 
				
			||||||
import TransactionRow from "../components/TransactionRow.vue";
 | 
					import TransactionRow from "../components/TransactionRow.vue";
 | 
				
			||||||
import TransactionInputRow from "../components/TransactionInputRow.vue";
 | 
					import TransactionInputRow from "../components/TransactionInputRow.vue";
 | 
				
			||||||
@@ -11,6 +11,8 @@ import Modal from "../components/Modal.vue";
 | 
				
			|||||||
import Input from "../components/Input.vue";
 | 
					import Input from "../components/Input.vue";
 | 
				
			||||||
import Checkbox from "../components/Checkbox.vue";
 | 
					import Checkbox from "../components/Checkbox.vue";
 | 
				
			||||||
import { formatDate } from "../date";
 | 
					import { formatDate } from "../date";
 | 
				
			||||||
 | 
					import DateInput from "../components/DateInput.vue";
 | 
				
			||||||
 | 
					import Autocomplete from '../components/Autocomplete.vue'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
defineProps<{
 | 
					defineProps<{
 | 
				
			||||||
    budgetid: string
 | 
					    budgetid: string
 | 
				
			||||||
@@ -28,17 +30,71 @@ const transactions = useTransactionsStore();
 | 
				
			|||||||
onMounted(() => {
 | 
					onMounted(() => {
 | 
				
			||||||
  transactions.GetProblematicTransactions();
 | 
					  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>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="grid grid-cols-[1fr_auto]">
 | 
					  <div class="grid grid-cols-[1fr_auto]">
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <h1 class="inline">
 | 
					      <h1 class="inline">
 | 
				
			||||||
        Problematic Transactions
 | 
					        {{ hasFilters ? "Filtered" : "Problematic" }} Transactions
 | 
				
			||||||
      </h1>
 | 
					      </h1>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </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>
 | 
					  <table>
 | 
				
			||||||
    <tr class="font-bold">
 | 
					    <tr class="font-bold">
 | 
				
			||||||
      <td class="hidden md:block" style="width: 90px;">Date</td>
 | 
					      <td class="hidden md:block" style="width: 90px;">Date</td>
 | 
				
			||||||
@@ -49,7 +105,7 @@ onMounted(() => {
 | 
				
			|||||||
      <td class="text-right">Amount</td>
 | 
					      <td class="text-right">Amount</td>
 | 
				
			||||||
    </tr>
 | 
					    </tr>
 | 
				
			||||||
    <TransactionRow
 | 
					    <TransactionRow
 | 
				
			||||||
      v-for="(transaction, index) in transactions.ProblematicTransactionsList"
 | 
					      v-for="(transaction, index) in transactionsList"
 | 
				
			||||||
      :key="transaction.ID"
 | 
					      :key="transaction.ID"
 | 
				
			||||||
      :with-account="true"
 | 
					      :with-account="true"
 | 
				
			||||||
      :transactionid="transaction.ID"
 | 
					      :transactionid="transaction.ID"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ function toggleMenu() {
 | 
				
			|||||||
        <router-link :to="'/budget/' + CurrentBudgetID + '/budgeting'">Budget</router-link>
 | 
					        <router-link :to="'/budget/' + CurrentBudgetID + '/budgeting'">Budget</router-link>
 | 
				
			||||||
        <br>
 | 
					        <br>
 | 
				
			||||||
        <!--<router-link :to="'/budget/'+CurrentBudgetID+'/reports'">Reports</router-link>-->
 | 
					        <!--<router-link :to="'/budget/'+CurrentBudgetID+'/reports'">Reports</router-link>-->
 | 
				
			||||||
        <router-link :to="'/budget/'+CurrentBudgetID+'/problematic-transactions'">Problematic Transactions</router-link>
 | 
					        <router-link :to="'/budget/'+CurrentBudgetID+'/problematic-transactions'">Transactions</router-link>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
      <li class="bg-slate-200 dark:bg-slate-700 my-2 p-2 px-3">
 | 
					      <li class="bg-slate-200 dark:bg-slate-700 my-2 p-2 px-3">
 | 
				
			||||||
        <div class="flex flex-row justify-between font-bold">
 | 
					        <div class="flex flex-row justify-between font-bold">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,14 @@
 | 
				
			|||||||
<script lang="ts" setup>
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { computed, onMounted, ref, watchEffect } from "vue";
 | 
					import { computed, onMounted, watchEffect } from "vue";
 | 
				
			||||||
import Currency from "../components/Currency.vue";
 | 
					 | 
				
			||||||
import { useBudgetsStore } from "../stores/budget";
 | 
					import { useBudgetsStore } from "../stores/budget";
 | 
				
			||||||
import { Category, useAccountStore } from "../stores/budget-account";
 | 
					import { useCategoryGroupStore } from "../stores/category-group";
 | 
				
			||||||
 | 
					import { useAccountStore } from "../stores/budget-account";
 | 
				
			||||||
import { useSessionStore } from "../stores/session";
 | 
					import { useSessionStore } from "../stores/session";
 | 
				
			||||||
import Input from "../components/Input.vue";
 | 
					 | 
				
			||||||
import { POST } from "../api";
 | 
					import { POST } from "../api";
 | 
				
			||||||
 | 
					import BudgetingSummary from "../components/BudgetingSummary.vue";
 | 
				
			||||||
 | 
					import { Category } from "../stores/category";
 | 
				
			||||||
 | 
					import CreateCategoryGroup from "../dialogs/CreateCategoryGroup.vue";
 | 
				
			||||||
 | 
					import BudgetingCategoryGroup from "../components/BudgetingCategoryGroup.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = defineProps<{
 | 
					const props = defineProps<{
 | 
				
			||||||
    budgetid: string,
 | 
					    budgetid: string,
 | 
				
			||||||
@@ -13,22 +16,12 @@ const props = defineProps<{
 | 
				
			|||||||
    month: string,
 | 
					    month: string,
 | 
				
			||||||
}>()
 | 
					}>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const categoryGroupStore = useCategoryGroupStore()
 | 
				
			||||||
 | 
					const categoryGroups = computed(() => [...categoryGroupStore.CategoryGroups.values()]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const budgetsStore = useBudgetsStore();
 | 
					const budgetsStore = useBudgetsStore();
 | 
				
			||||||
const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID);
 | 
					const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const accountStore = useAccountStore();
 | 
					 | 
				
			||||||
const categoriesForMonth = accountStore.CategoriesForMonthAndGroup;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function GetCategories(group: string) {
 | 
					 | 
				
			||||||
    return [...categoriesForMonth(selected.value.Year, selected.value.Month, group)];
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const groupsForMonth = accountStore.CategoryGroupsForMonth;
 | 
					 | 
				
			||||||
const GroupsForMonth = computed(() => {
 | 
					 | 
				
			||||||
    return [...groupsForMonth(selected.value.Year, selected.value.Month)];
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const previous = computed(() => ({
 | 
					const previous = computed(() => ({
 | 
				
			||||||
    Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(),
 | 
					    Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(),
 | 
				
			||||||
    Month: new Date(selected.value.Year, selected.value.Month - 1, 1).getMonth(),
 | 
					    Month: new Date(selected.value.Year, selected.value.Month - 1, 1).getMonth(),
 | 
				
			||||||
@@ -55,77 +48,10 @@ onMounted(() => {
 | 
				
			|||||||
    useSessionStore().setTitle("Budget for " + selected.value.Month + "/" + selected.value.Year);
 | 
					    useSessionStore().setTitle("Budget for " + selected.value.Month + "/" + selected.value.Year);
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
const expandedGroups = ref<Map<string, boolean>>(new Map<string, boolean>())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function toggleGroup(group: { Name: string, Expand: boolean }) {
 | 
					 | 
				
			||||||
    expandedGroups.value.set(group.Name, !(expandedGroups.value.get(group.Name) ?? group.Expand))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <h1>Budget for {{ selected.Month + 1 }}/{{ selected.Year }}</h1>
 | 
					  <BudgetingSummary :year="selected.Year" :month="selected.Month" />
 | 
				
			||||||
  <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>
 | 
					  <div>
 | 
				
			||||||
    <router-link
 | 
					    <router-link
 | 
				
			||||||
      :to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month"
 | 
					      :to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month"
 | 
				
			||||||
@@ -152,68 +78,13 @@ const budgeted = computed(() => accountStore.GetBudgeted(selected.value.Year, se
 | 
				
			|||||||
    <span class="hidden sm:block text-right">Assigned</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">Activity</span>
 | 
				
			||||||
    <span class="hidden sm:block text-right">Available</span>
 | 
					    <span class="hidden sm:block text-right">Available</span>
 | 
				
			||||||
    <template
 | 
					    <BudgetingCategoryGroup
 | 
				
			||||||
      v-for="group in GroupsForMonth"
 | 
					      v-for="group in categoryGroups"
 | 
				
			||||||
      :key="group.Name"
 | 
					      :key="group.Name"
 | 
				
			||||||
    >
 | 
					      :group="group"
 | 
				
			||||||
      <span
 | 
					      :year="selected.Year"
 | 
				
			||||||
        class="text-lg font-bold mt-2"
 | 
					      :month="selected.Month"
 | 
				
			||||||
        @click="toggleGroup(group)"
 | 
					    />
 | 
				
			||||||
      >{{ (getGroupState(group) ? "−" : "+") + " " + group.Name }}</span>
 | 
					    <CreateCategoryGroup />
 | 
				
			||||||
      <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>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,10 +3,6 @@ import NewBudget from '../dialogs/NewBudget.vue';
 | 
				
			|||||||
import RowCard from '../components/RowCard.vue';
 | 
					import RowCard from '../components/RowCard.vue';
 | 
				
			||||||
import { useSessionStore } from '../stores/session';
 | 
					import { useSessionStore } from '../stores/session';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = defineProps<{
 | 
					 | 
				
			||||||
    budgetid: string,
 | 
					 | 
				
			||||||
}>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const BudgetsList = useSessionStore().BudgetsList;
 | 
					const BudgetsList = useSessionStore().BudgetsList;
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,7 +20,7 @@ const BudgetsList = useSessionStore().BudgetsList;
 | 
				
			|||||||
        <!--<svg class="w-24"></svg>-->
 | 
					        <!--<svg class="w-24"></svg>-->
 | 
				
			||||||
        <p class="w-24 text-center text-6xl" />
 | 
					        <p class="w-24 text-center text-6xl" />
 | 
				
			||||||
        <span class="text-lg">{{ budget.Name
 | 
					        <span class="text-lg">{{ budget.Name
 | 
				
			||||||
        }}{{ budget.ID == budgetid ? " *" : "" }}</span>
 | 
					        }}</span>
 | 
				
			||||||
      </router-link>
 | 
					      </router-link>
 | 
				
			||||||
    </RowCard>
 | 
					    </RowCard>
 | 
				
			||||||
    <NewBudget />
 | 
					    <NewBudget />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,14 @@
 | 
				
			|||||||
import { defineStore } from "pinia";
 | 
					import { defineStore } from "pinia";
 | 
				
			||||||
import { GET, POST } from "../api";
 | 
					import { GET, POST } from "../api";
 | 
				
			||||||
import { useBudgetsStore } from "./budget";
 | 
					import { useBudgetsStore } from "./budget";
 | 
				
			||||||
 | 
					import { Category, useCategoryStore } from "./category";
 | 
				
			||||||
 | 
					import { useCategoryGroupStore } from "./category-group";
 | 
				
			||||||
import { useSessionStore } from "./session";
 | 
					import { useSessionStore } from "./session";
 | 
				
			||||||
import { useTransactionsStore } from "./transactions";
 | 
					import { Transaction, useTransactionsStore } from "./transactions";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface State {
 | 
					interface State {
 | 
				
			||||||
    Accounts: Map<string, Account>;
 | 
					    Accounts: Map<string, Account>;
 | 
				
			||||||
    CurrentAccountID: string | null;
 | 
					    CurrentAccountID: string | null;
 | 
				
			||||||
    Categories: Map<string, Category>;
 | 
					 | 
				
			||||||
    Months: Map<number, Map<number, Map<string, Category>>>;
 | 
					    Months: Map<number, Map<number, Map<string, Category>>>;
 | 
				
			||||||
    Available: number,
 | 
					    Available: number,
 | 
				
			||||||
    OverspentLastMonth: number,
 | 
					    OverspentLastMonth: number,
 | 
				
			||||||
@@ -22,7 +23,6 @@ export interface Account {
 | 
				
			|||||||
    ClearedBalance: number;
 | 
					    ClearedBalance: number;
 | 
				
			||||||
    WorkingBalance: number;
 | 
					    WorkingBalance: number;
 | 
				
			||||||
    ReconciledBalance: number;
 | 
					    ReconciledBalance: number;
 | 
				
			||||||
    Transactions: string[];
 | 
					 | 
				
			||||||
    LastReconciled: NullDate;
 | 
					    LastReconciled: NullDate;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,15 +31,6 @@ interface NullDate {
 | 
				
			|||||||
    Time: Date;
 | 
					    Time: Date;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Category {
 | 
					 | 
				
			||||||
    ID: string;
 | 
					 | 
				
			||||||
    Group: string;
 | 
					 | 
				
			||||||
    Name: string;
 | 
					 | 
				
			||||||
    AvailableLastMonth: number;
 | 
					 | 
				
			||||||
    Assigned: number;
 | 
					 | 
				
			||||||
    Activity: number;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
interface BudgetedAmounts {
 | 
					interface BudgetedAmounts {
 | 
				
			||||||
    Assigned: number,
 | 
					    Assigned: number,
 | 
				
			||||||
    Deassigned: number,
 | 
					    Deassigned: number,
 | 
				
			||||||
@@ -54,7 +45,6 @@ export const useAccountStore = defineStore("budget/account", {
 | 
				
			|||||||
        Months: new Map<number, Map<number, Map<string, Category>>>(),
 | 
					        Months: new Map<number, Map<number, Map<string, Category>>>(),
 | 
				
			||||||
        Available: 0,
 | 
					        Available: 0,
 | 
				
			||||||
        OverspentLastMonth: 0,
 | 
					        OverspentLastMonth: 0,
 | 
				
			||||||
        Categories: new Map<string, Category>(),
 | 
					 | 
				
			||||||
        Assignments: [],
 | 
					        Assignments: [],
 | 
				
			||||||
    }),
 | 
					    }),
 | 
				
			||||||
    getters: {
 | 
					    getters: {
 | 
				
			||||||
@@ -130,15 +120,10 @@ export const useAccountStore = defineStore("budget/account", {
 | 
				
			|||||||
                            Expand: prev.Name != "Hidden Categories",
 | 
					                            Expand: prev.Name != "Hidden Categories",
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        categoryGroups[categoryGroups.length - 1].Available +=
 | 
					                        categoryGroups[categoryGroups.length - 1].Available += this.GetCategoryAvailable(category);
 | 
				
			||||||
                            this.GetCategoryAvailable(category);
 | 
					                        categoryGroups[categoryGroups.length - 1].AvailableLastMonth += category.AvailableLastMonth;
 | 
				
			||||||
                        categoryGroups[
 | 
					                        categoryGroups[categoryGroups.length - 1].Activity += category.Activity;
 | 
				
			||||||
                            categoryGroups.length - 1
 | 
					                        categoryGroups[categoryGroups.length - 1].Assigned += category.Assigned;
 | 
				
			||||||
                        ].AvailableLastMonth += category.AvailableLastMonth;
 | 
					 | 
				
			||||||
                        categoryGroups[categoryGroups.length - 1].Activity +=
 | 
					 | 
				
			||||||
                            category.Activity;
 | 
					 | 
				
			||||||
                        categoryGroups[categoryGroups.length - 1].Assigned +=
 | 
					 | 
				
			||||||
                            category.Assigned;
 | 
					 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -241,22 +226,25 @@ export const useAccountStore = defineStore("budget/account", {
 | 
				
			|||||||
            available: number,
 | 
					            available: number,
 | 
				
			||||||
            overspentLastMonth: number,
 | 
					            overspentLastMonth: number,
 | 
				
			||||||
        ): void {
 | 
					        ): void {
 | 
				
			||||||
            this.$patch((state) => {
 | 
					          useCategoryStore().AddCategory(...categories)
 | 
				
			||||||
                const yearMap =
 | 
					          useCategoryGroupStore().AddCategoryGroup(...categories.map(x => ({ID: x.CategoryGroupID, Name: x.Group})));
 | 
				
			||||||
                    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);
 | 
					          this.$patch((state) => {
 | 
				
			||||||
                state.Months.set(year, yearMap);
 | 
					            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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                state.Available = available;
 | 
					            yearMap.set(month, monthMap);
 | 
				
			||||||
                state.OverspentLastMonth = overspentLastMonth;
 | 
					            state.Months.set(year, yearMap);
 | 
				
			||||||
            });
 | 
					
 | 
				
			||||||
 | 
					            state.Available = available;
 | 
				
			||||||
 | 
					            state.OverspentLastMonth = overspentLastMonth;
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        logout() {
 | 
					        logout() {
 | 
				
			||||||
            this.$reset();
 | 
					            this.$reset();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
import { defineStore } from "pinia";
 | 
					import { defineStore } from "pinia";
 | 
				
			||||||
import { GET, POST } from "../api";
 | 
					import { GET, POST, FORM } from "../api";
 | 
				
			||||||
import { useAccountStore } from "./budget-account";
 | 
					import { useAccountStore } from "./budget-account";
 | 
				
			||||||
 | 
					import { useCategoryStore } from "./category";
 | 
				
			||||||
import { Budget, useSessionStore } from "./session";
 | 
					import { Budget, useSessionStore } from "./session";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface State {
 | 
					interface State {
 | 
				
			||||||
@@ -24,9 +25,9 @@ export const useBudgetsStore = defineStore("budget", {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    actions: {
 | 
					    actions: {
 | 
				
			||||||
        ImportYNAB(formData: FormData) {
 | 
					        ImportYNAB(formData: FormData) {
 | 
				
			||||||
            return POST(
 | 
					            return FORM(
 | 
				
			||||||
                "/budget/" + this.CurrentBudgetID + "/import/ynab",
 | 
					                "/budget/" + this.CurrentBudgetID + "/import/ynab",
 | 
				
			||||||
                formData
 | 
					                formData,
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async NewBudget(budgetName: string): Promise<void> {
 | 
					        async NewBudget(budgetName: string): Promise<void> {
 | 
				
			||||||
@@ -40,9 +41,13 @@ export const useBudgetsStore = defineStore("budget", {
 | 
				
			|||||||
            sessionStore.Budgets.set(response.ID, response);
 | 
					            sessionStore.Budgets.set(response.ID, response);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async SetCurrentBudget(budgetid: string): Promise<void> {
 | 
					        async SetCurrentBudget(budgetid: string): Promise<void> {
 | 
				
			||||||
 | 
					            if(this.CurrentBudgetID == budgetid)
 | 
				
			||||||
 | 
					              return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.CurrentBudgetID = budgetid;
 | 
					            this.CurrentBudgetID = budgetid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (budgetid == null) return;
 | 
					            if (budgetid == null)
 | 
				
			||||||
 | 
					              return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await this.FetchBudget(budgetid);
 | 
					            await this.FetchBudget(budgetid);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@@ -54,16 +59,16 @@ export const useBudgetsStore = defineStore("budget", {
 | 
				
			|||||||
        MergeBudgetingData(response: any) {
 | 
					        MergeBudgetingData(response: any) {
 | 
				
			||||||
            const accounts = useAccountStore();
 | 
					            const accounts = useAccountStore();
 | 
				
			||||||
            for (const account of response.Accounts || []) {
 | 
					            for (const account of response.Accounts || []) {
 | 
				
			||||||
                const existingAccount = accounts.Accounts.get(account.ID);
 | 
					 | 
				
			||||||
                account.Transactions = existingAccount?.Transactions ?? [];
 | 
					 | 
				
			||||||
                if (account.LastReconciled.Valid)
 | 
					                if (account.LastReconciled.Valid)
 | 
				
			||||||
                    account.LastReconciled.Time = new Date(
 | 
					                    account.LastReconciled.Time = new Date(
 | 
				
			||||||
                        account.LastReconciled.Time
 | 
					                        account.LastReconciled.Time
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
                accounts.Accounts.set(account.ID, account);
 | 
					                accounts.Accounts.set(account.ID, account);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const categories = useCategoryStore();
 | 
				
			||||||
            for (const category of response.Categories || []) {
 | 
					            for (const category of response.Categories || []) {
 | 
				
			||||||
                accounts.Categories.set(category.ID, category);
 | 
					                categories.Categories.set(category.ID, category);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								web/src/stores/category-group.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								web/src/stores/category-group.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					import { defineStore } from "pinia";
 | 
				
			||||||
 | 
					import { POST } from "../api";
 | 
				
			||||||
 | 
					import { useBudgetsStore } from "./budget";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface State {
 | 
				
			||||||
 | 
					    CategoryGroups: Map<string, CategoryGroup>;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface CategoryGroup {
 | 
				
			||||||
 | 
					  ID: string;
 | 
				
			||||||
 | 
					  Name: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const useCategoryGroupStore = defineStore("category-group", {
 | 
				
			||||||
 | 
					  state: (): State => ({
 | 
				
			||||||
 | 
					      CategoryGroups: new Map<string, CategoryGroup>(),
 | 
				
			||||||
 | 
					  }),
 | 
				
			||||||
 | 
					  getters: {
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  actions: {
 | 
				
			||||||
 | 
					    async CreateCategoryGroup(
 | 
				
			||||||
 | 
					      group: string,
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
 | 
					      const result = await POST(
 | 
				
			||||||
 | 
					        "/category-group/new",
 | 
				
			||||||
 | 
					        JSON.stringify({
 | 
				
			||||||
 | 
					          budgetId: useBudgetsStore().CurrentBudgetID,
 | 
				
			||||||
 | 
					          group: group,
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      const response = await result.json();
 | 
				
			||||||
 | 
					      this.AddCategoryGroup(response);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    async AddCategoryGroup(...categoryGroups : CategoryGroup[]){
 | 
				
			||||||
 | 
					      for (const categoryGroup of categoryGroups) {
 | 
				
			||||||
 | 
					        this.CategoryGroups.set(categoryGroup.ID, categoryGroup);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
							
								
								
									
										59
									
								
								web/src/stores/category.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								web/src/stores/category.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					import { defineStore } from "pinia";
 | 
				
			||||||
 | 
					import { POST } from "../api";
 | 
				
			||||||
 | 
					import { useBudgetsStore } from "./budget";
 | 
				
			||||||
 | 
					import { CategoryGroup } from "./category-group";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface State {
 | 
				
			||||||
 | 
					    Categories: Map<string, Category>;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface Category {
 | 
				
			||||||
 | 
					    ID: string;
 | 
				
			||||||
 | 
					    CategoryGroupID: string;
 | 
				
			||||||
 | 
					    Group: string;
 | 
				
			||||||
 | 
					    Name: string;
 | 
				
			||||||
 | 
					    AvailableLastMonth: number;
 | 
				
			||||||
 | 
					    Assigned: number;
 | 
				
			||||||
 | 
					    Activity: number;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const useCategoryStore = defineStore("category", {
 | 
				
			||||||
 | 
					  state: (): State => ({
 | 
				
			||||||
 | 
					      Categories: new Map<string, Category>(),
 | 
				
			||||||
 | 
					  }),
 | 
				
			||||||
 | 
					  getters: {
 | 
				
			||||||
 | 
					    GetCategoriesForGroup(state) {
 | 
				
			||||||
 | 
					      return (group : CategoryGroup) : Category[] => {
 | 
				
			||||||
 | 
					        return [...state.Categories.values()].filter(x => x.CategoryGroupID == group.ID);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  actions: {
 | 
				
			||||||
 | 
					    async CreateCategory(
 | 
				
			||||||
 | 
					      group: string,
 | 
				
			||||||
 | 
					      name: string,
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
 | 
					      const result = await POST(
 | 
				
			||||||
 | 
					        "/category/new",
 | 
				
			||||||
 | 
					        JSON.stringify({
 | 
				
			||||||
 | 
					          budgetId: useBudgetsStore().CurrentBudgetID,
 | 
				
			||||||
 | 
					          name: name,
 | 
				
			||||||
 | 
					          group: group,
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      const response = await result.json();
 | 
				
			||||||
 | 
					      this.AddCategory(response);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    async AddCategory(...categories : Category[]){
 | 
				
			||||||
 | 
					      for (const category of categories) {
 | 
				
			||||||
 | 
					        this.Categories.set(category.ID, category);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    async SetAssigned(category : Category, year : number, month : number, assigned : number){
 | 
				
			||||||
 | 
					      this.Categories.get(category.ID)!.Assigned = assigned;
 | 
				
			||||||
 | 
					      const currentBudgetID = useBudgetsStore().CurrentBudgetID;
 | 
				
			||||||
 | 
					      await POST("/budget/"+currentBudgetID+"/category/" + category.ID + "/" + year + "/" + (month+1),
 | 
				
			||||||
 | 
					        JSON.stringify({Assigned: assigned}));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@@ -8,6 +8,7 @@ interface State {
 | 
				
			|||||||
    Transactions: Map<string, Transaction>;
 | 
					    Transactions: Map<string, Transaction>;
 | 
				
			||||||
    Reconciling: boolean;
 | 
					    Reconciling: boolean;
 | 
				
			||||||
    ProblematicTransactions: Array<string>;
 | 
					    ProblematicTransactions: Array<string>;
 | 
				
			||||||
 | 
					    FilteredTransactions: Array<string>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Transaction {
 | 
					export interface Transaction {
 | 
				
			||||||
@@ -16,12 +17,12 @@ export interface Transaction {
 | 
				
			|||||||
    TransferAccount: string;
 | 
					    TransferAccount: string;
 | 
				
			||||||
    CategoryGroup: string;
 | 
					    CategoryGroup: string;
 | 
				
			||||||
    Category: string;
 | 
					    Category: string;
 | 
				
			||||||
    CategoryID: string | undefined;
 | 
					    CategoryID: string | null;
 | 
				
			||||||
    Memo: string;
 | 
					    Memo: string;
 | 
				
			||||||
    Status: string;
 | 
					    Status: string;
 | 
				
			||||||
    GroupID: string;
 | 
					    GroupID: string;
 | 
				
			||||||
    Payee: string;
 | 
					    Payee: string;
 | 
				
			||||||
    PayeeID: string | undefined;
 | 
					    PayeeID: string | null;
 | 
				
			||||||
    Amount: number;
 | 
					    Amount: number;
 | 
				
			||||||
    Reconciled: boolean;
 | 
					    Reconciled: boolean;
 | 
				
			||||||
    Account: string;
 | 
					    Account: string;
 | 
				
			||||||
@@ -33,6 +34,7 @@ export const useTransactionsStore = defineStore("budget/transactions", {
 | 
				
			|||||||
        Transactions: new Map<string, Transaction>(),
 | 
					        Transactions: new Map<string, Transaction>(),
 | 
				
			||||||
        Reconciling: false,
 | 
					        Reconciling: false,
 | 
				
			||||||
        ProblematicTransactions: new Array<string>(),
 | 
					        ProblematicTransactions: new Array<string>(),
 | 
				
			||||||
 | 
					        FilteredTransactions: new Array<string>(),
 | 
				
			||||||
    }),
 | 
					    }),
 | 
				
			||||||
    getters: {
 | 
					    getters: {
 | 
				
			||||||
        ReconcilingBalance(state): number {
 | 
					        ReconcilingBalance(state): number {
 | 
				
			||||||
@@ -45,9 +47,12 @@ export const useTransactionsStore = defineStore("budget/transactions", {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            return reconciledBalance;
 | 
					            return reconciledBalance;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        TransactionsByDate(state) : Record<string, Transaction[]> {
 | 
					        TransactionsByDate(state) : Record<string, Transaction[]>|undefined{
 | 
				
			||||||
            const accountsStore = useAccountStore();
 | 
					            const accountsStore = useAccountStore();
 | 
				
			||||||
            const allTransactions = [...this.Transactions.values()];
 | 
					            const account = accountsStore.CurrentAccount;
 | 
				
			||||||
 | 
					            if(account === undefined)
 | 
				
			||||||
 | 
					              return undefined;
 | 
				
			||||||
 | 
					            const allTransactions = [...this.Transactions.values()].filter(x => x.AccountID == account.ID);
 | 
				
			||||||
            return groupBy(allTransactions, x => formatDate(x.Date));
 | 
					            return groupBy(allTransactions, x => formatDate(x.Date));
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        TransactionsList(state) : Transaction[] {
 | 
					        TransactionsList(state) : Transaction[] {
 | 
				
			||||||
@@ -58,6 +63,9 @@ export const useTransactionsStore = defineStore("budget/transactions", {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        ProblematicTransactionsList(state) : Transaction[] {
 | 
					        ProblematicTransactionsList(state) : Transaction[] {
 | 
				
			||||||
            return [...state.ProblematicTransactions.map(x => state.Transactions!.get(x)!)];
 | 
					            return [...state.ProblematicTransactions.map(x => state.Transactions!.get(x)!)];
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        FilteredTransactionsList(state) : Transaction[] {
 | 
				
			||||||
 | 
					            return [...state.FilteredTransactions.map(x => state.Transactions!.get(x)!)];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    actions: {
 | 
					    actions: {
 | 
				
			||||||
@@ -80,8 +88,24 @@ export const useTransactionsStore = defineStore("budget/transactions", {
 | 
				
			|||||||
            const budgetStore = useBudgetsStore();
 | 
					            const budgetStore = useBudgetsStore();
 | 
				
			||||||
            const result = await GET("/budget/" + budgetStore.CurrentBudgetID + "/problematic-transactions");
 | 
					            const result = await GET("/budget/" + budgetStore.CurrentBudgetID + "/problematic-transactions");
 | 
				
			||||||
            const response = await result.json();
 | 
					            const response = await result.json();
 | 
				
			||||||
            this.AddTransactions(response.Transactions);
 | 
					            const transactions = response.Transactions ?? [];
 | 
				
			||||||
            this.ProblematicTransactions = [...response.Transactions.map((x : Transaction) => x.ID)];
 | 
					            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) {
 | 
					        async SubmitReconcilation(reconciliationTransactionAmount: number) {
 | 
				
			||||||
            const accountsStore = useAccountStore();
 | 
					            const accountsStore = useAccountStore();
 | 
				
			||||||
@@ -106,18 +130,15 @@ export const useTransactionsStore = defineStore("budget/transactions", {
 | 
				
			|||||||
            const recTrans = response.ReconciliationTransaction;
 | 
					            const recTrans = response.ReconciliationTransaction;
 | 
				
			||||||
            if (recTrans) {
 | 
					            if (recTrans) {
 | 
				
			||||||
                this.AddTransactions([recTrans]);
 | 
					                this.AddTransactions([recTrans]);
 | 
				
			||||||
                account.Transactions.unshift(recTrans.ID);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        logout() {
 | 
					        logout() {
 | 
				
			||||||
            this.$reset();
 | 
					            this.$reset();
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async saveTransaction(payload: string) {
 | 
					        async saveTransaction(payload: string) {
 | 
				
			||||||
            const accountsStore = useAccountStore();
 | 
					 | 
				
			||||||
            const result = await POST("/transaction/new", payload);
 | 
					            const result = await POST("/transaction/new", payload);
 | 
				
			||||||
            const response = (await result.json()) as Transaction;
 | 
					            const response = (await result.json()) as Transaction;
 | 
				
			||||||
            this.AddTransactions([response]);
 | 
					            this.AddTransactions([response]);
 | 
				
			||||||
            accountsStore.CurrentAccount?.Transactions.unshift(response.ID);
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async editTransaction(transactionid: string, payload: string) {
 | 
					        async editTransaction(transactionid: string, payload: string) {
 | 
				
			||||||
            const result = await POST("/transaction/" + transactionid, payload);
 | 
					            const result = await POST("/transaction/" + transactionid, payload);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7272
									
								
								web/yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										7272
									
								
								web/yarn.lock
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user