public static function PHPExcel_Calculation_Financial::CUMIPMT 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::CUMIPMT()
* CUMIPMT * * Returns the cumulative interest paid on a loan between the start and end periods. * * Excel Function: * CUMIPMT(rate,nper,pv,start,end[,type]) * * @access public * @category Financial Functions *
Parameters
float $rate The Interest rate: * @param integer $nper The total number of payment periods * @param float $pv Present Value * @param integer $start The first period in the calculation. * Payment periods are numbered beginning with 1. * @param integer $end The last period in the calculation. * @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 809
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start);
$end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end);
$type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($start < 1 || $start > $end) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Calculate
$interest = 0;
for ($per = $start; $per <= $end; ++$per) {
$interest += self::IPMT($rate, $per, $nper, $pv, 0, $type);
}
return $interest;
}