master
parent
2d5e5a609f
commit
8e318a041b
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue