CFLib.org – Common Function Library Project

Payment(IR, PV, FV, NP)

Last updated August 2, 2001

author

Raymond Thompson

Version: 1 | Requires: CF5 | Library: FinancialLib

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:

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:

/**
 * 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);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson