Merge pull request #4164 from oleibman/amordegrc

Tweak for AMORDEGRC
This commit is contained in:
oleibman
2024-09-15 12:30:27 +00:00
committed by GitHub
@@ -9,8 +9,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Amortization
{
private const ROUNDING_ADJUSTMENT = (PHP_VERSION_ID < 80400) ? 0 : 1e-14;
/**
* AMORDEGRC.
*
@@ -82,7 +80,7 @@ class Amortization
$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;