public static function PHPExcel_Calculation_Financial::AMORDEGRC 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::AMORDEGRC()
* AMORDEGRC * * Returns the depreciation for each accounting period. * This function is provided for the French accounting system. If an asset is purchased in * the middle of the accounting period, the prorated depreciation is taken into account. * The function is similar to AMORLINC, except that a depreciation coefficient is applied in * the calculation depending on the life of the assets. * This function will return the depreciation until the last period of the life of the assets * or until the cumulated value of depreciation is greater than the cost of the assets minus * the salvage value. * * Excel Function: * AMORDEGRC(cost,purchased,firstPeriod,salvage,period,rate[,basis]) * * @access public * @category Financial Functions *
Parameters
float cost The cost of the asset.: * @param mixed purchased Date of the purchase of the asset. * @param mixed firstPeriod Date of the end of the first period. * @param mixed salvage The salvage value at the end of the life of the asset. * @param float period The period. * @param float rate Rate of depreciation. * @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 309
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
$firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod);
$salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$period = floor(PHPExcel_Calculation_Functions::flattenSingleValue($period));
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$basis = is_null($basis) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// The depreciation coefficients are:
// Life of assets (1/rate) Depreciation coefficient
// Less than 3 years 1
// Between 3 and 4 years 1.5
// Between 5 and 6 years 2
// More than 6 years 2.5
$fUsePer = 1.0 / $rate;
if ($fUsePer < 3.0) {
$amortiseCoeff = 1.0;
}
elseif ($fUsePer < 5.0) {
$amortiseCoeff = 1.5;
}
elseif ($fUsePer <= 6.0) {
$amortiseCoeff = 2.0;
}
else {
$amortiseCoeff = 2.5;
}
$rate *= $amortiseCoeff;
$fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost, 0);
$cost -= $fNRate;
$fRest = $cost - $salvage;
for ($n = 0; $n < $period; ++$n) {
$fNRate = round($rate * $cost, 0);
$fRest -= $fNRate;
if ($fRest < 0.0) {
switch ($period - $n) {
case 0:
case 1:
return round($cost * 0.5, 0);
break;
default:
return 0.0;
break;
}
}
$cost -= $fNRate;
}
return $fNRate;
}