diff --git a/app/Domain/UserVacationStatsRetriever.php b/app/Domain/UserVacationStatsRetriever.php index 21967cb..e0d7c93 100644 --- a/app/Domain/UserVacationStatsRetriever.php +++ b/app/Domain/UserVacationStatsRetriever.php @@ -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)); } + } diff --git a/app/Infrastructure/Http/Controllers/DashboardController.php b/app/Infrastructure/Http/Controllers/DashboardController.php index a0fb994..8be109b 100644 --- a/app/Infrastructure/Http/Controllers/DashboardController.php +++ b/app/Infrastructure/Http/Controllers/DashboardController.php @@ -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" => [ diff --git a/config/vacation_types.php b/config/vacation_types.php index f890546..806cbbc 100644 --- a/config/vacation_types.php +++ b/config/vacation_types.php @@ -25,6 +25,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::TimeInLieu->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false, @@ -34,6 +35,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Sick->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false, @@ -83,6 +85,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationTypeConfigRetriever::KEY_IS_VACATION => true, VacationType::Volunteering->value => [ diff --git a/resources/js/Shared/Widgets/VacationStats.vue b/resources/js/Shared/Widgets/VacationStats.vue index a2af181..9365173 100644 --- a/resources/js/Shared/Widgets/VacationStats.vue +++ b/resources/js/Shared/Widgets/VacationStats.vue @@ -49,7 +49,7 @@ Twój roczny limit urlopu wypoczynkowego. -