Module: LoanCreator::ExcelFormulas
- Included in:
- Standard
- Defined in:
- lib/loan_creator/excel_formulas.rb
Overview
Source: gist.github.com/mattetti/1015948
Instance Method Summary collapse
-
#ipmt(rate, per, nper, pv, fv = 0, type = 0) ⇒ Object
Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
-
#ppmt(rate, per, nper, pv, fv = 0, type = 0) ⇒ Object
Returns the payment on the principal for a given period for an investment based on periodic, constant payments and a constant interest rate.
Instance Method Details
#ipmt(rate, per, nper, pv, fv = 0, type = 0) ⇒ Object
Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
6 7 8 9 10 |
# File 'lib/loan_creator/excel_formulas.rb', line 6 def ipmt(rate, per, nper, pv, fv=0, type=0) p = _pmt(rate, nper, pv, fv, 0); ip = -(pv * _pow1p(rate, per - 1) * rate + p * _pow1pm1(rate, per - 1)) (type == 0) ? ip : ip / (1 + rate) end |
#ppmt(rate, per, nper, pv, fv = 0, type = 0) ⇒ Object
Returns the payment on the principal for a given period for an investment based on periodic, constant payments and a constant interest rate.
14 15 16 17 18 |
# File 'lib/loan_creator/excel_formulas.rb', line 14 def ppmt(rate, per, nper, pv, fv=0, type=0) p = _pmt(rate, nper, pv, fv, type) ip = ipmt(rate, per, nper, pv, fv, type) p - ip end |