From 8e318a041b54bb0da7abb69d5438e4ec63a7b876 Mon Sep 17 00:00:00 2001 From: Rustem Date: Sat, 24 May 2025 09:48:06 +0500 Subject: [PATCH] master --- app/Service/DepositService.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Service/DepositService.php b/app/Service/DepositService.php index 75e0c5b..445edbc 100644 --- a/app/Service/DepositService.php +++ b/app/Service/DepositService.php @@ -4,7 +4,7 @@ namespace App\Service; class DepositService { - public function calcWithoutDeposit($deposit, $days): float { + 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, @@ -12,15 +12,18 @@ class DepositService 13.44, 13.88, 14.32, 14.76, 15.20 ]; - $lastKnownRate = 15.20; $ndsRate = 0.12; - $total = 0; - $percent = $percentRates[$days] ?? $lastKnownRate; - if ($percent !== null) { - $sumForDay = $deposit * ($percent / 100) * (1 + $ndsRate); - $total += $sumForDay; + $lastKnownRate = 15.20; + + $index = $day - 1; + + $percent = $percentRates[$index] ?? $lastKnownRate; + + if ($percent === null) { + return 0.0; } - return round($total, 2); + $sum = $deposit * ($percent / 100) * (1 + $ndsRate); + return round($sum, 2); } }