* #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;
|
||||
|
||||
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\VacationRequest;
|
||||
|
||||
@ -40,8 +43,16 @@ class VacationRequestPolicy
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -33,19 +33,19 @@ class DemoSeeder extends Seeder
|
||||
YearPeriod::unsetEventDispatcher();
|
||||
VacationRequest::unsetEventDispatcher();
|
||||
|
||||
$employee1 = User::factory([
|
||||
$user = User::factory([
|
||||
"first_name" => "Jan",
|
||||
"last_name" => "Kowalski",
|
||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "programista",
|
||||
"role" => Role::Employee,
|
||||
"role" => Role::Administrator,
|
||||
"employment_date" => Carbon::createFromDate(2021, 12, 31),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->create();
|
||||
|
||||
$employee2 = User::factory([
|
||||
User::factory([
|
||||
"first_name" => "Anna",
|
||||
"last_name" => "Nowak",
|
||||
"email" => "anna.nowak@example.com",
|
||||
@ -57,7 +57,7 @@ class DemoSeeder extends Seeder
|
||||
])
|
||||
->create();
|
||||
|
||||
$employee3 = User::factory([
|
||||
User::factory([
|
||||
"first_name" => "Tola",
|
||||
"last_name" => "Sawicka",
|
||||
"email" => "tola.sawicka@example.com",
|
||||
@ -93,7 +93,7 @@ class DemoSeeder extends Seeder
|
||||
])
|
||||
->create();
|
||||
|
||||
$admin = User::factory([
|
||||
User::factory([
|
||||
"first_name" => "Miłosz",
|
||||
"last_name" => "Borowski",
|
||||
"email" => "milosz.borowski@example.com",
|
||||
@ -151,8 +151,8 @@ class DemoSeeder extends Seeder
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||
"comment" => "Komentarz do wniosku urlopowego.",
|
||||
])
|
||||
->for($employee1)
|
||||
->for($employee1, "creator")
|
||||
->for($user)
|
||||
->for($user, "creator")
|
||||
->for($currentYearPeriod)
|
||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||
@ -175,7 +175,7 @@ class DemoSeeder extends Seeder
|
||||
"from" => null,
|
||||
"to" => Created::class,
|
||||
])->for($vacationRequestApproved)
|
||||
->for($employee1)
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
VacationRequestActivity::factory([
|
||||
@ -221,8 +221,8 @@ class DemoSeeder extends Seeder
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
|
||||
"comment" => "Komentarz do wniosku urlopowego.",
|
||||
])
|
||||
->for($employee1)
|
||||
->for($employee1, "creator")
|
||||
->for($user)
|
||||
->for($user, "creator")
|
||||
->for($currentYearPeriod)
|
||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||
@ -245,7 +245,7 @@ class DemoSeeder extends Seeder
|
||||
"from" => null,
|
||||
"to" => Created::class,
|
||||
])->for($vacationRequestWaitsForAdminApproval)
|
||||
->for($employee1)
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
VacationRequestActivity::factory([
|
||||
@ -278,8 +278,8 @@ class DemoSeeder extends Seeder
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"comment" => "",
|
||||
])
|
||||
->for($employee1)
|
||||
->for($employee1, "creator")
|
||||
->for($user)
|
||||
->for($user, "creator")
|
||||
->for($currentYearPeriod)
|
||||
->afterCreating(function (VacationRequest $vacationRequest): void {
|
||||
$days = app(VacationDaysCalculator::class)->calculateDays(
|
||||
@ -302,7 +302,7 @@ class DemoSeeder extends Seeder
|
||||
"from" => null,
|
||||
"to" => Created::class,
|
||||
])->for($vacationRequestRejected)
|
||||
->for($employee1)
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
VacationRequestActivity::factory([
|
||||
|
@ -203,7 +203,7 @@
|
||||
</h3>
|
||||
<div class="mt-2 max-w-xl text-sm text-gray-500">
|
||||
<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>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
|
Loading…
x
Reference in New Issue
Block a user