CFLib.org – Common Function Library Project

Payment(IR, PV, FV, NP)

Last updated August 2, 2001

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

 
Rated 4 time(s). Average Rating: 2.5

Description:
Calculate the payment on a loan given the interest rate, periods, and present value. The value returned is negative since the payment represents a reduction in the account. To get the simple value, call Abs on the result.

Return Values:
Returns a numeric value.

Example:

view plain print about
Payment = <cfoutput>#Payment(0.08,20000,0,24)#</cfoutput>

Parameters:

Name Description Required
IR Interest rate per year (8.5% = 0.085) Yes
PV Present Value Yes
FV Future Value (Generally zero for calculating payments. Non zero for pay down to ammount.) Yes
NP Number of periods. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Calculate payment on loan.
 * 
 * @param IR      Interest rate per year (8.5% = 0.085) 
 * @param PV      Present Value 
 * @param FV      Future Value (Generally zero for calculating payments. Non zero for pay down to ammount.) 
 * @param NP      Number of periods. 
 * @return Returns a numeric value. 
 * @author Raymond Thompson (rayt@qsystems.net) 
 * @version 1, August 2, 2001 
 */

function Payment(IR,PV,FV,NP) {
  var tir = abs(ir) / 12;
  var tfv = abs(fv);
  var tpv = abs(pv);
  var scale = 0;
  var pmt=0;
  var q = (1 + tir)^ abs(np);

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

Search CFLib.org


Latest Additions

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

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

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

Ben Forta Ben Forta added
GetHostAddress
28 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