public static function PHPExcel_Calculation_Financial::ACCRINT in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::ACCRINT()
* ACCRINT * * Returns the accrued interest for a security that pays periodic interest. * * Excel Function: * ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis]) * * @access public * @category Financial Functions *
Parameters
mixed $issue The security's issue date.: * @param mixed $firstinterest The security's first interest date. * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue date * when the security is traded to the buyer. * @param float $rate The security's annual coupon rate. * @param float $par The security's par value. * If you omit par, ACCRINT uses $1,000. * @param integer $frequency the number of coupon payments per year. * Valid frequency values are: * 1 Annual * 2 Semi-Annual * 4 Quarterly * If working in Gnumeric Mode, the following frequency options are * also available * 6 Bimonthly * 12 Monthly * @param integer $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php, line 201
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par = 1000, $frequency = 1, $basis = 0) {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$par = is_null($par) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par);
$frequency = is_null($frequency) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = is_null($basis) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if (is_numeric($rate) && is_numeric($par)) {
$rate = (double) $rate;
$par = (double) $par;
if ($rate <= 0 || $par <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
return $par * $rate * $daysBetweenIssueAndSettlement;
}
return PHPExcel_Calculation_Functions::VALUE();
}