feat(refund): enhance refund process by adding backfill for refunded_units and updating inventory restoration logic

This commit is contained in:
2026-09-16 15:00:41 -03:00
parent 353fd34db2
commit a46bf905e8
4 changed files with 168 additions and 7 deletions

View File

@@ -226,13 +226,13 @@ class AdminAppTicketService
'amount' => number_format($refundAmount, 2, '.', ''),
]);
$this->restoreInventory($ticket);
$this->restoreInventory($ticket, $purchaseItem);
return $ticket->refresh()->load(self::RELATIONS);
});
}
private function restoreInventory(Ticket $ticket): void
private function restoreInventory(Ticket $ticket, PurchaseItem $purchaseItem): void
{
$catalogItem = $ticket->sourceCatalogItem;
if ($catalogItem === null) {
@@ -242,7 +242,7 @@ class AdminAppTicketService
}
// Bundle components need a per-ticket allocation before they can be restored.
if ($catalogItem->isBundle()) {
if ($catalogItem->isBundle() || $purchaseItem->sourceCatalogItem?->isBundle()) {
return;
}