GithubHelp home page GithubHelp logo

bradenrayhorn / beans Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 17.76 MB

Self-hosted envelope/zero based budgeting

License: GNU Affero General Public License v3.0

Makefile 0.10% Go 64.67% TypeScript 32.80% CSS 0.11% HTML 0.09% JavaScript 2.23%

beans's People

Contributors

bradenrayhorn avatar dependabot[bot] avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

beans's Issues

Budgetable money

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. โœ…

Category limits

Categories and category groups should be limited to some fixed amount per budget.

Proposed limits:

  • Categories: 250
  • Category Groups: 50

Update error handling

Errors should be wrapped and transformed into HTTP errors if needed. A message should be included in response.

Account limits

Limit the number of accounts that can be created per budget. First suggestion: 50.

Cleanup Amount arithmetic

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.

Verify things don't blow up with big numbers

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.

Add Available to budget header to budget page

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

Handle timezone when finding default month for budget

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.

Invalid date results in 500 error

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.

Validating access in contracts

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()
}

Logging

Standard log format should be figured out.

Add user contract

User logic should be replace with a user contract and appropriate tests.

Unit tests

Add some more unit tests.

  • Authentication middleware
  • Logic services
  • Postgres repositories?

Update to node 18

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.

Tests for http/frontend.go

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.

Beans CLI tests

Add tests for Beans CLI (only command is currently beans migrate. Potentially improve the structure of the code to help with testability.

Jest and ESM

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.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • Update dependency @playwright/test to v1.36.1
  • Update dependency @tanstack/react-query to v4.29.25
  • Update dependency downshift to v7.6.2
  • Update dependency framer-motion to v10.12.22
  • Update dependency react-hook-form to v7.45.2
  • Update typescript-eslint monorepo to v6.1.0 (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • Update dependency downshift to v8

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

docker-compose
docker-compose.yml
  • postgres 15.2
github-actions
.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
gomod
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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

Income categories

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.

Update user tests

  • Move additional user endpoints to user contract.
  • Add HTTP unit test coverage for user endpoints
    • Keep one integration for register/login/me flow
  • Test auth middleware?

Find validation solution

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.

Explore code splitting

Currently code is bundled into one big index.js file, Vite/React should be configured to split this into multiple files.

Add date input

Add a DateInput component that can be used for date inputs.

Only allow valid dates can be entered.

Transition when switching months

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.

Make configurable

Database, http port, etc should be pulled from env config or similar.

beansd and beans should both utilize this config.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.