2.1.1 • Published 7 years ago

balance-growth v2.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

balance-growth

Build Status Coverage Status Latest Stable Version

Calculate monthly balance growth over time.

Installation

npm install balance-growth

Getting start-of-month and end-of-month balances

Transaction amounts are added after the last day of the month and before the first day of the following month.

import {MonthlyBalanceAdjuster} from 'balance-growth';

const adjuster = new MonthlyBalanceAdjuster();
const balances = adjuster.getMonthlyBalances({
  balances: [
    { date: '2016-11-01', balance: 100 },
    { date: '2016-11-15', balance: 328 },
    { date: '2016-12-03', balance: 564 }
  ],
  transactions: [
    { date: '2016-11-02', amount: 200 },
    { date: '2016-12-02', amount: 200 }
  ],
  maxDate: '2017-01-01'
});
console.log(balances);
[
  { "month": "2016-11", "balance": 100, "eomBalance": 160 },
  { "month": "2016-12", "balance": 360, "eomBalance": 364 }
]

Getting balance growth (%) per month

import {BalanceGrowth} from 'balance-growth';

const calculator = new BalanceGrowth();
const growth = calculator.getGrowth({
  balances: [
    { date: '2016-11-01', balance: 100 },
    { date: '2016-11-15', balance: 328 },
    { date: '2016-12-03', balance: 564 }
  ],
  transactions: [
    { date: '2016-11-02', amount: 200 },
    { date: '2016-12-02', amount: 200 }
  ],
  maxDate: '2017-01-01'
});
console.log(growth);
[
  { "month": "2016-11", "balance": 100, "eomBalance": 160, "growth": 60 },
  { "month": "2016-12", "balance": 360, "eomBalance": 364, "growth": 1 }
]

60% growth in november and 1% growth in december

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago