feat(tenant): add master toggle for ticket refunds
This commit is contained in:
@@ -100,7 +100,10 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
->assertJsonPath('data.0.can_refund', false);
|
||||
|
||||
// Total refund allowed
|
||||
$tenant->update(['allow_ticket_total_refund' => true]);
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
]);
|
||||
$this->getJson('/api/v1/adminapp/tenant/tickets')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.0.allow_refund', true)
|
||||
@@ -108,6 +111,7 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
|
||||
// Partial refund allowed with percentage set
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => false,
|
||||
'allow_ticket_partial_refund' => true,
|
||||
'ticket_partial_refund_percentage' => 20.00,
|
||||
@@ -117,6 +121,17 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
->assertJsonPath('data.0.allow_refund', true)
|
||||
->assertJsonPath('data.0.can_refund', true);
|
||||
|
||||
// Master toggle disabled while preserving the partial refund preference
|
||||
$tenant->update(['allow_ticket_refund' => false]);
|
||||
$this->getJson('/api/v1/adminapp/tenant/tickets')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.0.allow_refund', false)
|
||||
->assertJsonPath('data.0.can_refund', false);
|
||||
$this->assertTrue($tenant->fresh()->allow_ticket_partial_refund);
|
||||
$this->assertSame('20.00', $tenant->fresh()->ticket_partial_refund_percentage);
|
||||
|
||||
$tenant->update(['allow_ticket_refund' => true]);
|
||||
|
||||
// Partial refund enabled but percentage is 0
|
||||
$tenant->update([
|
||||
'ticket_partial_refund_percentage' => 0,
|
||||
@@ -162,7 +177,10 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
public function test_it_totally_refunds_a_ticket_when_the_tenant_allows_it(): void
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-total-refund');
|
||||
$tenant->update(['allow_ticket_total_refund' => true]);
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
]);
|
||||
$admin = $this->createAdminAppUser($tenant);
|
||||
$this->grantTicketsMenu($tenant);
|
||||
Sanctum::actingAs($admin);
|
||||
@@ -184,6 +202,7 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-partial-refund');
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_partial_refund' => true,
|
||||
'ticket_partial_refund_percentage' => 25.50,
|
||||
]);
|
||||
@@ -239,6 +258,7 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-calc-both');
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
'allow_ticket_partial_refund' => true,
|
||||
'ticket_partial_refund_percentage' => 30.00,
|
||||
@@ -258,6 +278,7 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-calc-total');
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
'allow_ticket_partial_refund' => false,
|
||||
]);
|
||||
@@ -276,6 +297,7 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-calc-insufficient');
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
'allow_ticket_partial_refund' => true,
|
||||
'ticket_partial_refund_percentage' => 50.00,
|
||||
@@ -299,7 +321,10 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
public function test_it_fails_calculating_refund_if_ticket_is_not_active(): void
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-calc-inactive');
|
||||
$tenant->update(['allow_ticket_total_refund' => true]);
|
||||
$tenant->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
]);
|
||||
$admin = $this->createAdminAppUser($tenant);
|
||||
$this->grantTicketsMenu($tenant);
|
||||
Sanctum::actingAs($admin);
|
||||
@@ -316,8 +341,14 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
{
|
||||
$tenantA = $this->createTenant('ticket-calc-a');
|
||||
$tenantB = $this->createTenant('ticket-calc-b');
|
||||
$tenantA->update(['allow_ticket_total_refund' => true]);
|
||||
$tenantB->update(['allow_ticket_total_refund' => true]);
|
||||
$tenantA->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
]);
|
||||
$tenantB->update([
|
||||
'allow_ticket_refund' => true,
|
||||
'allow_ticket_total_refund' => true,
|
||||
]);
|
||||
|
||||
$adminA = $this->createAdminAppUser($tenantA);
|
||||
$adminB = $this->createAdminAppUser($tenantB);
|
||||
|
||||
Reference in New Issue
Block a user