@@ 1223-1242 (lines=20) @@ | ||
1220 | * |
|
1221 | * @return float |
|
1222 | */ |
|
1223 | public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) |
|
1224 | { |
|
1225 | $rate = Functions::flattenSingleValue($rate); |
|
1226 | $nper = Functions::flattenSingleValue($nper); |
|
1227 | $pmt = Functions::flattenSingleValue($pmt); |
|
1228 | $pv = Functions::flattenSingleValue($pv); |
|
1229 | $type = Functions::flattenSingleValue($type); |
|
1230 | ||
1231 | // Validate parameters |
|
1232 | if ($type != 0 && $type != 1) { |
|
1233 | return Functions::NAN(); |
|
1234 | } |
|
1235 | ||
1236 | // Calculate |
|
1237 | if ($rate !== null && $rate != 0) { |
|
1238 | return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; |
|
1239 | } |
|
1240 | ||
1241 | return -$pv - $pmt * $nper; |
|
1242 | } |
|
1243 | ||
1244 | /** |
|
1245 | * FVSCHEDULE. |
|
@@ 1863-1882 (lines=20) @@ | ||
1860 | * |
|
1861 | * @return float |
|
1862 | */ |
|
1863 | public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) |
|
1864 | { |
|
1865 | $rate = Functions::flattenSingleValue($rate); |
|
1866 | $nper = Functions::flattenSingleValue($nper); |
|
1867 | $pmt = Functions::flattenSingleValue($pmt); |
|
1868 | $fv = Functions::flattenSingleValue($fv); |
|
1869 | $type = Functions::flattenSingleValue($type); |
|
1870 | ||
1871 | // Validate parameters |
|
1872 | if ($type != 0 && $type != 1) { |
|
1873 | return Functions::NAN(); |
|
1874 | } |
|
1875 | ||
1876 | // Calculate |
|
1877 | if ($rate !== null && $rate != 0) { |
|
1878 | return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); |
|
1879 | } |
|
1880 | ||
1881 | return -$fv - $pmt * $nper; |
|
1882 | } |
|
1883 | ||
1884 | /** |
|
1885 | * RATE. |