diff --git a/app/Member/Member.php b/app/Member/Member.php index 9868342d..61862186 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -355,6 +355,10 @@ class Member extends Model implements Geolocatable $preventions[] = Prevention::EFZ; } + if (!$this->has_vk) { + $preventions[] = Prevention::VK; + } + if ($this->more_ps_at === null) { if ($this->ps_at === null || $this->ps_at->diffInYears($date) >= 5) { $preventions[] = Prevention::PS; diff --git a/app/Prevention/Enums/Prevention.php b/app/Prevention/Enums/Prevention.php index 4472bc39..841767f6 100644 --- a/app/Prevention/Enums/Prevention.php +++ b/app/Prevention/Enums/Prevention.php @@ -7,6 +7,7 @@ enum Prevention case EFZ; case PS; case MOREPS; + case VK; public function text(): string { @@ -14,6 +15,7 @@ enum Prevention static::EFZ => 'erweitertes Führungszeugnis', static::PS => 'Präventionsschulung Basis Plus', static::MOREPS => 'Präventionsschulung (Auffrischung)', + static::VK => 'Verhaltenskodex', }; } } diff --git a/tests/Feature/Member/PreventionTest.php b/tests/Feature/Member/PreventionTest.php index bc164a80..2a437735 100644 --- a/tests/Feature/Member/PreventionTest.php +++ b/tests/Feature/Member/PreventionTest.php @@ -111,44 +111,49 @@ class PreventionTest extends TestCase protected function attributes(): Generator { yield [ - 'attrs' => ['efz' => null, 'ps_at' => now()], + 'attrs' => ['has_vk' => true, 'efz' => null, 'ps_at' => now()], 'preventions' => [Prevention::EFZ] ]; yield [ - 'attrs' => ['efz' => now(), 'ps_at' => null], + 'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => null], 'preventions' => [Prevention::PS] ]; yield [ - 'attrs' => ['efz' => now()->subDay(), 'ps_at' => now()], + 'attrs' => ['has_vk' => true, 'efz' => now()->subDay(), 'ps_at' => now()], 'preventions' => [] ]; yield [ - 'attrs' => ['efz' => now(), 'ps_at' => now()->subDay()], + 'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subDay()], 'preventions' => [] ]; yield [ - 'attrs' => ['efz' => now()->subYears(5)->subDay(), 'ps_at' => now()], + 'attrs' => ['has_vk' => true, 'efz' => now()->subYears(5)->subDay(), 'ps_at' => now()], 'preventions' => [Prevention::EFZ] ]; yield [ - 'attrs' => ['efz' => now(), 'ps_at' => now()->subYears(5)->subDay()], + 'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay()], 'preventions' => [Prevention::PS] ]; yield [ - 'attrs' => ['efz' => now(), 'ps_at' => now()->subYears(5)->subDay(), 'more_ps_at' => now()], + 'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(5)->subDay(), 'more_ps_at' => now()], 'preventions' => [] ]; yield [ - 'attrs' => ['efz' => now(), 'ps_at' => now()->subYears(15), 'more_ps_at' => now()->subYears(5)->subDay()], + 'attrs' => ['has_vk' => true, 'efz' => now(), 'ps_at' => now()->subYears(15), 'more_ps_at' => now()->subYears(5)->subDay()], 'preventions' => [Prevention::MOREPS], ]; + + yield [ + 'attrs' => ['has_vk' => false, 'efz' => now(), 'ps_at' => now()], + 'preventions' => [Prevention::VK], + ]; } /**