From 4158e886342ee7a980210c668f73389893305e95 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Wed, 20 Apr 2022 10:17:58 +0200 Subject: [PATCH 01/14] #120 - wip --- app/Domain/Enums/VacationType.php | 1 + app/Domain/VacationTypeConfigRetriever.php | 6 +++++ .../Http/Controllers/TimesheetController.php | 3 ++- .../Controllers/VacationLimitController.php | 4 ++-- config/vacation_types.php | 22 +++++++++++++++++++ resources/js/Shared/VacationPopup.vue | 2 +- resources/lang/pl.json | 1 + 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/Domain/Enums/VacationType.php b/app/Domain/Enums/VacationType.php index 71bdd41..a93ca3d 100644 --- a/app/Domain/Enums/VacationType.php +++ b/app/Domain/Enums/VacationType.php @@ -18,6 +18,7 @@ enum VacationType: string case TimeInLieu = "time_in_lieu"; case Sick = "sick_vacation"; case Absence = "absence"; + case HomeOffice = "home_office"; public function label(): string { diff --git a/app/Domain/VacationTypeConfigRetriever.php b/app/Domain/VacationTypeConfigRetriever.php index 213fcc8..7865d41 100644 --- a/app/Domain/VacationTypeConfigRetriever.php +++ b/app/Domain/VacationTypeConfigRetriever.php @@ -15,6 +15,7 @@ class VacationTypeConfigRetriever public const KEY_BILLABLE = "billable"; public const KEY_HAS_LIMIT = "has_limit"; public const KEY_AVAILABLE_FOR = "available_for"; + public const KEY_IS_VACATION = "is_vacation"; public function __construct( protected Repository $config, @@ -40,6 +41,11 @@ class VacationTypeConfigRetriever return $this->getConfigFor($type)[static::KEY_HAS_LIMIT]; } + public function isVacation(VacationType $type): bool + { + return $this->getConfigFor($type)[static::KEY_IS_VACATION]; + } + public function isAvailableFor(VacationType $type, EmploymentForm $employmentForm): bool { return in_array($employmentForm, $this->getConfigFor($type)[static::KEY_AVAILABLE_FOR], true); diff --git a/app/Infrastructure/Http/Controllers/TimesheetController.php b/app/Infrastructure/Http/Controllers/TimesheetController.php index 3408bf5..16af5f6 100644 --- a/app/Infrastructure/Http/Controllers/TimesheetController.php +++ b/app/Infrastructure/Http/Controllers/TimesheetController.php @@ -35,7 +35,8 @@ class TimesheetController extends Controller $types = VacationType::all() ->filter( - fn(VacationType $type) => $configRetriever->isAvailableFor($type, EmploymentForm::EmploymentContract), + fn(VacationType $type) => $configRetriever->isAvailableFor($type, EmploymentForm::EmploymentContract) + && $configRetriever->isVacation($type), ); $filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx"; diff --git a/app/Infrastructure/Http/Controllers/VacationLimitController.php b/app/Infrastructure/Http/Controllers/VacationLimitController.php index cb3c8ef..29c333e 100644 --- a/app/Infrastructure/Http/Controllers/VacationLimitController.php +++ b/app/Infrastructure/Http/Controllers/VacationLimitController.php @@ -11,7 +11,7 @@ use Toby\Eloquent\Helpers\YearPeriodRetriever; use Toby\Eloquent\Models\VacationLimit; use Toby\Eloquent\Models\YearPeriod; use Toby\Infrastructure\Http\Requests\VacationLimitRequest; -use Toby\Infrastructure\Http\Resources\SimpleUserResource; +use Toby\Infrastructure\Http\Resources\UserResource; class VacationLimitController extends Controller { @@ -32,7 +32,7 @@ class VacationLimitController extends Controller $limitsResource = $limits->map(fn(VacationLimit $limit) => [ "id" => $limit->id, - "user" => new SimpleUserResource($limit->user), + "user" => new UserResource($limit->user), "hasVacation" => $limit->hasVacation(), "days" => $limit->days, "remainingLastYear" => $previousYearPeriod diff --git a/config/vacation_types.php b/config/vacation_types.php index e9b4402..f890546 100644 --- a/config/vacation_types.php +++ b/config/vacation_types.php @@ -15,6 +15,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::OnRequest->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -42,6 +43,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Unpaid->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -51,6 +53,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Special->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -60,6 +63,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Childcare->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -69,6 +73,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Training->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -79,6 +84,7 @@ return [ EmploymentForm::EmploymentContract, ], ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, VacationType::Volunteering->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, @@ -87,6 +93,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Volunteering->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -96,6 +103,7 @@ return [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ EmploymentForm::EmploymentContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, ], VacationType::Absence->value => [ VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, @@ -107,5 +115,19 @@ return [ EmploymentForm::B2bContract, EmploymentForm::BoardMemberContract, ], + VacationTypeConfigRetriever::KEY_IS_VACATION => true, + ], + VacationType::HomeOffice->value => [ + VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false, + VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false, + VacationTypeConfigRetriever::KEY_BILLABLE => true, + VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, + VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ + EmploymentForm::EmploymentContract, + EmploymentForm::CommissionContract, + EmploymentForm::B2bContract, + EmploymentForm::BoardMemberContract, + ], + VacationTypeConfigRetriever::KEY_IS_VACATION => false, ], ]; diff --git a/resources/js/Shared/VacationPopup.vue b/resources/js/Shared/VacationPopup.vue index 79aba5a..2ace025 100644 --- a/resources/js/Shared/VacationPopup.vue +++ b/resources/js/Shared/VacationPopup.vue @@ -16,7 +16,7 @@
- Rodzaj urlopu + Rodzaj wniosku
diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 9cc41ae..5df56a5 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -15,6 +15,7 @@ "time_in_lieu": "Odbiór za święto", "sick_vacation": "Zwolnienie lekarskie", "absence": "Nieobecność", + "home_office": "Biuro w domu", "employee": "Pracownik", "administrator": "Administrator", "technical_approver": "Techniczny akceptujący", -- 2.52.0 From 889af3aaa27574c4d14732d8eea6a7442f868ccb Mon Sep 17 00:00:00 2001 From: EwelinaLasowy Date: Wed, 20 Apr 2022 10:38:17 +0200 Subject: [PATCH 02/14] #120 - add icon to home office --- resources/js/Composables/vacationTypeInfo.js | 8 ++++++++ resources/lang/pl.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/js/Composables/vacationTypeInfo.js b/resources/js/Composables/vacationTypeInfo.js index 4f154cb..ff6ee92 100644 --- a/resources/js/Composables/vacationTypeInfo.js +++ b/resources/js/Composables/vacationTypeInfo.js @@ -8,6 +8,7 @@ import HandHeartOutlineIcon from 'vue-material-design-icons/HandHeartOutline.vue import CalendarCheckIcon from 'vue-material-design-icons/CalendarCheck.vue' import MedicalBagIcon from 'vue-material-design-icons/MedicalBag.vue' import CalendarRemoveIcon from 'vue-material-design-icons/CalendarRemove.vue' +import LaptopIcon from 'vue-material-design-icons/Laptop.vue'; const types = [ { @@ -80,6 +81,13 @@ const types = [ color: 'text-cyan-500', border: 'border-cyan-500', }, + { + text: 'Praca zdalna', + value: 'home_office', + icon: LaptopIcon, + color: 'text-fuchsia-500', + border: 'border-fuchsia-500', + }, ] export default function useVacationTypeInfo() { diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 5df56a5..c288aba 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -15,7 +15,7 @@ "time_in_lieu": "Odbiór za święto", "sick_vacation": "Zwolnienie lekarskie", "absence": "Nieobecność", - "home_office": "Biuro w domu", + "home_office": "Praca zdalna", "employee": "Pracownik", "administrator": "Administrator", "technical_approver": "Techniczny akceptujący", -- 2.52.0 From a149f05b9b6a37ab1ac01674629ba6df909dcbd1 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Wed, 20 Apr 2022 10:48:09 +0200 Subject: [PATCH 03/14] #120 - wip --- app/Domain/UserVacationStatsRetriever.php | 13 ++++++++++++- .../Http/Controllers/DashboardController.php | 2 ++ config/vacation_types.php | 3 +++ resources/js/Shared/Widgets/VacationStats.vue | 13 ++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) 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.
-
+
{{ stats.other }}
@@ -60,6 +60,17 @@ Urlopy bezpłatne, okolicznościowe, zwolnienia lekarskie, itd., które zostały już zatwierdzone.
+
+
+ {{ stats.homeOffice }} +
+
+ Biuro w domu +
+
+ Biuro w domku +
+
-- 2.52.0 From 4c5627c06735188596e706095c0e5abe634e4416 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Wed, 20 Apr 2022 10:51:44 +0200 Subject: [PATCH 04/14] #120 - wip --- resources/js/Pages/VacationRequest/Create.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/js/Pages/VacationRequest/Create.vue b/resources/js/Pages/VacationRequest/Create.vue index 212ab31..7489fcf 100644 --- a/resources/js/Pages/VacationRequest/Create.vue +++ b/resources/js/Pages/VacationRequest/Create.vue @@ -142,7 +142,9 @@ :class="{ 'border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500': form.errors.type, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.type }" >