fix depreciation spelling

This commit is contained in:
Dennis Eichhorn 2020-10-29 22:29:05 +01:00
parent 8e225141ad
commit c0a46b778a
2 changed files with 37 additions and 37 deletions

View File

@ -78,7 +78,7 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticDegressivDepreciationFactor(float $start, float $residual, int $duration) : float public static function getArithmeticDegressiveDepreciationFactor(float $start, float $residual, int $duration) : float
{ {
return ($start - $residual) / ($duration * ($duration + 1) / 2); return ($start - $residual) / ($duration * ($duration + 1) / 2);
} }
@ -95,9 +95,9 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float public static function getArithmeticDegressiveDepreciationInT(float $start, float $residual, int $duration, int $t) : float
{ {
return self::getArithmeticDegressivDepreciationFactor($start, $residual, $duration) * ($duration - $t + 1); return self::getArithmeticDegressiveDepreciationFactor($start, $residual, $duration) * ($duration - $t + 1);
} }
/** /**
@ -112,19 +112,19 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticDegressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float public static function getArithmeticDegressiveDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float
{ {
$end = $start; $end = $start;
for ($i = 1; $i <= $t; ++$i) { for ($i = 1; $i <= $t; ++$i) {
$end -= self::getArithmeticDegressivDepreciationInT($start, $residual, $duration, $i); $end -= self::getArithmeticDegressiveDepreciationInT($start, $residual, $duration, $i);
} }
return $end; return $end;
} }
/** /**
* Calculate the progressive factor * Calculate the progressivee factor
* *
* @param float $start Value to depreciate (reduced by residual value if required) * @param float $start Value to depreciate (reduced by residual value if required)
* @param float $residual Residual value * @param float $residual Residual value
@ -134,7 +134,7 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticProgressivDepreciationFactor(float $start, float $residual, int $duration) : float public static function getArithmeticProgressiveDepreciationFactor(float $start, float $residual, int $duration) : float
{ {
return ($start - $residual) / ($duration * ($duration + 1) / 2); return ($start - $residual) / ($duration * ($duration + 1) / 2);
} }
@ -151,9 +151,9 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticProgressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float public static function getArithmeticProgressiveDepreciationInT(float $start, float $residual, int $duration, int $t) : float
{ {
return self::getArithmeticProgressivDepreciationFactor($start, $residual, $duration) * $t; return self::getArithmeticProgressiveDepreciationFactor($start, $residual, $duration) * $t;
} }
/** /**
@ -168,9 +168,9 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getArithmeticProgressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float public static function getArithmeticProgressiveDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float
{ {
return $start - self::getArithmeticProgressivDepreciationFactor($start, $residual, $duration) * $t * ($t + 1) / 2; return $start - self::getArithmeticProgressiveDepreciationFactor($start, $residual, $duration) * $t * ($t + 1) / 2;
} }
/** /**
@ -184,7 +184,7 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float public static function getGeometicProgressiveDepreciationRate(float $start, float $residual, int $duration) : float
{ {
return (1 - \pow($residual / $start, 1 / $duration)); return (1 - \pow($residual / $start, 1 / $duration));
} }
@ -201,9 +201,9 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicProgressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float public static function getGeometicProgressiveDepreciationInT(float $start, float $residual, int $duration, int $t) : float
{ {
$rate = self::getGeometicProgressivDepreciationRate($start, $residual, $duration); $rate = self::getGeometicProgressiveDepreciationRate($start, $residual, $duration);
return $start * (1 - $rate) ** ($duration - $t) * $rate; return $start * (1 - $rate) ** ($duration - $t) * $rate;
} }
@ -220,12 +220,12 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicProgressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float public static function getGeometicProgressiveDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float
{ {
$end = $start; $end = $start;
for ($i = 1; $i <= $t; ++$i) { for ($i = 1; $i <= $t; ++$i) {
$end -= self::getGeometicProgressivDepreciationInT($start, $residual, $duration, $i); $end -= self::getGeometicProgressiveDepreciationInT($start, $residual, $duration, $i);
} }
return $end; return $end;
@ -242,7 +242,7 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicDegressivDepreciationRate(float $start, float $residual, int $duration) : float public static function getGeometicDegressiveDepreciationRate(float $start, float $residual, int $duration) : float
{ {
return (1 - \pow($residual / $start, 1 / $duration)); return (1 - \pow($residual / $start, 1 / $duration));
} }
@ -259,9 +259,9 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float public static function getGeometicDegressiveDepreciationInT(float $start, float $residual, int $duration, int $t) : float
{ {
$rate = self::getGeometicDegressivDepreciationRate($start, $residual, $duration); $rate = self::getGeometicDegressiveDepreciationRate($start, $residual, $duration);
return $start * (1 - $rate) ** ($t - 1) * $rate; return $start * (1 - $rate) ** ($t - 1) * $rate;
} }
@ -277,8 +277,8 @@ final class Depreciation
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getGeometicDegressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float public static function getGeometicDegressiveDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float
{ {
return $start * (1 - self::getGeometicDegressivDepreciationRate($start, $residual, $duration)) ** $t; return $start * (1 - self::getGeometicDegressiveDepreciationRate($start, $residual, $duration)) ** $t;
} }
} }

View File

@ -41,63 +41,63 @@ class DepreciationTest extends \PHPUnit\Framework\TestCase
* @testdox The arithmetic degressive depreciation and reverse value calculations are correct * @testdox The arithmetic degressive depreciation and reverse value calculations are correct
* @group framework * @group framework
*/ */
public function testArithmeticDegressivDepreciation() : void public function testArithmeticDegressiveDepreciation() : void
{ {
$start = 150000; $start = 150000;
$residual = 18000; $residual = 18000;
$duration = 5; $duration = 5;
$t = 2; $t = 2;
self::assertEqualsWithDelta(8800, Depreciation::getArithmeticDegressivDepreciationFactor($start, $residual, $duration), 5); self::assertEqualsWithDelta(8800, Depreciation::getArithmeticDegressiveDepreciationFactor($start, $residual, $duration), 5);
self::assertEqualsWithDelta(35200, Depreciation::getArithmeticDegressivDepreciationInT($start, $residual,$duration, $t), 5); self::assertEqualsWithDelta(35200, Depreciation::getArithmeticDegressiveDepreciationInT($start, $residual,$duration, $t), 5);
self::assertEqualsWithDelta(70800, Depreciation::getArithmeticDegressivDepreciationResidualInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(70800, Depreciation::getArithmeticDegressiveDepreciationResidualInT($start, $residual, $duration, $t), 5);
} }
/** /**
* @testdox The arithmetic progressive depreciation and reverse value calculations are correct * @testdox The arithmetic progressive depreciation and reverse value calculations are correct
* @group framework * @group framework
*/ */
public function testArithmeticProgressivDepreciation() : void public function testArithmeticProgressiveDepreciation() : void
{ {
$start = 40000; $start = 40000;
$residual = 4700; $residual = 4700;
$duration = 4; $duration = 4;
$t = 2; $t = 2;
self::assertEqualsWithDelta(3530, Depreciation::getArithmeticProgressivDepreciationFactor($start, $residual, $duration), 5); self::assertEqualsWithDelta(3530, Depreciation::getArithmeticProgressiveDepreciationFactor($start, $residual, $duration), 5);
self::assertEqualsWithDelta(7060, Depreciation::getArithmeticProgressivDepreciationInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(7060, Depreciation::getArithmeticProgressiveDepreciationInT($start, $residual, $duration, $t), 5);
self::assertEqualsWithDelta(29410, Depreciation::getArithmeticProgressivDepreciationResidualInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(29410, Depreciation::getArithmeticProgressiveDepreciationResidualInT($start, $residual, $duration, $t), 5);
} }
/** /**
* @testdox The geometric progressive depreciation and reverse value calculations are correct * @testdox The geometric progressive depreciation and reverse value calculations are correct
* @group framework * @group framework
*/ */
public function testGeometricProgressivDepreciation() : void public function testGeometricProgressiveDepreciation() : void
{ {
$start = 150000; $start = 150000;
$residual = 18000; $residual = 18000;
$duration = 5; $duration = 5;
$t = 2; $t = 2;
self::assertEqualsWithDelta(0.3456, Depreciation::getGeometicProgressivDepreciationRate($start, $residual, $duration), 0.01); self::assertEqualsWithDelta(0.3456, Depreciation::getGeometicProgressiveDepreciationRate($start, $residual, $duration), 0.01);
self::assertEqualsWithDelta(14527, Depreciation::getGeometicProgressivDepreciationInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(14527, Depreciation::getGeometicProgressiveDepreciationInT($start, $residual, $duration, $t), 5);
self::assertEqualsWithDelta(125965, Depreciation::getGeometicProgressivDepreciationResidualInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(125965, Depreciation::getGeometicProgressiveDepreciationResidualInT($start, $residual, $duration, $t), 5);
} }
/** /**
* @testdox The geometric degressive depreciation and reverse value calculations are correct * @testdox The geometric degressive depreciation and reverse value calculations are correct
* @group framework * @group framework
*/ */
public function testGeometricDegressivDepreciation() : void public function testGeometricDegressiveDepreciation() : void
{ {
$start = 150000; $start = 150000;
$residual = 18000; $residual = 18000;
$duration = 5; $duration = 5;
$t = 2; $t = 2;
self::assertEqualsWithDelta(0.3456, Depreciation::getGeometicDegressivDepreciationRate($start, $residual, $duration), 0.01); self::assertEqualsWithDelta(0.3456, Depreciation::getGeometicDegressiveDepreciationRate($start, $residual, $duration), 0.01);
self::assertEqualsWithDelta(33924, Depreciation::getGeometicDegressivDepreciationInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(33924, Depreciation::getGeometicDegressiveDepreciationInT($start, $residual, $duration, $t), 5);
self::assertEqualsWithDelta(64236, Depreciation::getGeometicDegressivDepreciationResidualInT($start, $residual, $duration, $t), 5); self::assertEqualsWithDelta(64236, Depreciation::getGeometicDegressiveDepreciationResidualInT($start, $residual, $duration, $t), 5);
} }
} }