feat(ticket): enhance ticket details with entry reservation amount and product naming for desfile
This commit is contained in:
@@ -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<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 */
|
||||
public function values(Ticket $ticket, ?array $details = null): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user