feat(event): support ticket refund configuration in event endpoints

This commit is contained in:
2026-09-11 16:22:46 -03:00
parent c0c19c9c01
commit 4bb4f526e4
4 changed files with 117 additions and 0 deletions

View File

@@ -51,6 +51,10 @@ class AdminAppEventControllerTest extends TestCase
->assertOk()
->assertJsonPath('data.title', 'Festival Acme')
->assertJsonPath('data.location', 'Predio Ferial, Rosario')
->assertJsonPath('data.allow_ticket_refund', true)
->assertJsonPath('data.allow_ticket_total_refund', true)
->assertJsonPath('data.allow_ticket_partial_refund', true)
->assertJsonPath('data.ticket_partial_refund_percentage', '25.50')
->assertJsonCount(0, 'data.dates')
->assertJsonPath('data.contact.whatsapp_url', 'https://wa.me/5493415550101')
->assertJsonPath('data.contact.instagram_url', 'https://instagram.com/acme')
@@ -62,6 +66,10 @@ class AdminAppEventControllerTest extends TestCase
'event_title' => 'Festival Acme',
'event_location' => 'Predio Ferial, Rosario',
'event_date_text' => null,
'allow_ticket_refund' => true,
'allow_ticket_total_refund' => true,
'allow_ticket_partial_refund' => true,
'ticket_partial_refund_percentage' => 25.50,
]);
$this->assertDatabaseCount('event_dates', 0);
$this->assertDatabaseHas('tenant_social_media', [
@@ -71,6 +79,56 @@ class AdminAppEventControllerTest extends TestCase
]);
}
public function test_disabling_refunds_preserves_the_configured_types_and_percentage(): void
{
$tenant = $this->createTenant('acme');
$tenant->update([
'allow_ticket_refund' => true,
'allow_ticket_total_refund' => true,
'allow_ticket_partial_refund' => true,
'ticket_partial_refund_percentage' => 35.50,
]);
Sanctum::actingAs($this->createAdminAppUser($tenant));
$payload = $this->eventPayload();
$payload['allow_ticket_refund'] = false;
$payload['ticket_partial_refund_percentage'] = 35.50;
$this->putJson('/api/v1/adminapp/tenant/event', $payload)
->assertOk()
->assertJsonPath('data.allow_ticket_refund', false)
->assertJsonPath('data.allow_ticket_total_refund', true)
->assertJsonPath('data.allow_ticket_partial_refund', true)
->assertJsonPath('data.ticket_partial_refund_percentage', '35.50');
$tenant->refresh();
$this->assertFalse($tenant->allow_refund());
$this->assertTrue($tenant->allow_ticket_total_refund);
$this->assertTrue($tenant->allow_ticket_partial_refund);
$this->assertSame('35.50', $tenant->ticket_partial_refund_percentage);
}
public function test_enabled_refunds_require_a_type_and_a_valid_partial_percentage(): void
{
$tenant = $this->createTenant('acme');
Sanctum::actingAs($this->createAdminAppUser($tenant));
$payload = $this->eventPayload();
$payload['allow_ticket_total_refund'] = false;
$payload['allow_ticket_partial_refund'] = false;
$this->putJson('/api/v1/adminapp/tenant/event', $payload)
->assertUnprocessable()
->assertJsonValidationErrors('allow_ticket_refund');
$payload['allow_ticket_partial_refund'] = true;
$payload['ticket_partial_refund_percentage'] = 0;
$this->putJson('/api/v1/adminapp/tenant/event', $payload)
->assertUnprocessable()
->assertJsonValidationErrors('ticket_partial_refund_percentage');
}
public function test_an_adminapp_user_can_read_only_its_tenant_active_event(): void
{
$tenant = $this->createTenant('acme');
@@ -375,6 +433,10 @@ class AdminAppEventControllerTest extends TestCase
return [
'title' => 'Festival Acme',
'location' => 'Predio Ferial, Rosario',
'allow_ticket_refund' => true,
'allow_ticket_total_refund' => true,
'allow_ticket_partial_refund' => true,
'ticket_partial_refund_percentage' => 25.50,
'contact' => [
'whatsapp_url' => 'https://wa.me/5493415550101',
'instagram_url' => 'https://instagram.com/acme',