@@ 1338-1359 (lines=22) @@ | ||
1335 | * |
|
1336 | * @return float |
|
1337 | */ |
|
1338 | public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) |
|
1339 | { |
|
1340 | $rate = Functions::flattenSingleValue($rate); |
|
1341 | $per = (int) Functions::flattenSingleValue($per); |
|
1342 | $nper = (int) Functions::flattenSingleValue($nper); |
|
1343 | $pv = Functions::flattenSingleValue($pv); |
|
1344 | $fv = Functions::flattenSingleValue($fv); |
|
1345 | $type = (int) Functions::flattenSingleValue($type); |
|
1346 | ||
1347 | // Validate parameters |
|
1348 | if ($type != 0 && $type != 1) { |
|
1349 | return Functions::NAN(); |
|
1350 | } |
|
1351 | if ($per <= 0 || $per > $nper) { |
|
1352 | return Functions::VALUE(); |
|
1353 | } |
|
1354 | ||
1355 | // Calculate |
|
1356 | $interestAndPrincipal = self::interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type); |
|
1357 | ||
1358 | return $interestAndPrincipal[0]; |
|
1359 | } |
|
1360 | ||
1361 | /** |
|
1362 | * IRR. |
|
@@ 1664-1685 (lines=22) @@ | ||
1661 | * |
|
1662 | * @return float |
|
1663 | */ |
|
1664 | public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) |
|
1665 | { |
|
1666 | $rate = Functions::flattenSingleValue($rate); |
|
1667 | $per = (int) Functions::flattenSingleValue($per); |
|
1668 | $nper = (int) Functions::flattenSingleValue($nper); |
|
1669 | $pv = Functions::flattenSingleValue($pv); |
|
1670 | $fv = Functions::flattenSingleValue($fv); |
|
1671 | $type = (int) Functions::flattenSingleValue($type); |
|
1672 | ||
1673 | // Validate parameters |
|
1674 | if ($type != 0 && $type != 1) { |
|
1675 | return Functions::NAN(); |
|
1676 | } |
|
1677 | if ($per <= 0 || $per > $nper) { |
|
1678 | return Functions::VALUE(); |
|
1679 | } |
|
1680 | ||
1681 | // Calculate |
|
1682 | $interestAndPrincipal = self::interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type); |
|
1683 | ||
1684 | return $interestAndPrincipal[1]; |
|
1685 | } |
|
1686 | ||
1687 | public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0) |
|
1688 | { |