fix(ticket): temporarily disable maximum use date validation in ticket generation
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Catalog\Models\Variant;
|
||||
use App\Domains\Ticket\Exceptions\TicketGenerationException;
|
||||
use App\Domains\Ticket\Models\Ticket;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -27,14 +26,11 @@ class TicketGeneratorService
|
||||
throw TicketGenerationException::invalidQuantity();
|
||||
}
|
||||
|
||||
$now = now();
|
||||
|
||||
return DB::transaction(function () use ($catalogItem, $user, $quantity, $sourceVariantId, $now): Collection {
|
||||
return DB::transaction(function () use ($catalogItem, $user, $quantity, $sourceVariantId): Collection {
|
||||
$targets = $this->resolveTargets(
|
||||
$catalogItem,
|
||||
$quantity,
|
||||
$sourceVariantId,
|
||||
$now,
|
||||
);
|
||||
|
||||
return $targets->map(function (array $target) use (
|
||||
@@ -68,11 +64,10 @@ class TicketGeneratorService
|
||||
CatalogItem $catalogItem,
|
||||
int $quantity,
|
||||
?int $sourceVariantId,
|
||||
CarbonInterface $now,
|
||||
): Collection {
|
||||
if (! $catalogItem->isBundle()) {
|
||||
$variant = $this->resolveVariant($catalogItem, $sourceVariantId);
|
||||
$this->validateTarget($catalogItem, $variant, $now);
|
||||
$this->validateTarget($catalogItem, $variant);
|
||||
|
||||
return Collection::times($quantity, fn (): array => [
|
||||
'catalog_item' => $catalogItem,
|
||||
@@ -90,10 +85,10 @@ class TicketGeneratorService
|
||||
}
|
||||
|
||||
return $catalogItem->bundleComponents
|
||||
->flatMap(function ($component) use ($quantity, $now): Collection {
|
||||
->flatMap(function ($component) use ($quantity): Collection {
|
||||
$componentItem = $component->catalogItem;
|
||||
$variant = $component->variant;
|
||||
$this->validateTarget($componentItem, $variant, $now);
|
||||
$this->validateTarget($componentItem, $variant);
|
||||
|
||||
return Collection::times(
|
||||
$quantity * $component->quantity,
|
||||
@@ -133,16 +128,17 @@ class TicketGeneratorService
|
||||
private function validateTarget(
|
||||
CatalogItem $catalogItem,
|
||||
?Variant $variant,
|
||||
CarbonInterface $now,
|
||||
): void {
|
||||
if (! $catalogItem->has_tickets) {
|
||||
throw TicketGenerationException::ticketsDisabled($catalogItem);
|
||||
}
|
||||
|
||||
$selectedItem = $variant ?? $catalogItem;
|
||||
|
||||
if ($selectedItem->getMaximumUseDate()?->lessThanOrEqualTo($now)) {
|
||||
throw TicketGenerationException::maximumUseDateReached($catalogItem);
|
||||
}
|
||||
// TODO: Reactivar esta validación cuando los pagos con productos vencidos
|
||||
// deban rechazarse nuevamente. Se deja deshabilitada temporalmente.
|
||||
// $selectedItem = $variant ?? $catalogItem;
|
||||
//
|
||||
// if ($selectedItem->getMaximumUseDate()?->lessThanOrEqualTo(now())) {
|
||||
// throw TicketGenerationException::maximumUseDateReached($catalogItem);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user