bradenrayhorn / beans Goto Github PK
View Code? Open in Web Editor NEWSelf-hosted envelope/zero based budgeting
License: GNU Affero General Public License v3.0
Self-hosted envelope/zero based budgeting
License: GNU Affero General Public License v3.0
Total money available to budget in a given month should be displayed on the budget page.
The money available should be equal to:
+ sum of all transactions with "income" category in current and previous months
- currently assigned money in all months, including future
Requires #138 to be complete first.
Categories and category groups should be limited to some fixed amount per budget.
Proposed limits:
Errors should be wrapped and transformed into HTTP errors if needed. A message should be included in response.
Limit the number of accounts that can be created per budget. First suggestion: 50.
Validate API response JSON to make sure they fit the defined Typescript types.
Review CORS and cookie policies (SameSite, etc) for security.
And credentials: include
on frontend.
Look into what happens to a pgx db transaction when a context is cancelled. Is the transaction rolled back?
The balance on the accounts page should be reflect the sum of all transactions for each account.
Remove status task and just require all 4 shards to complete. Keeps things simpler.
Amount arithmetic is a bit all over the place in beans/currency.go
. It should be refactored to just be functions, not functions on a struct.
Also check it matters whether apd.Decimal is a pointer.
Fix login page becoming stuck if you input wrong password or other network error occurs.
Should do #240 first.
Very large amounts should either be impossible to be saved or be handled correctly. Make sure both backend and frontend can handle large numbers.
Limiting transactions to a certain amount may be the simplest way to accomplish. Even a $1,000,000
limit should be enough to prevent running into limits.
Javascript max number with precision of 2 decimal digits is 70368744177663 (https://stackoverflow.com/a/57225494). So it would take 70 million transaction of one million dollars to hit that limit.
Current amount available to budget for the month should be displayed on the budget page.
Example:
, May --- June --- February
Income: 0 --- 500 --- 0
To budget: 0 --- 0 --- 380
Electric assigned: 0 --- 50 --- 50
Shopping assigned: 0 --- 20 --- 0
Carryover: 0 --- 430 --- 0
, May --- June --- February
Income: 0 --- 500 --- 0
To budget: 0 --- 430 --- 0
Electric assigned: 0 --- 50 --- 0
Shopping assigned: 0 --- 20 --- 0
Carryover: 0 --- 0 --- 0
When creating the default month for a budget on the get single budget endpoint, server timezone is used to get the current month.
Timezone (or current local time) should be passed in a header and read by the server. This timezone should be used to find the current time and default month.
This prevents the wrong month from being created for the user when calling the endpoint near the end of a month and in a different timezone than the server.
The TestMonth/can_create_and_get
test seems to have a case where it can fail.
https://github.com/bradenrayhorn/beans/actions/runs/3817487468/jobs/6493776991
Logout functionality should be implemented
Amounts that have a comma in them fail to save as transactions, as the frontend is sending a comma.
The amount should be sent as a number, much like the category assigned amount editing on the budget page.
Sending a request with an invalid date format (i.e. 2022-12-0
) results in a 500 error. This should instead return a 422 saying the date (and which json field) was in an invalid format.
Most contract functions do not do access validation.
For example, MonthContract.setCategoryAmount does not validate the month belongs to a budget that the user has access to.
To meet the goal of having the HTTP packing simply handle translate contracts to JSON and HTTP results, the contract package could handle access validation.
However, a logical place to write this access validation must be found.
Also consider how testing access control and whether this ends up in full HTTP integration tests
Potential:
type AuthContext struct {
}
func (auth *AuthContext) User() User {
return User{}
}
type BudgetAuthContext struct {
AuthContext
}
type MonthAuthContext struct {
BudgetAuthContext
}
var x = func() {
auth := AuthContext{}
budget := BudgetAuthContext{auth}
budget.User()
}
Properly handle signals to process and gracefully shutdown
Standard log format should be figured out.
User logic should be replace with a user contract and appropriate tests.
Add some more unit tests.
Include sqlc and migrate docs
Having some problems with the node fetch implementation in tests (remix-run/react-router#10118).
Try update to node 18 at some point in future, it will apparently be fixed.
For now, sticking with node 16 and polyfilling the fetch API.
Eslint, prettier format
Add tests for SPA served from http/frontend.go
. Need to mock the embedded FS.
Probably could setup a mock dist directory somewhere, then change embed_mock.go
to read from there. The prefix "dist" hardcoded in frontend.go
might need to be imported from the web/embed*.go
files to allow it to be customized.
Add tests for Beans CLI (only command is currently beans migrate
. Potentially improve the structure of the code to help with testability.
See post: https://tkdodo.eu/blog/react-query-meets-react-router.
This could result in no changes for the frontend, but worth reviewing.
Look into running Jest (and nextjs build process) in ES modules mode. https://jestjs.io/docs/ecmascript-modules
This would be beneficial as some dependencies (namely ky) are exclusively ES modules. If Jest was running in ESM mode, extra rules to setup proper transformations in the config would not be needed.
Add workflows for go code quality:
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates await pending status checks. To force their creation now, click the checkbox below.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
docker-compose.yml
postgres 15.2
.github/workflows/backend-lint.yml
actions/setup-go v4
actions/checkout v3
.github/workflows/frontend-lint.yml
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
.github/workflows/go.yml
actions/checkout v3
actions/setup-go v4
.github/workflows/playwright.yml
actions/checkout v3
actions/setup-node v3
actions/setup-go v4
actions/upload-artifact v3
.github/workflows/vitest.yml
actions/checkout v3
actions/setup-node v3
go.mod
go 1.20
github.com/segmentio/ksuid v1.0.4
github.com/go-chi/chi/v5 v5.0.10
github.com/cockroachdb/apd/v3 v3.2.0
github.com/go-chi/cors v1.2.1
github.com/golang-migrate/migrate/v4 v4.16.2
github.com/jackc/pgconn v1.14.0
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa@469b46aa5efa
github.com/jackc/pgtype v1.14.0
github.com/jackc/pgx/v4 v4.18.1
github.com/orlangure/gnomock v0.28.0
github.com/rs/zerolog v1.29.1
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.11.0
golang.org/x/net v0.12.0
web/package.json
@chakra-ui/icons 2.0.19
@chakra-ui/react 2.7.1
@chakra-ui/theme-tools 2.0.18
@emotion/react 11.11.1
@emotion/styled 11.11.0
@tanstack/react-query 4.29.23
dayjs 1.11.9
downshift 7.6.1
fraction.js 4.2.0
framer-motion 10.12.21
ky 0.33.3
react 18.2.0
react-dom 18.2.0
react-focus-lock ^2.9.4
react-hook-form 7.45.1
react-number-format 5.2.2
react-router-dom 6.14.1
zustand 4.3.9
@babel/eslint-parser ^7.21.3
@playwright/test 1.36.0
@testing-library/jest-dom 5.16.5
@testing-library/react 14.0.0
@testing-library/user-event 14.4.3
@types/react 18.2.15
@types/react-dom 18.2.7
@typescript-eslint/eslint-plugin ^6.0.0
@typescript-eslint/parser ^6.0.0
@vitejs/plugin-react 4.0.3
babel-preset-react-app ^10.0.1
confusing-browser-globals ^1.0.11
cross-fetch 4.0.0
eslint 8.44.0
eslint-plugin-flowtype ^8.0.3
eslint-plugin-import ^2.27.5
eslint-plugin-jsx-a11y 6.7.1
eslint-plugin-react ^7.32.2
eslint-plugin-react-hooks ^4.6.0
jsdom 22.1.0
msw 1.2.2
prettier 2.8.8
start-server-and-test 2.0.0
typescript 5.1.6
vite 4.4.4
vitest 0.33.0
Certain categories need to have the ability to be marked as "income" categories. This lets us determine if the category should be included in "budgetable" money.
Validate incoming user data.
Ex: cannot create user with no username or no password
All errors should appear at once, not one message at a time.
Left over available money from the previous month in a category should be included in the available total in next month's budget for that same category.
Currently code is bundled into one big index.js file, Vite/React should be configured to split this into multiple files.
Write test structure. Maybe use https://github.com/orlangure/gnomock
Add a DateInput
component that can be used for date inputs.
Only allow valid dates can be entered.
Setup automated action to automatically check for dependency updates. Something like dependabot or renovate.
There is no transition when switching months which can be a little jarring.
Maybe something could slide in/out? At the very least need to get rid of the budget numbers flashing on screen.
Database, http port, etc should be pulled from env config or similar.
beansd
and beans
should both utilize this config.
Cleanup ky setup. Remove extra query parameters (cookie on get me).
Better organize error handling. Add error logger.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.