#152 - updated vacation stats

This commit is contained in:
2022-07-07 11:49:18 +02:00
parent 62c3c11ebf
commit cbe70315eb
3 changed files with 84 additions and 69 deletions

View File

@@ -103,6 +103,15 @@ class UserVacationStatsRetriever
return $limit ?? 0;
}
public function hasVacationDaysLimit(User $user, YearPeriod $yearPeriod): bool
{
$limit = $user->vacationLimits()
->whereBelongsTo($yearPeriod)
->first()?->days;
return $limit !== null;
}
protected function getLimitableVacationTypes(): Collection
{
$types = VacationType::all();

View File

@@ -74,6 +74,7 @@ class DashboardController extends Controller
->get();
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
$hasLimit = $vacationStatsRetriever->hasVacationDaysLimit($user, $yearPeriod);
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
$homeOffice = $vacationStatsRetriever->getHomeOfficeDays($user, $yearPeriod);
@@ -99,6 +100,7 @@ class DashboardController extends Controller
],
),
"stats" => [
"hasLimit" => $hasLimit,
"limit" => $limit,
"remaining" => $remaining,
"used" => $used,