#120 - wip
This commit is contained in:
@@ -34,10 +34,10 @@ class UserVacationStatsRetriever
|
||||
public function getUsedVacationDaysByMonth(User $user, YearPeriod $yearPeriod): Collection
|
||||
{
|
||||
return $user->vacations()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query): Builder => $query
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereIn("type", $this->getLimitableVacationTypes())
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
@@ -69,11 +69,21 @@ class UserVacationStatsRetriever
|
||||
"vacationRequest",
|
||||
fn(Builder $query): Builder => $query
|
||||
->whereIn("type", $this->getNotLimitableVacationTypes())
|
||||
->whereNot("type", VacationType::HomeOffice)
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getHomeOfficeDays(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user
|
||||
->vacations()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation("vacationRequest", "type", VacationType::HomeOffice)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getRemainingVacationDays(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
$limit = $this->getVacationDaysLimit($user, $yearPeriod);
|
||||
@@ -106,4 +116,5 @@ class UserVacationStatsRetriever
|
||||
|
||||
return $types->filter(fn(VacationType $type) => !$this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -57,6 +57,7 @@ class DashboardController extends Controller
|
||||
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
|
||||
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
|
||||
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
|
||||
$homeOffice = $vacationStatsRetriever->getHomeOfficeDays($user, $yearPeriod);
|
||||
$other = $vacationStatsRetriever->getOtherApprovedVacationDays($user, $yearPeriod);
|
||||
$remaining = $limit - $used - $pending;
|
||||
|
||||
@@ -69,6 +70,7 @@ class DashboardController extends Controller
|
||||
"remaining" => $remaining,
|
||||
"used" => $used,
|
||||
"pending" => $pending,
|
||||
"homeOffice" => $homeOffice,
|
||||
"other" => $other,
|
||||
],
|
||||
"can" => [
|
||||
|
Reference in New Issue
Block a user