You are here

public static function PHPExcel_Calculation_Financial::PPMT in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::PPMT()

* PPMT * * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate. * *

Parameters

float $rate Interest rate per period: * @param int $per Period for which we want to find the interest * @param int $nper Number of periods * @param float $pv Present Value * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period * @return float

1 call to PHPExcel_Calculation_Financial::PPMT()
PHPExcel_Calculation_Financial::CUMPRINC in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php
* CUMPRINC * * Returns the cumulative principal paid on a loan between the start and end periods. * * Excel Function: * CUMPRINC(rate,nper,pv,start,end[,type]) * * @access public * @category Financial Functions *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php, line 1599

Class

PHPExcel_Calculation_Financial
PHPExcel_Calculation_Financial

Code

public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) {
  $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
  $per = (int) PHPExcel_Calculation_Functions::flattenSingleValue($per);
  $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
  $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
  $fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
  $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);

  // Validate parameters
  if ($type != 0 && $type != 1) {
    return PHPExcel_Calculation_Functions::NaN();
  }
  if ($per <= 0 || $per > $nper) {
    return PHPExcel_Calculation_Functions::VALUE();
  }

  // Calculate
  $interestAndPrincipal = self::_interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
  return $interestAndPrincipal[1];
}