public static function PHPExcel_Calculation_Financial::FV in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::FV()
* FV * * Returns the Future Value of a cash flow with constant payments and interest rate (annuities). * * Excel Function: * FV(rate,nper,pmt[,pv[,type]]) * * @access public * @category Financial Functions *
Parameters
float $rate The interest rate per period: * @param int $nper Total number of payment periods in an annuity * @param float $pmt The payment made each period: it cannot change over the * life of the annuity. Typically, pmt contains principal * and interest but no other fees or taxes. * @param float $pv Present Value, or the lump-sum amount that a series of * future payments is worth right now. * @param integer $type A number 0 or 1 and indicates when payments are due: * 0 or omitted At the end of the period. * 1 At the beginning of the period. * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php, line 1185
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$type = PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
}
else {
return -$pv - $pmt * $nper;
}
}