From 7f754037bbd8b9592651c90185b48e91e5382fdc Mon Sep 17 00:00:00 2001 From: ncoronel Date: Fri, 25 Sep 2026 11:31:54 -0300 Subject: [PATCH] feat(ticket): enhance ticket details with entry reservation amount and product naming for desfile --- .../Services/AdminAppTicketRowService.php | 37 ++++++++++++++++--- .../Ticket/AdminAppTicketControllerTest.php | 4 ++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/Domains/Ticketing/Ticket/Services/AdminAppTicketRowService.php b/app/Domains/Ticketing/Ticket/Services/AdminAppTicketRowService.php index d734b820..740749be 100644 --- a/app/Domains/Ticketing/Ticket/Services/AdminAppTicketRowService.php +++ b/app/Domains/Ticketing/Ticket/Services/AdminAppTicketRowService.php @@ -11,6 +11,8 @@ class AdminAppTicketRowService { private const FIESTA_FUTBOL_INFANTIL = 'fiesta_futbol_infantil'; + private const DESFILE_PURA_TENDENCIA = 'desfile_pura_tendencia'; + private const CATEGORY_PRESENTATIONS = [ 'alojamientos' => ['category' => 'Camping', 'product' => 'tipo_alojamiento', 'type' => null, 'size' => null], 'camping' => ['category' => null, 'product' => 'tipo_alojamiento', 'type' => null, 'size' => null], @@ -25,24 +27,49 @@ class AdminAppTicketRowService { $purchaseItem = $ticket->sourcePurchaseItem; $refund = $ticket->refund; + $variantProperties = $this->variantProperties($ticket); return [ 'source_purchase_item_id' => $ticket->source_purchase_item_id, 'order_number' => $purchaseItem?->compra_id, - 'product' => $purchaseItem?->item_nombre - ?? $ticket->sourceCatalogItem?->nombre - ?? $ticket->name, - 'amount' => $purchaseItem?->precio_unitario, + 'product' => $this->productName($ticket, $purchaseItem?->item_nombre, $variantProperties), + 'amount' => $purchaseItem?->precio_unitario ?? $ticket->entryReservation?->importe, 'refund_type' => $refund?->type, 'refund_type_label' => $refund?->typeLabel(), 'client' => $purchaseItem?->purchase?->nombre_apellido ?? $ticket->user?->nombre_apellido, 'status' => $ticket->status, 'scanned_by' => $ticket->scannerUser?->nombre_apellido, - 'variant_properties' => $this->variantProperties($ticket), + 'variant_properties' => $variantProperties, 'allow_refund' => $ticket->allow_refund(), ]; } + /** + * @param list}> $properties + */ + private function productName(Ticket $ticket, ?string $snapshotName, array $properties): string + { + $baseName = $ticket->sourceCatalogItem?->nombre ?: $ticket->name; + + if ($ticket->tenant_code !== self::DESFILE_PURA_TENDENCIA) { + return $snapshotName ?: $baseName; + } + + $seatDescription = collect(['sector', 'fila', 'asiento']) + ->map(function (string $code) use ($properties): ?string { + $property = collect($properties)->firstWhere('code', $code); + $values = collect($property['values'] ?? [])->pluck('label')->filter()->implode(', '); + + return $property === null || $values === '' + ? null + : $property['label'].' '.$values; + }) + ->filter() + ->implode(', '); + + return $seatDescription === '' ? ($snapshotName ?: $baseName) : "{$baseName} ({$seatDescription})"; + } + /** @param array|null $details */ public function values(Ticket $ticket, ?array $details = null): array { diff --git a/tests/Feature/Ticket/AdminAppTicketControllerTest.php b/tests/Feature/Ticket/AdminAppTicketControllerTest.php index 7e00c4b5..20f83794 100644 --- a/tests/Feature/Ticket/AdminAppTicketControllerTest.php +++ b/tests/Feature/Ticket/AdminAppTicketControllerTest.php @@ -254,6 +254,8 @@ class AdminAppTicketControllerTest extends TestCase $this->getJson('/api/v1/adminapp/tenant/tickets') ->assertOk() ->assertJsonPath('data.0.id', $ticket->id) + ->assertJsonPath('data.0.amount', '100.00') + ->assertJsonPath('data.0.values.amount', 100) ->assertJsonPath('data.0.allow_refund', true) ->assertJsonPath('data.0.can_refund', false); @@ -979,6 +981,8 @@ class AdminAppTicketControllerTest extends TestCase ->assertOk() ->assertJsonCount(1, 'data') ->assertJsonPath('data.0.id', $matching->id) + ->assertJsonPath('data.0.product', 'Entrada (Sector A)') + ->assertJsonPath('data.0.values.product', 'Entrada (Sector A)') ->assertJsonPath('data.0.values.tipo', 'VIP') ->assertJsonPath('data.0.values.sector', 'A');