# CFLib.org – Common Function Library Project

## Payment(IR, PV, FV, NP)

##### Last updated August 02, 2001

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);
}
pmt = (tir * (tfv + q * tpv)) / (-1 + q);
if (scale NEQ 0)
pmt = int(pmt * scale + 0.5) / scale;
return(-pmt);
}
``````

### Search CFLib.org Raymond Camden added
QueryDeleteRows
November 04, 2017 Leigh added
May 11, 2016 Raymond Camden added
stripHTML
May 10, 2016 Kevin Cotton added
date2ExcelDate
May 05, 2016 Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson