You are here

public static function PHPExcel_Calculation_Financial::SYD in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::SYD()

* SYD * * Returns the sum-of-years' digits depreciation of an asset for a specified period. * *

Parameters

cost Initial cost of the asset: * @param salvage Value at the end of the depreciation * @param life Number of periods over which the asset is depreciated * @param period Period * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php, line 1955

Class

PHPExcel_Calculation_Financial
PHPExcel_Calculation_Financial

Code

public static function SYD($cost, $salvage, $life, $period) {
  $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
  $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
  $life = PHPExcel_Calculation_Functions::flattenSingleValue($life);
  $period = PHPExcel_Calculation_Functions::flattenSingleValue($period);

  // Calculate
  if (is_numeric($cost) && is_numeric($salvage) && is_numeric($life) && is_numeric($period)) {
    if ($life < 1 || $period > $life) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    return ($cost - $salvage) * ($life - $period + 1) * 2 / ($life * ($life + 1));
  }
  return PHPExcel_Calculation_Functions::VALUE();
}