* #73 - cancel vacation request * #73 - fix * #73 - changed text for cancelling vacation request Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
parent
43870fa060
commit
afb1a5e9ff
@ -5,6 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Toby\Domain\Policies;
|
namespace Toby\Domain\Policies;
|
||||||
|
|
||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
|
use Toby\Domain\States\VacationRequest\Created;
|
||||||
|
use Toby\Domain\States\VacationRequest\WaitingForAdministrative;
|
||||||
|
use Toby\Domain\States\VacationRequest\WaitingForTechnical;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
|
||||||
@ -40,8 +43,16 @@ class VacationRequestPolicy
|
|||||||
return in_array($user->role, [Role::AdministrativeApprover, Role::TechnicalApprover], true);
|
return in_array($user->role, [Role::AdministrativeApprover, Role::TechnicalApprover], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancel(User $user): bool
|
public function cancel(User $user, VacationRequest $vacationRequest): bool
|
||||||
{
|
{
|
||||||
|
if ($vacationRequest->user->is($user) && $vacationRequest->state->equals(
|
||||||
|
Created::class,
|
||||||
|
WaitingForAdministrative::class,
|
||||||
|
WaitingForTechnical::class,
|
||||||
|
)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return $user->role === Role::AdministrativeApprover;
|
return $user->role === Role::AdministrativeApprover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,19 +33,19 @@ class DemoSeeder extends Seeder
|
|||||||
YearPeriod::unsetEventDispatcher();
|
YearPeriod::unsetEventDispatcher();
|
||||||
VacationRequest::unsetEventDispatcher();
|
VacationRequest::unsetEventDispatcher();
|
||||||
|
|
||||||
$employee1 = User::factory([
|
$user = User::factory([
|
||||||
"first_name" => "Jan",
|
"first_name" => "Jan",
|
||||||
"last_name" => "Kowalski",
|
"last_name" => "Kowalski",
|
||||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||||
"employment_form" => EmploymentForm::EmploymentContract,
|
"employment_form" => EmploymentForm::EmploymentContract,
|
||||||
"position" => "programista",
|
"position" => "programista",
|
||||||
"role" => Role::Employee,
|
"role" => Role::Administrator,
|
||||||
"employment_date" => Carbon::createFromDate(2021, 12, 31),
|
"employment_date" => Carbon::createFromDate(2021, 12, 31),
|
||||||
"remember_token" => Str::random(10),
|
"remember_token" => Str::random(10),
|
||||||
])
|
])
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$employee2 = User::factory([
|
User::factory([
|
||||||
"first_name" => "Anna",
|
"first_name" => "Anna",
|
||||||
"last_name" => "Nowak",
|
"last_name" => "Nowak",
|
||||||
"email" => "anna.nowak@example.com",
|
"email" => "anna.nowak@example.com",
|
||||||
@ -57,7 +57,7 @@ class DemoSeeder extends Seeder
|
|||||||
])
|
])
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$employee3 = User::factory([
|
User::factory([
|
||||||
"first_name" => "Tola",
|
"first_name" => "Tola",
|
||||||
"last_name" => "Sawicka",
|
"last_name" => "Sawicka",
|
||||||
"email" => "tola.sawicka@example.com",
|
"email" => "tola.sawicka@example.com",
|
||||||
@ -93,7 +93,7 @@ class DemoSeeder extends Seeder
|
|||||||
])
|
])
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$admin = User::factory([
|
User::factory([
|
||||||
"first_name" => "Miłosz",
|
"first_name" => "Miłosz",
|
||||||
"last_name" => "Borowski",
|
"last_name" => "Borowski",
|
||||||
"email" => "milosz.borowski@example.com",
|
"email" => "milosz.borowski@example.com",
|
||||||
@ -151,8 +151,8 @@ class DemoSeeder extends Seeder
|
|||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Komentarz do wniosku urlopowego.",
|
"comment" => "Komentarz do wniosku urlopowego.",
|
||||||
])
|
])
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->for($employee1, "creator")
|
->for($user, "creator")
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||||
@ -175,7 +175,7 @@ class DemoSeeder extends Seeder
|
|||||||
"from" => null,
|
"from" => null,
|
||||||
"to" => Created::class,
|
"to" => Created::class,
|
||||||
])->for($vacationRequestApproved)
|
])->for($vacationRequestApproved)
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
VacationRequestActivity::factory([
|
VacationRequestActivity::factory([
|
||||||
@ -221,8 +221,8 @@ class DemoSeeder extends Seeder
|
|||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
|
||||||
"comment" => "Komentarz do wniosku urlopowego.",
|
"comment" => "Komentarz do wniosku urlopowego.",
|
||||||
])
|
])
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->for($employee1, "creator")
|
->for($user, "creator")
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||||
@ -245,7 +245,7 @@ class DemoSeeder extends Seeder
|
|||||||
"from" => null,
|
"from" => null,
|
||||||
"to" => Created::class,
|
"to" => Created::class,
|
||||||
])->for($vacationRequestWaitsForAdminApproval)
|
])->for($vacationRequestWaitsForAdminApproval)
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
VacationRequestActivity::factory([
|
VacationRequestActivity::factory([
|
||||||
@ -278,8 +278,8 @@ class DemoSeeder extends Seeder
|
|||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
"comment" => "",
|
"comment" => "",
|
||||||
])
|
])
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->for($employee1, "creator")
|
->for($user, "creator")
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||||
@ -302,7 +302,7 @@ class DemoSeeder extends Seeder
|
|||||||
"from" => null,
|
"from" => null,
|
||||||
"to" => Created::class,
|
"to" => Created::class,
|
||||||
])->for($vacationRequestRejected)
|
])->for($vacationRequestRejected)
|
||||||
->for($employee1)
|
->for($user)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
VacationRequestActivity::factory([
|
VacationRequestActivity::factory([
|
||||||
|
@ -203,7 +203,7 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="mt-2 max-w-xl text-sm text-gray-500">
|
<div class="mt-2 max-w-xl text-sm text-gray-500">
|
||||||
<p>
|
<p>
|
||||||
Wniosek można anulować w każdej chwili - nawet jeśli był już zatwierdzony.
|
Anulowanego wniosku nie można przywrócić - należy utworzyć nowy.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user