feat(ticket): enhance ticket details with entry reservation amount and product naming for desfile

This commit is contained in:
2026-09-25 11:31:54 -03:00
parent f29c5692b9
commit 7f754037bb
2 changed files with 36 additions and 5 deletions

View File

@@ -11,6 +11,8 @@ class AdminAppTicketRowService
{ {
private const FIESTA_FUTBOL_INFANTIL = 'fiesta_futbol_infantil'; private const FIESTA_FUTBOL_INFANTIL = 'fiesta_futbol_infantil';
private const DESFILE_PURA_TENDENCIA = 'desfile_pura_tendencia';
private const CATEGORY_PRESENTATIONS = [ private const CATEGORY_PRESENTATIONS = [
'alojamientos' => ['category' => 'Camping', 'product' => 'tipo_alojamiento', 'type' => null, 'size' => null], 'alojamientos' => ['category' => 'Camping', 'product' => 'tipo_alojamiento', 'type' => null, 'size' => null],
'camping' => ['category' => null, '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; $purchaseItem = $ticket->sourcePurchaseItem;
$refund = $ticket->refund; $refund = $ticket->refund;
$variantProperties = $this->variantProperties($ticket);
return [ return [
'source_purchase_item_id' => $ticket->source_purchase_item_id, 'source_purchase_item_id' => $ticket->source_purchase_item_id,
'order_number' => $purchaseItem?->compra_id, 'order_number' => $purchaseItem?->compra_id,
'product' => $purchaseItem?->item_nombre 'product' => $this->productName($ticket, $purchaseItem?->item_nombre, $variantProperties),
?? $ticket->sourceCatalogItem?->nombre 'amount' => $purchaseItem?->precio_unitario ?? $ticket->entryReservation?->importe,
?? $ticket->name,
'amount' => $purchaseItem?->precio_unitario,
'refund_type' => $refund?->type, 'refund_type' => $refund?->type,
'refund_type_label' => $refund?->typeLabel(), 'refund_type_label' => $refund?->typeLabel(),
'client' => $purchaseItem?->purchase?->nombre_apellido ?? $ticket->user?->nombre_apellido, 'client' => $purchaseItem?->purchase?->nombre_apellido ?? $ticket->user?->nombre_apellido,
'status' => $ticket->status, 'status' => $ticket->status,
'scanned_by' => $ticket->scannerUser?->nombre_apellido, 'scanned_by' => $ticket->scannerUser?->nombre_apellido,
'variant_properties' => $this->variantProperties($ticket), 'variant_properties' => $variantProperties,
'allow_refund' => $ticket->allow_refund(), 'allow_refund' => $ticket->allow_refund(),
]; ];
} }
/**
* @param list<array{code: string, label: string, values: list<array{value: string, label: string}>}> $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<string, mixed>|null $details */ /** @param array<string, mixed>|null $details */
public function values(Ticket $ticket, ?array $details = null): array public function values(Ticket $ticket, ?array $details = null): array
{ {

View File

@@ -254,6 +254,8 @@ class AdminAppTicketControllerTest extends TestCase
$this->getJson('/api/v1/adminapp/tenant/tickets') $this->getJson('/api/v1/adminapp/tenant/tickets')
->assertOk() ->assertOk()
->assertJsonPath('data.0.id', $ticket->id) ->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.allow_refund', true)
->assertJsonPath('data.0.can_refund', false); ->assertJsonPath('data.0.can_refund', false);
@@ -979,6 +981,8 @@ class AdminAppTicketControllerTest extends TestCase
->assertOk() ->assertOk()
->assertJsonCount(1, 'data') ->assertJsonCount(1, 'data')
->assertJsonPath('data.0.id', $matching->id) ->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.tipo', 'VIP')
->assertJsonPath('data.0.values.sector', 'A'); ->assertJsonPath('data.0.values.sector', 'A');