This commit is contained in:
Adrian Hopek 2022-04-20 10:17:58 +02:00
parent cc981b02b4
commit 4158e88634
7 changed files with 35 additions and 4 deletions

View File

@ -18,6 +18,7 @@ enum VacationType: string
case TimeInLieu = "time_in_lieu"; case TimeInLieu = "time_in_lieu";
case Sick = "sick_vacation"; case Sick = "sick_vacation";
case Absence = "absence"; case Absence = "absence";
case HomeOffice = "home_office";
public function label(): string public function label(): string
{ {

View File

@ -15,6 +15,7 @@ class VacationTypeConfigRetriever
public const KEY_BILLABLE = "billable"; public const KEY_BILLABLE = "billable";
public const KEY_HAS_LIMIT = "has_limit"; public const KEY_HAS_LIMIT = "has_limit";
public const KEY_AVAILABLE_FOR = "available_for"; public const KEY_AVAILABLE_FOR = "available_for";
public const KEY_IS_VACATION = "is_vacation";
public function __construct( public function __construct(
protected Repository $config, protected Repository $config,
@ -40,6 +41,11 @@ class VacationTypeConfigRetriever
return $this->getConfigFor($type)[static::KEY_HAS_LIMIT]; 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 public function isAvailableFor(VacationType $type, EmploymentForm $employmentForm): bool
{ {
return in_array($employmentForm, $this->getConfigFor($type)[static::KEY_AVAILABLE_FOR], true); return in_array($employmentForm, $this->getConfigFor($type)[static::KEY_AVAILABLE_FOR], true);

View File

@ -35,7 +35,8 @@ class TimesheetController extends Controller
$types = VacationType::all() $types = VacationType::all()
->filter( ->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"; $filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx";

View File

@ -11,7 +11,7 @@ use Toby\Eloquent\Helpers\YearPeriodRetriever;
use Toby\Eloquent\Models\VacationLimit; use Toby\Eloquent\Models\VacationLimit;
use Toby\Eloquent\Models\YearPeriod; use Toby\Eloquent\Models\YearPeriod;
use Toby\Infrastructure\Http\Requests\VacationLimitRequest; use Toby\Infrastructure\Http\Requests\VacationLimitRequest;
use Toby\Infrastructure\Http\Resources\SimpleUserResource; use Toby\Infrastructure\Http\Resources\UserResource;
class VacationLimitController extends Controller class VacationLimitController extends Controller
{ {
@ -32,7 +32,7 @@ class VacationLimitController extends Controller
$limitsResource = $limits->map(fn(VacationLimit $limit) => [ $limitsResource = $limits->map(fn(VacationLimit $limit) => [
"id" => $limit->id, "id" => $limit->id,
"user" => new SimpleUserResource($limit->user), "user" => new UserResource($limit->user),
"hasVacation" => $limit->hasVacation(), "hasVacation" => $limit->hasVacation(),
"days" => $limit->days, "days" => $limit->days,
"remainingLastYear" => $previousYearPeriod "remainingLastYear" => $previousYearPeriod

View File

@ -15,6 +15,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::OnRequest->value => [ VacationType::OnRequest->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -42,6 +43,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Unpaid->value => [ VacationType::Unpaid->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -51,6 +53,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Special->value => [ VacationType::Special->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -60,6 +63,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Childcare->value => [ VacationType::Childcare->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -69,6 +73,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Training->value => [ VacationType::Training->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -79,6 +84,7 @@ return [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
VacationType::Volunteering->value => [ VacationType::Volunteering->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
@ -87,6 +93,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Volunteering->value => [ VacationType::Volunteering->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -96,6 +103,7 @@ return [
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [ VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
EmploymentForm::EmploymentContract, EmploymentForm::EmploymentContract,
], ],
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
], ],
VacationType::Absence->value => [ VacationType::Absence->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
@ -107,5 +115,19 @@ return [
EmploymentForm::B2bContract, EmploymentForm::B2bContract,
EmploymentForm::BoardMemberContract, 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,
], ],
]; ];

View File

@ -16,7 +16,7 @@
</div> </div>
<div class="py-2 space-y-1"> <div class="py-2 space-y-1">
<dt class="text-sm font-medium text-gray-500"> <dt class="text-sm font-medium text-gray-500">
Rodzaj urlopu Rodzaj wniosku
</dt> </dt>
<dd class="mt-1 text-sm text-gray-900"> <dd class="mt-1 text-sm text-gray-900">
<VacationType :type="vacation.type" /> <VacationType :type="vacation.type" />

View File

@ -15,6 +15,7 @@
"time_in_lieu": "Odbiór za święto", "time_in_lieu": "Odbiór za święto",
"sick_vacation": "Zwolnienie lekarskie", "sick_vacation": "Zwolnienie lekarskie",
"absence": "Nieobecność", "absence": "Nieobecność",
"home_office": "Biuro w domu",
"employee": "Pracownik", "employee": "Pracownik",
"administrator": "Administrator", "administrator": "Administrator",
"technical_approver": "Techniczny akceptujący", "technical_approver": "Techniczny akceptujący",