@@ 1239-1258 (lines=20) @@ | ||
1236 | * |
|
1237 | * @return float |
|
1238 | */ |
|
1239 | public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) |
|
1240 | { |
|
1241 | $rate = Functions::flattenSingleValue($rate); |
|
1242 | $nper = Functions::flattenSingleValue($nper); |
|
1243 | $pmt = Functions::flattenSingleValue($pmt); |
|
1244 | $pv = Functions::flattenSingleValue($pv); |
|
1245 | $type = Functions::flattenSingleValue($type); |
|
1246 | ||
1247 | // Validate parameters |
|
1248 | if ($type != 0 && $type != 1) { |
|
1249 | return Functions::NAN(); |
|
1250 | } |
|
1251 | ||
1252 | // Calculate |
|
1253 | if ($rate !== null && $rate != 0) { |
|
1254 | return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; |
|
1255 | } |
|
1256 | ||
1257 | return -$pv - $pmt * $nper; |
|
1258 | } |
|
1259 | ||
1260 | /** |
|
1261 | * FVSCHEDULE. |
|
@@ 1879-1898 (lines=20) @@ | ||
1876 | * |
|
1877 | * @return float |
|
1878 | */ |
|
1879 | public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) |
|
1880 | { |
|
1881 | $rate = Functions::flattenSingleValue($rate); |
|
1882 | $nper = Functions::flattenSingleValue($nper); |
|
1883 | $pmt = Functions::flattenSingleValue($pmt); |
|
1884 | $fv = Functions::flattenSingleValue($fv); |
|
1885 | $type = Functions::flattenSingleValue($type); |
|
1886 | ||
1887 | // Validate parameters |
|
1888 | if ($type != 0 && $type != 1) { |
|
1889 | return Functions::NAN(); |
|
1890 | } |
|
1891 | ||
1892 | // Calculate |
|
1893 | if ($rate !== null && $rate != 0) { |
|
1894 | return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); |
|
1895 | } |
|
1896 | ||
1897 | return -$fv - $pmt * $nper; |
|
1898 | } |
|
1899 | ||
1900 | /** |
|
1901 | * RATE. |