pipicar/app/Service/DepositService.php

30 lines
835 B
PHP

<?php
namespace App\Service;
class DepositService
{
public function calcWithoutDeposit($deposit, $days): 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
];
$lastKnownRate = 15.20;
$ndsRate = 0.12;
$total = 0;
for ($i = 0; $i < $days; $i++) {
$percent = $percentRates[$i] ?? $lastKnownRate;
if ($percent !== null) {
$sumForDay = $deposit * ($percent / 100) * (1 + $ndsRate);
$total += $sumForDay;
}
}
return round($total, 2);
}
}