wip
This commit is contained in:
parent
93f0151b14
commit
3c43f6814d
@ -6,15 +6,12 @@ namespace Toby\Architecture\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
|
||||||
use Toby\Eloquent\Observers\UserObserver;
|
use Toby\Eloquent\Observers\UserObserver;
|
||||||
use Toby\Eloquent\Observers\YearPeriodObserver;
|
|
||||||
|
|
||||||
class ObserverServiceProvider extends ServiceProvider
|
class ObserverServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
User::observe(UserObserver::class);
|
User::observe(UserObserver::class);
|
||||||
YearPeriod::observe(YearPeriodObserver::class);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
app/Domain/Actions/CreateUserAction.php
Normal file
33
app/Domain/Actions/CreateUserAction.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Toby\Domain\Actions;
|
||||||
|
|
||||||
|
use Toby\Eloquent\Models\User;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
|
class CreateUserAction
|
||||||
|
{
|
||||||
|
public function execute(array $data): User
|
||||||
|
{
|
||||||
|
$user = new User($data);
|
||||||
|
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$this->createVacationLimitsFor($user);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createVacationLimitsFor(User $user): void
|
||||||
|
{
|
||||||
|
$yearPeriods = YearPeriod::all();
|
||||||
|
|
||||||
|
foreach ($yearPeriods as $yearPeriod) {
|
||||||
|
$user->vacationLimits()->create([
|
||||||
|
"year_period_id" => $yearPeriod->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,22 +2,30 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Toby\Eloquent\Observers;
|
namespace Toby\Domain\Actions;
|
||||||
|
|
||||||
use Toby\Domain\PolishHolidaysRetriever;
|
use Toby\Domain\PolishHolidaysRetriever;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class YearPeriodObserver
|
class CreateYearPeriodAction
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected PolishHolidaysRetriever $polishHolidaysRetriever,
|
protected PolishHolidaysRetriever $polishHolidaysRetriever,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function created(YearPeriod $yearPeriod): void
|
public function execute(int $year): YearPeriod
|
||||||
{
|
{
|
||||||
|
$yearPeriod = new YearPeriod([
|
||||||
|
"year" => $year,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$yearPeriod->save();
|
||||||
|
|
||||||
$this->createVacationLimitsFor($yearPeriod);
|
$this->createVacationLimitsFor($yearPeriod);
|
||||||
$this->createHolidaysFor($yearPeriod);
|
$this->createHolidaysFor($yearPeriod);
|
||||||
|
|
||||||
|
return $yearPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createVacationLimitsFor(YearPeriod $yearPeriod): void
|
protected function createVacationLimitsFor(YearPeriod $yearPeriod): void
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace Toby\Domain;
|
namespace Toby\Domain;
|
||||||
|
|
||||||
use Carbon\CarbonPeriod;
|
use Carbon\CarbonPeriod;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||||
@ -55,7 +54,7 @@ class CalendarGenerator
|
|||||||
{
|
{
|
||||||
return Vacation::query()
|
return Vacation::query()
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
->whereRelation("vacationRequest", fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()))
|
->approved()
|
||||||
->with("vacationRequest")
|
->with("vacationRequest")
|
||||||
->get()
|
->get()
|
||||||
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||||
|
@ -25,7 +25,6 @@ use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
use Toby\Domain\Enums\VacationType;
|
use Toby\Domain\Enums\VacationType;
|
||||||
use Toby\Domain\States\VacationRequest\Approved;
|
|
||||||
use Toby\Eloquent\Models\Holiday;
|
use Toby\Eloquent\Models\Holiday;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\Vacation;
|
use Toby\Eloquent\Models\Vacation;
|
||||||
@ -189,7 +188,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
|||||||
return $user->vacations()
|
return $user->vacations()
|
||||||
->with("vacationRequest")
|
->with("vacationRequest")
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
->whereRelation("vacationRequest", "state", Approved::$name)
|
->approved()
|
||||||
->get()
|
->get()
|
||||||
->groupBy(
|
->groupBy(
|
||||||
[
|
[
|
||||||
|
@ -88,7 +88,7 @@ class UserVacationStatsRetriever
|
|||||||
$limit = $user->vacationLimits()
|
$limit = $user->vacationLimits()
|
||||||
->where("year_period_id", $yearPeriod->id)
|
->where("year_period_id", $yearPeriod->id)
|
||||||
->first()
|
->first()
|
||||||
->days;
|
?->days;
|
||||||
|
|
||||||
return $limit ?? 0;
|
return $limit ?? 0;
|
||||||
}
|
}
|
||||||
|
@ -71,18 +71,6 @@ class User extends Authenticatable
|
|||||||
return $this->hasMany(Vacation::class);
|
return $this->hasMany(Vacation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeSearch(Builder $query, ?string $text): Builder
|
|
||||||
{
|
|
||||||
if ($text === null) {
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query
|
|
||||||
->where("first_name", "ILIKE", $text)
|
|
||||||
->orWhere("last_name", "ILIKE", $text)
|
|
||||||
->orWhere("email", "ILIKE", $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAvatar(): string
|
public function getAvatar(): string
|
||||||
{
|
{
|
||||||
return $this->getAvatarGenerator()
|
return $this->getAvatarGenerator()
|
||||||
@ -108,6 +96,28 @@ class User extends Authenticatable
|
|||||||
->exists();
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeSearch(Builder $query, ?string $text): Builder
|
||||||
|
{
|
||||||
|
if ($text === null) {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query
|
||||||
|
->where("first_name", "ILIKE", $text)
|
||||||
|
->orWhere("last_name", "ILIKE", $text)
|
||||||
|
->orWhere("email", "ILIKE", $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeWithVacationLimitIn(Builder $query, YearPeriod $yearPeriod): Builder
|
||||||
|
{
|
||||||
|
return $query->whereRelation(
|
||||||
|
"vacationlimits",
|
||||||
|
fn(Builder $query) => $query
|
||||||
|
->where("year_period_id", $yearPeriod->id)
|
||||||
|
->whereNotNull("days"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getAvatarName(): string
|
protected function getAvatarName(): string
|
||||||
{
|
{
|
||||||
return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1);
|
return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1);
|
||||||
|
@ -4,10 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Eloquent\Models;
|
namespace Toby\Eloquent\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Toby\Domain\VacationRequestStatesRetriever;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@ -40,4 +42,12 @@ class Vacation extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(YearPeriod::class);
|
return $this->belongsTo(YearPeriod::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeApproved(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->whereRelation(
|
||||||
|
"vacationRequest",
|
||||||
|
fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace Toby\Eloquent\Observers;
|
|||||||
use Illuminate\Contracts\Hashing\Hasher;
|
use Illuminate\Contracts\Hashing\Hasher;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
|
||||||
|
|
||||||
class UserObserver
|
class UserObserver
|
||||||
{
|
{
|
||||||
@ -23,15 +22,4 @@ class UserObserver
|
|||||||
*/
|
*/
|
||||||
$user->password = $this->hash->make(Str::random(40));
|
$user->password = $this->hash->make(Str::random(40));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function created(User $user): void
|
|
||||||
{
|
|
||||||
$yearPeriods = YearPeriod::all();
|
|
||||||
|
|
||||||
foreach ($yearPeriods as $yearPeriod) {
|
|
||||||
$user->vacationLimits()->create([
|
|
||||||
"year_period_id" => $yearPeriod->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Http\Controllers;
|
namespace Toby\Infrastructure\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
@ -29,10 +28,7 @@ class DashboardController extends Controller
|
|||||||
$absences = Vacation::query()
|
$absences = Vacation::query()
|
||||||
->with(["user", "vacationRequest"])
|
->with(["user", "vacationRequest"])
|
||||||
->whereDate("date", $now)
|
->whereDate("date", $now)
|
||||||
->whereRelation(
|
->approved()
|
||||||
"vacationRequest",
|
|
||||||
fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()),
|
|
||||||
)
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($user->can("listAll", VacationRequest::class)) {
|
if ($user->can("listAll", VacationRequest::class)) {
|
||||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Http\Controllers;
|
namespace Toby\Infrastructure\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Toby\Domain\Enums\Month;
|
use Toby\Domain\Enums\Month;
|
||||||
@ -26,10 +25,7 @@ class MonthlyUsageController extends Controller
|
|||||||
$currentUser = $request->user();
|
$currentUser = $request->user();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($currentYearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $currentYearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->where("id", "!=", $currentUser->id)
|
->where("id", "!=", $currentUser->id)
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Auth\Access\AuthorizationException;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
|
use Toby\Domain\Actions\CreateUserAction;
|
||||||
use Toby\Domain\Enums\EmploymentForm;
|
use Toby\Domain\Enums\EmploymentForm;
|
||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
@ -54,11 +55,11 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function store(UserRequest $request): RedirectResponse
|
public function store(UserRequest $request, CreateUserAction $createUserAction): RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize("manageUsers");
|
$this->authorize("manageUsers");
|
||||||
|
|
||||||
User::query()->create($request->data());
|
$createUserAction->execute($request->data());
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route("users.index")
|
->route("users.index")
|
||||||
|
@ -103,10 +103,7 @@ class VacationRequestController extends Controller
|
|||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($yearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
->get();
|
->get();
|
||||||
@ -164,10 +161,7 @@ class VacationRequestController extends Controller
|
|||||||
$yearPeriod = $yearPeriodRetriever->selected();
|
$yearPeriod = $yearPeriodRetriever->selected();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($yearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
->get();
|
->get();
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Bus\Queueable;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Toby\Domain\Actions\CreateYearPeriodAction;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class CheckYearPeriod implements ShouldQueue
|
class CheckYearPeriod implements ShouldQueue
|
||||||
@ -15,30 +16,17 @@ class CheckYearPeriod implements ShouldQueue
|
|||||||
use Dispatchable;
|
use Dispatchable;
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(CreateYearPeriodAction $createYearPeriodAction): void
|
||||||
{
|
{
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
$now = Carbon::now();
|
||||||
|
|
||||||
if ($currentYearPeriod === null) {
|
if ($currentYearPeriod === null) {
|
||||||
$this->createCurrentYearPeriod();
|
$createYearPeriodAction->execute($now->year);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (YearPeriod::query()->max("year") === Carbon::now()->year) {
|
if (YearPeriod::query()->max("year") === $now->year) {
|
||||||
$this->createNextYearPeriod();
|
$createYearPeriodAction->execute($now->year + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createCurrentYearPeriod(): void
|
|
||||||
{
|
|
||||||
YearPeriod::query()->create([
|
|
||||||
"year" => Carbon::now()->year,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createNextYearPeriod(): void
|
|
||||||
{
|
|
||||||
YearPeriod::query()->create([
|
|
||||||
"year" => Carbon::now()->year + 1,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,6 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::unsetEventDispatcher();
|
|
||||||
YearPeriod::unsetEventDispatcher();
|
|
||||||
VacationRequest::unsetEventDispatcher();
|
|
||||||
|
|
||||||
User::factory(9)->create();
|
User::factory(9)->create();
|
||||||
User::factory([
|
User::factory([
|
||||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||||
|
@ -29,10 +29,6 @@ class DemoSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::unsetEventDispatcher();
|
|
||||||
YearPeriod::unsetEventDispatcher();
|
|
||||||
VacationRequest::unsetEventDispatcher();
|
|
||||||
|
|
||||||
$user = User::factory([
|
$user = User::factory([
|
||||||
"first_name" => "Jan",
|
"first_name" => "Jan",
|
||||||
"last_name" => "Kowalski",
|
"last_name" => "Kowalski",
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="can.generateTimesheet">
|
<div v-if="can.generateTimesheet">
|
||||||
<a
|
<a
|
||||||
:href="`/timesheet/${selectedMonth.value}`"
|
:href="`/vacation/timesheet/${selectedMonth.value}`"
|
||||||
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Pobierz plik Excel
|
Pobierz plik Excel
|
||||||
|
@ -81,6 +81,7 @@ import { useMonthInfo } from '@/Composables/monthInfo'
|
|||||||
import VacationBar from '@/Shared/VacationBar'
|
import VacationBar from '@/Shared/VacationBar'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
years: Object,
|
||||||
monthlyUsage: Object,
|
monthlyUsage: Object,
|
||||||
currentMonth: String,
|
currentMonth: String,
|
||||||
})
|
})
|
||||||
@ -89,6 +90,6 @@ const { getMonths } = useMonthInfo()
|
|||||||
const months = getMonths()
|
const months = getMonths()
|
||||||
|
|
||||||
function isCurrentMonth(month) {
|
function isCurrentMonth(month) {
|
||||||
return props.currentMonth === month.value
|
return (props.years.selected.year === props.years.current.year && props.currentMonth === month.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
||||||
<form @submit.prevent="submitVacationDays">
|
<form @submit.prevent="submitVacationDays">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200 border-b">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
|
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
|
||||||
Strona główna
|
Strona główna
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
<div class="mt-1 pt-1">
|
<div class="mt-1 pt-1 space-y-1">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
v-for="item in navigation"
|
v-for="item in navigation"
|
||||||
:key="item.name"
|
:key="item.name"
|
||||||
@ -202,9 +202,9 @@
|
|||||||
as="button"
|
as="button"
|
||||||
method="post"
|
method="post"
|
||||||
:preserve-state="false"
|
:preserve-state="false"
|
||||||
class="font-medium text-blumilk-600 hover:text-blumilk-500"
|
class="font-semibold text-blumilk-600 hover:text-blumilk-500"
|
||||||
>
|
>
|
||||||
Kliknij, aby wrócić do obecnego roku
|
Wróc do obecnego roku
|
||||||
</inertialink>
|
</inertialink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,7 +28,7 @@ Route::middleware("auth")->group(function (): void {
|
|||||||
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
|
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
|
||||||
->name("year-periods.select");
|
->name("year-periods.select");
|
||||||
|
|
||||||
Route::prefix("/vacation")->group(function () {
|
Route::prefix("/vacation")->group(function (): void {
|
||||||
Route::get("/limits", [VacationLimitController::class, "edit"])
|
Route::get("/limits", [VacationLimitController::class, "edit"])
|
||||||
->name("vacation.limits");
|
->name("vacation.limits");
|
||||||
Route::get("/calendar/{month?}", [VacationCalendarController::class, "index"])
|
Route::get("/calendar/{month?}", [VacationCalendarController::class, "index"])
|
||||||
|
@ -9,6 +9,7 @@ use Inertia\Testing\AssertableInertia as Assert;
|
|||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationLimit;
|
use Toby\Eloquent\Models\VacationLimit;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class VacationLimitTest extends FeatureTestCase
|
class VacationLimitTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
@ -16,12 +17,14 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdminCanSeeVacationLimits(): void
|
public function testAdminCanSeeVacationLimits(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
User::factory(10)->create();
|
VacationLimit::factory(10)
|
||||||
|
->for(YearPeriod::current())
|
||||||
|
->create();
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->get("/vacation-limits")
|
->get("/vacation/limits")
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(
|
->assertInertia(
|
||||||
fn(Assert $page) => $page
|
fn(Assert $page) => $page
|
||||||
@ -32,9 +35,11 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdminCanUpdateVacationLimits(): void
|
public function testAdminCanUpdateVacationLimits(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
User::factory(3)->create();
|
VacationLimit::factory(3)
|
||||||
|
->for(YearPeriod::current())
|
||||||
|
->create();
|
||||||
|
|
||||||
[$limit1, $limit2, $limit3] = VacationLimit::all();
|
[$limit1, $limit2, $limit3] = VacationLimit::all();
|
||||||
|
|
||||||
@ -54,7 +59,7 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->put("/vacation-limits", [
|
->put("/vacation/limits", [
|
||||||
"items" => $data,
|
"items" => $data,
|
||||||
])
|
])
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
@ -39,7 +39,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanSeeVacationRequestsList(): void
|
public function testUserCanSeeVacationRequestsList(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationRequest::factory()
|
VacationRequest::factory()
|
||||||
@ -49,7 +49,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation-requests/me")
|
->get("/vacation/requests/me")
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(
|
->assertInertia(
|
||||||
fn(Assert $page) => $page
|
fn(Assert $page) => $page
|
||||||
@ -60,7 +60,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequest(): void
|
public function testUserCanCreateVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -94,8 +94,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
||||||
{
|
{
|
||||||
$creator = User::factory()->admin()->createQuietly();
|
$creator = User::factory()->admin()->create();
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($creator)
|
$this->actingAs($creator)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -130,8 +130,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
||||||
{
|
{
|
||||||
$creator = User::factory()->admin()->createQuietly();
|
$creator = User::factory()->admin()->create();
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($creator)
|
$this->actingAs($creator)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -167,8 +167,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testTechnicalApproverCanApproveVacationRequest(): void
|
public function testTechnicalApproverCanApproveVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
@ -180,7 +180,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-technical")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -190,8 +190,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministrativeApproverCanApproveVacationRequest(): void
|
public function testAdministrativeApproverCanApproveVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-administrative")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -213,8 +213,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testTechnicalApproverCanRejectVacationRequest(): void
|
public function testTechnicalApproverCanRejectVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -234,7 +234,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/reject")
|
->post("/vacation/requests/{$vacationRequest->id}/reject")
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -244,7 +244,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -255,7 +255,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -269,7 +269,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtWeekend(): void
|
public function testUserCannotCreateVacationRequestAtWeekend(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -280,7 +280,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
||||||
@ -294,7 +294,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtHoliday(): void
|
public function testUserCannotCreateVacationRequestAtHoliday(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -312,7 +312,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||||
@ -326,7 +326,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeHasPendingVacationRequestInThisRange(): void
|
public function testUserCannotCreateVacationRequestIfHeHasPendingVacationRequestInThisRange(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -348,7 +348,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
@ -362,7 +362,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -384,7 +384,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
@ -398,10 +398,10 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestWithEndDatePriorToTheStartDate(): void
|
public function testUserCannotCreateVacationRequestWithEndDatePriorToTheStartDate(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -415,11 +415,11 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtTheTurnOfTheYear(): void
|
public function testUserCannotCreateVacationRequestAtTheTurnOfTheYear(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
||||||
|
@ -16,7 +16,7 @@ trait InteractsWithYearPeriods
|
|||||||
public function createYearPeriod(int $year): YearPeriod
|
public function createYearPeriod(int $year): YearPeriod
|
||||||
{
|
{
|
||||||
/** @var YearPeriod $yearPeriod */
|
/** @var YearPeriod $yearPeriod */
|
||||||
$yearPeriod = YearPeriod::factory()->createQuietly([
|
$yearPeriod = YearPeriod::factory()->create([
|
||||||
"year" => $year,
|
"year" => $year,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ namespace Tests\Unit;
|
|||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\Traits\InteractsWithYearPeriods;
|
use Tests\Traits\InteractsWithYearPeriods;
|
||||||
|
use Toby\Domain\Actions\CreateUserAction;
|
||||||
|
use Toby\Domain\Actions\CreateYearPeriodAction;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
@ -27,7 +29,11 @@ class VacationLimitTest extends TestCase
|
|||||||
$this->assertDatabaseCount("vacation_limits", 0);
|
$this->assertDatabaseCount("vacation_limits", 0);
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$user = User::factory()->create();
|
$createUserAction = $this->app->make(CreateUserAction::class);
|
||||||
|
|
||||||
|
$dumpData = User::factory()->raw();
|
||||||
|
|
||||||
|
$user = $createUserAction->execute($dumpData);
|
||||||
|
|
||||||
$this->assertDatabaseCount("vacation_limits", 1);
|
$this->assertDatabaseCount("vacation_limits", 1);
|
||||||
|
|
||||||
@ -40,10 +46,12 @@ class VacationLimitTest extends TestCase
|
|||||||
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
|
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
|
||||||
{
|
{
|
||||||
$this->assertDatabaseCount("vacation_limits", 0);
|
$this->assertDatabaseCount("vacation_limits", 0);
|
||||||
|
$createYearPeriodAction = $this->app->make(CreateYearPeriodAction::class);
|
||||||
|
$lastYear = YearPeriod::query()->max("year") + 1;
|
||||||
|
|
||||||
User::factory(10)->createQuietly();
|
User::factory(10)->create();
|
||||||
|
|
||||||
YearPeriod::factory()->create();
|
$createYearPeriodAction->execute($lastYear);
|
||||||
|
|
||||||
$this->assertDatabaseCount("vacation_limits", 10);
|
$this->assertDatabaseCount("vacation_limits", 10);
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,16 @@ class VacationRequestNotificationTest extends TestCase
|
|||||||
|
|
||||||
$user = User::factory([
|
$user = User::factory([
|
||||||
"role" => Role::Employee,
|
"role" => Role::Employee,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$technicalApprover = User::factory([
|
$technicalApprover = User::factory([
|
||||||
"role" => Role::TechnicalApprover,
|
"role" => Role::TechnicalApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$administrativeApprover = User::factory([
|
$administrativeApprover = User::factory([
|
||||||
"role" => Role::AdministrativeApprover,
|
"role" => Role::AdministrativeApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$admin = User::factory([
|
$admin = User::factory([
|
||||||
"role" => Role::Administrator,
|
"role" => Role::Administrator,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ class VacationRequestNotificationTest extends TestCase
|
|||||||
|
|
||||||
$technicalApprover = User::factory([
|
$technicalApprover = User::factory([
|
||||||
"role" => Role::TechnicalApprover,
|
"role" => Role::TechnicalApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$administrativeApprover = User::factory([
|
$administrativeApprover = User::factory([
|
||||||
"role" => Role::AdministrativeApprover,
|
"role" => Role::AdministrativeApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$admin = User::factory([
|
$admin = User::factory([
|
||||||
"role" => Role::Administrator,
|
"role" => Role::Administrator,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeVacationItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeVacationItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
@ -60,7 +60,14 @@ class YearPeriodRetrieverTest extends TestCase
|
|||||||
public function testLinks(): void
|
public function testLinks(): void
|
||||||
{
|
{
|
||||||
$expected = [
|
$expected = [
|
||||||
"current" => $this->current->year,
|
"current" => [
|
||||||
|
"year" => $this->currentYearPeriod->year,
|
||||||
|
"link" => route("year-periods.select", $this->currentYearPeriod),
|
||||||
|
],
|
||||||
|
"selected" => [
|
||||||
|
"year" => $this->currentYearPeriod->year,
|
||||||
|
"link" => route("year-periods.select", $this->currentYearPeriod),
|
||||||
|
],
|
||||||
"navigation" => [
|
"navigation" => [
|
||||||
[
|
[
|
||||||
"year" => $this->previousYearPeriod->year,
|
"year" => $this->previousYearPeriod->year,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user