master
Rustem 2025-05-24 09:48:06 +05:00
parent 2d5e5a609f
commit 8e318a041b
1 changed files with 11 additions and 8 deletions

View File

@ -4,7 +4,7 @@ namespace App\Service;
class DepositService class DepositService
{ {
public function calcWithoutDeposit($deposit, $days): float { public function calcWithoutDeposit($deposit, $day): float {
$percentRates = [ $percentRates = [
3.00, 3.00, 3.00, 4.05, 5.10, 6.15, 7.20, 8.25, 9.30, 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, 10.35, 11.40, 12.45, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00,
@ -12,15 +12,18 @@ class DepositService
13.44, 13.88, 14.32, 14.76, 15.20 13.44, 13.88, 14.32, 14.76, 15.20
]; ];
$lastKnownRate = 15.20;
$ndsRate = 0.12; $ndsRate = 0.12;
$total = 0; $lastKnownRate = 15.20;
$percent = $percentRates[$days] ?? $lastKnownRate;
if ($percent !== null) { $index = $day - 1;
$sumForDay = $deposit * ($percent / 100) * (1 + $ndsRate);
$total += $sumForDay; $percent = $percentRates[$index] ?? $lastKnownRate;
if ($percent === null) {
return 0.0;
} }
return round($total, 2); $sum = $deposit * ($percent / 100) * (1 + $ndsRate);
return round($sum, 2);
} }
} }