CFLib.org – Common Function Library Project

Periods(IR, PV, FV, PMT)

Last updated August 2, 2001

Version: 1 | Requires: ColdFusion 5 | Library: FinancialLib

 
Rated 0 time(s). Average Rating: 0

Description:
Calculate the number of payments for a loan when given the payment, interest rate, and value of the loan.

Return Values:
Returns a numeric value.

Example:

view plain print about
Number of Periods = <cfoutput>#Periods(0.08,20000,0,904.55)#</cfoutput>

Parameters:

Name Description Required
IR Interest rate per year (8% = 0.08) Yes
PV Present Value Yes
FV Future Value Yes
PMT Payment Amount Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Calculate the number of payments for a loan.
 * 
 * @param IR      Interest rate per year (8% = 0.08) 
 * @param PV      Present Value 
 * @param FV      Future Value 
 * @param PMT      Payment Amount 
 * @return Returns a numeric value. 
 * @author Raymond Thompson (rayt@qsystems.net) 
 * @version 1, August 2, 2001 
 */

function Periods(IR,PV,FV,PMT) {
  var tir = ir / 12;
  var scale = 0;
  var np=0;
  var tpv = -abs(pv);
  var tfv = -abs(fv);
  var tpmt = abs(pmt);

  if(ArrayLen(Arguments) gt 4) {
    scale = 10^abs(Arguments[5]);
  }
  np = log((-tfv * tir + tpmt) / (tpmt + tir * tpv)) / log(1 + tir);
  if (scale NEQ 0)
    np = int(np * scale + 0.5) / scale;
  return(np);
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
3 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson