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 Sick = "sick_vacation";
case Absence = "absence";
case HomeOffice = "home_office";
public function label(): string
{

View File

@@ -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);

View File

@@ -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";

View File

@@ -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