homo #8

Merged
ncoronel merged 79 commits from homo into main 2026-09-17 17:52:21 +00:00
54 changed files with 2024 additions and 186 deletions
Showing only changes of commit 6384c0046d - Show all commits

View File

@@ -80,14 +80,23 @@ class AdminAppTicketService
public function cancel(Tenant $tenant, int $ticketId): Ticket
{
$ticket = Ticket::query()
->where('tenant_code', $tenant->codigo)
->findOrFail($ticketId);
return DB::transaction(function () use ($tenant, $ticketId): Ticket {
$ticket = Ticket::query()
->where('tenant_code', $tenant->codigo)
->lockForUpdate()
->findOrFail($ticketId);
$ticket->markAsCancelled();
$ticket->save();
if (! $ticket->can_cancel()) {
throw ValidationException::withMessages([
'status' => 'El ticket debe estar activo para poder cancelarlo.',
]);
}
return $ticket->refresh()->load(self::RELATIONS);
$ticket->markAsCancelled();
$ticket->save();
return $ticket->refresh()->load(self::RELATIONS);
});
}
public function refund(Tenant $tenant, int $ticketId, string $refundType): Ticket
@@ -100,6 +109,18 @@ class AdminAppTicketService
->lockForUpdate()
->findOrFail($ticketId);
if (! $ticket->can_refund()) {
if ($ticket->status !== Ticket::STATUS_ACTIVE) {
throw ValidationException::withMessages([
'status' => 'El ticket debe estar activo para poder reembolsarlo.',
]);
}
throw ValidationException::withMessages([
'refund' => 'El reembolso no está disponible para este ticket.',
]);
}
$purchaseItem = PurchaseItem::query()
->lockForUpdate()
->find($ticket->source_purchase_item_id);