public static function PHPExcel_Calculation_Financial::ACCRINTM 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::ACCRINTM()
* ACCRINTM * * Returns the accrued interest for a security that pays interest at maturity. * * Excel Function: * ACCRINTM(issue,settlement,rate[,par[,basis]]) * * @access public * @category Financial Functions *
Parameters
mixed issue The security's issue date.: * @param mixed settlement The security's settlement (or maturity) date. * @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 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 253
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis = 0) {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$par = is_null($par) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par);
$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();
}