30 lines
754 B
PHP
30 lines
754 B
PHP
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
class DepositService
|
|
{
|
|
public function calcWithoutDeposit($deposit, $day): float {
|
|
$percentRates = [
|
|
3.00, 3.00, 3.00, 4.05, 5.10, 6.15, 7.20, 8.25, 9.30,
|
|
10.35, 11.40, 12.45, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00,
|
|
13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00,
|
|
13.44, 13.88, 14.32, 14.76, 15.20
|
|
];
|
|
|
|
$ndsRate = 0.12;
|
|
$lastKnownRate = 15.20;
|
|
|
|
$index = $day - 1;
|
|
|
|
$percent = $percentRates[$index] ?? $lastKnownRate;
|
|
|
|
if ($percent === null) {
|
|
return 0.0;
|
|
}
|
|
|
|
$sum = $deposit * ($percent / 100) * (1 + $ndsRate);
|
|
return round($sum, 2);
|
|
}
|
|
}
|