Skip to content

Commit

Permalink
Merge pull request #4164 from oleibman/amordegrc
Browse files Browse the repository at this point in the history
Tweak for AMORDEGRC
  • Loading branch information
oleibman authored Sep 15, 2024
2 parents 2d493d7 + 90162a1 commit c91c8c9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Calculation/Financial/Amortization.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

class Amortization
{
private const ROUNDING_ADJUSTMENT = (PHP_VERSION_ID < 80400) ? 0 : 1e-14;

/**
* AMORDEGRC.
*
Expand Down Expand Up @@ -82,7 +80,7 @@ public static function AMORDEGRC(
$amortiseCoeff = self::getAmortizationCoefficient($rate);

$rate *= $amortiseCoeff;
$rate += self::ROUNDING_ADJUSTMENT;
$rate = (float) (string) $rate; // ugly way to avoid rounding problem
$fNRate = round($yearFrac * $rate * $cost, 0);
$cost -= $fNRate;
$fRest = $cost - $salvage;
Expand Down

0 comments on commit c91c8c9

Please sign in to comment.