Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ebradyjobory committed Mar 26, 2016
2 parents 4309bf9 + f177c02 commit af30afa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ Finance.prototype.WACC = function(marketValueOfEquity, marketValueOfDebt, costOf
return Math.round(WACC * 1000) / 10;
};

// PMT calculates the payment for a loan based on constant payments and a constant interest rate
Finance.prototype.PMT = function(fractionalRate, numOfPayments, principal) {
return -principal * fractionalRate/(1-Math.pow(1+fractionalRate,-numOfPayments))
};

if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
module.exports = Finance;
Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ describe('FinanceJS', function() {
cal.WACC(600000, 400000, 6, 5, 35).should.equal(4.9);
});

it('should compute PMT', function() {
// fractional rate, number of payments, loan principal
Number(cal.PMT(0.02,36,-1000000).toFixed(4)).should.equal(39232.8526)
});

});

0 comments on commit af30afa

Please sign in to comment.