Skip to content

wailorman/budget-shary

Repository files navigation

Budget Shary

CHANGELOG
LIVE DEMO
BUILDS

What is this?

Goal of this application is to equalize expenses of all persons.

For example, two guys (Mike and Jimmy) want to drink a beer at home. Mike went to a shop and buy two bottles of beer and spent 60 dollars (it's very expensive beer).

The $60 price is High for Mike. He wants to split it with Jimmy to not be left without money.

How?

So. Both guys have the same shares in this budget -- 50%. Mike have $60 expenses. Jimmy -- $0 expenses. That is, monetary shares of each guy = $30 (totalExpenses * share)

We need to equalize own expenses and monetary shares for each person.

By this example, funds of

Mike = 30 - 60 = -30
Jimmy = 30 - 0 = +30

Funds calculated by this formula:

Funds = shareInMonetary - ownExpenses [ + incomeTransactionsTotal - outcomeTransactionsTotal ]

To make funds of each persons equals 0, we can follow two ways:

  1. Reduce monetary share of Jimmy to 0 and increase for Mike to 60.
    But this way Mike will become drunk.
  2. Reduce expenses of Mike to 30 and increase for Jimmy to 30.

I think, Jimmy will like second way. So how to change expenses?
Easy! Jimmy should give $30 to Mike. In other language, we need to create a transaction from Jimmy to Mike with 30 dollars total.

After transaction has been proceeded, let's recalculate funds for beer-guys.

Mike = 30 - 60 + 30 - 0 = 0
Jimmy = 30 - 0 + 0 - 30 = 0

Funds are equalized and now guys are happy.

How to run?

npm start

Developing mode. Starting webpack-dev-server and watch on changes in all files (including sources & tests)

Keeps tests files prebuilded

npm test

Runs all tests

[NODE_ENV=production] npm run build

Runs webpack and compiles all assets (sources & tests)

npm test:unit

Run unit tests (prebuild required)

npm run test:integration
npm run test:integration:dev

Runs integration tests in Karma and PhantomJS. Use :dev suffix to run Karma in watch mode

npm run storybook

Runs Storybook on 9001 port