Fix im Anmeldungs-Ende

This commit is contained in:
2026-09-11 13:23:53 +02:00
parent ef6284d5cc
commit 790e8e1dbc
3 changed files with 113 additions and 3 deletions
+2 -2
View File
@@ -239,8 +239,8 @@ class EventResource extends JsonResource{
} }
public function getMultiplier() : float { public function getMultiplier() : float {
$earlyBirdEnd = $this->event->early_bird_end; // Der Frühbucherpreis gilt einschließlich des ganzen Stichtags.
if ($earlyBirdEnd > now()) { if (now() <= $this->event->early_bird_end->copy()->endOfDay()) {
return 1; return 1;
} }
+2 -1
View File
@@ -12,7 +12,8 @@ class CloseEvent implements CronTask {
$eventRepository = new EventRepository(); $eventRepository = new EventRepository();
/** @var Event $event */ /** @var Event $event */
foreach ($eventRepository->getAvailable(false) as $event) { foreach ($eventRepository->getAvailable(false) as $event) {
if ($event->registration_final_end <= $now ) { // Der Anmeldeschluss gilt einschließlich des ganzen Tages: bis 23:59:59 darf man sich anmelden.
if ($now > $event->registration_final_end->copy()->endOfDay()) {
$event->registration_allowed = false; $event->registration_allowed = false;
$event->save(); $event->save();
} }
+109
View File
@@ -0,0 +1,109 @@
<?php
namespace Tests\Feature;
use App\Models\Event;
use App\Models\Tenant;
use App\Resources\EventResource;
use App\Tasks\CloseEvent;
use DateTime;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
/**
* Anmeldeschluss und Early-Bird-Ende einer Veranstaltung.
*
* Beide sind ein Tag, keine Uhrzeit: Sie gelten einschließlich des ganzen Stichtags bis 23:59.
*/
class EventDeadlineTest extends TestCase
{
use RefreshDatabase;
private Tenant $tenant;
protected function setUp(): void
{
parent::setUp();
$this->tenant = Tenant::create([
'slug' => 'tv',
'name' => 'Test',
'email' => 't@example.com',
'email_finance' => 'finance@example.com',
'url' => 'test.local',
'account_name' => 'Test e.V.',
'account_iban' => 'DE00',
'account_bic' => 'XY',
'city' => 'Stadt',
'postcode' => '00000',
'is_active_local_group' => true,
'has_active_instance' => true,
]);
app()->instance('tenant', $this->tenant);
DB::table('participation_fee_types')->insert(['slug' => 'fixed', 'name' => 'Fix']);
}
public function test_am_anmeldeschluss_um_2359_bleibt_die_anmeldung_offen(): void
{
$event = $this->makeEvent();
$this->travelTo(new DateTime('2026-09-11 23:59:00'));
new CloseEvent()->handle();
$this->assertTrue($event->fresh()->registration_allowed);
}
public function test_am_folgetag_schliesst_der_cron_die_anmeldung(): void
{
$event = $this->makeEvent();
$this->travelTo(new DateTime('2026-09-12 00:10:00'));
new CloseEvent()->handle();
$this->assertFalse($event->fresh()->registration_allowed);
}
public function test_am_early_bird_stichtag_um_2359_gilt_der_fruehbucherpreis(): void
{
$event = $this->makeEvent();
$this->travelTo(new DateTime('2026-09-11 23:59:00'));
$this->assertEqualsWithDelta(1.0, new EventResource($event)->getMultiplier(), 0.0001);
}
public function test_am_tag_nach_dem_early_bird_stichtag_gilt_der_aufschlag(): void
{
$event = $this->makeEvent();
$this->travelTo(new DateTime('2026-09-12 00:00:01'));
$this->assertEqualsWithDelta(1.2, new EventResource($event)->getMultiplier(), 0.0001);
}
private function makeEvent(): Event
{
return Event::create([
'tenant' => $this->tenant->slug,
'name' => 'Event',
'identifier' => 'evt-' . uniqid(),
'location' => 'Ort',
'postal_code' => '00000',
'email' => 'e@example.com',
'start_date' => '2026-09-20',
'end_date' => '2026-09-25',
'early_bird_end' => '2026-09-11',
'registration_final_end' => '2026-09-11',
'early_bird_end_amount_increase' => 20,
'registration_allowed' => true,
'account_owner' => 'Owner',
'account_iban' => 'DE00',
'participation_fee_type' => 'fixed',
'pay_per_day' => false,
'pay_direct' => false,
]);
}
}