Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfpb/overall-loan-cost
A node module to calculate the overall cost of a loan.
https://github.com/cfpb/overall-loan-cost
Last synced: about 1 month ago
JSON representation
A node module to calculate the overall cost of a loan.
- Host: GitHub
- URL: https://github.com/cfpb/overall-loan-cost
- Owner: cfpb
- License: cc0-1.0
- Created: 2014-07-28T21:19:36.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-02T17:21:04.000Z (over 10 years ago)
- Last Synced: 2024-04-25T11:02:39.732Z (9 months ago)
- Language: JavaScript
- Size: 221 KB
- Stars: 3
- Watchers: 18
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: COPYING.txt
Awesome Lists containing this project
README
# overall-loan-cost [![Build Status](https://secure.travis-ci.org/cfpb/overall-loan-cost.png?branch=master)](http://travis-ci.org/cfpb/overall-loan-cost)
[![browser support](https://ci.testling.com/cfpb/overall-loan-cost.png)
](https://ci.testling.com/cfpb/overall-loan-cost)> Calculate the overall cost of a loan.
## Installation
First install [node.js](http://nodejs.org/). Then:
```sh
npm install overall-loan-cost --save
```## Usage
## Basic usage
Require the module and pass it an object of loan values (amount borrowed, rate, and total loan term in months):
```javascript
var cost = require('overall-loan-cost');cost({
amountBorrowed: 300000,
rate: 4.25,
totalTerm: 360,
});
```This will return the total cost of the loan, total equity of the loan, and the overall cost of the loan (cost + equity):
```javascript
{
totalCost: 231295.08,
totalEquity: 300000,
overallCost: 531295.08
}
```## Additional values
You can also include the down payment and closing costs of the loan.
```javascript
cost({
amountBorrowed: 300000,
rate: 4.25,
totalTerm: 360,
downPayment: 20000,
closingCosts: 30000
});
```Will return:
```javascript
{
totalCost: 261295.08,
totalEquity: 320000,
overallCost: 581295.08
}
```If you're interested in seeing the costs of a loan for a period that is shorter than the total life of the loan, you can pass the `amortizeTerm` value in months:
```javascript
cost({
amountBorrowed: 255000,
rate: 4.5,
totalTerm: 360,
amortizeTerm: 84,
downPayment: 45000,
closingCosts: 6000
})
```This will return the total cost, total equity, and overall cost after 7 years:
```javascript
{
totalCost: 81449.02,
totalEquity: 78082.98,
overallCost: 159531.99
}
```## Contributing
Please read the [Contributing guidelines](CONTRIBUTING.md).
### Running Tests
We are using [nodeunit](https://github.com/caolan/nodeunit) to test. To run tests, first install nodeunit and any dependencies via npm:
```
npm install
```Run tests with:
```
npm test
```