Squashed commit of the following:
commit 6ae625d4fdc11989950ef0678db62fdb52be7c8c Author: ncoronel <ncoronel@quo.ar> Date: Wed Sep 2 09:46:18 2026 -0300 refactor(tickets): enhance search functionality for tickets by client names and formatted amounts commit 098e525d32be9cb6487bc01a3d120aa0f2386a15 Author: ncoronel <ncoronel@quo.ar> Date: Wed Sep 2 09:09:30 2026 -0300 fix(tickets): protect referenced purchase items commit 210db17f2f6a6a4a509297b773a2b5d3e3149a3d Author: ncoronel <ncoronel@quo.ar> Date: Wed Sep 2 08:59:24 2026 -0300 test(tickets): cover purchase item references commit 6a004713c4bad622dfa5e26394458925db1cb5a7 Author: ncoronel <ncoronel@quo.ar> Date: Wed Sep 2 08:59:02 2026 -0300 refactor(tickets): reference purchase items directly
This commit is contained in:
@@ -23,13 +23,13 @@ class TicketGeneratorService
|
||||
User $user,
|
||||
int $quantity = 1,
|
||||
?int $sourceVariantId = null,
|
||||
?int $sourcePurchaseId = null,
|
||||
?int $sourcePurchaseItemId = null,
|
||||
): Collection {
|
||||
if ($quantity < 1) {
|
||||
throw TicketGenerationException::invalidQuantity();
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($catalogItem, $user, $quantity, $sourceVariantId, $sourcePurchaseId): Collection {
|
||||
return DB::transaction(function () use ($catalogItem, $user, $quantity, $sourceVariantId, $sourcePurchaseItemId): Collection {
|
||||
$targets = $this->resolveTargets(
|
||||
$catalogItem,
|
||||
$quantity,
|
||||
@@ -37,7 +37,7 @@ class TicketGeneratorService
|
||||
);
|
||||
|
||||
return $targets->map(function (array $target) use (
|
||||
$sourcePurchaseId,
|
||||
$sourcePurchaseItemId,
|
||||
$user,
|
||||
): Ticket {
|
||||
$item = $target['catalog_item'];
|
||||
@@ -45,7 +45,7 @@ class TicketGeneratorService
|
||||
$ticket = Ticket::query()->create([
|
||||
'tenant_code' => $item->tenant_code,
|
||||
'ticket' => (string) Str::uuid(),
|
||||
'source_purchase_id' => $sourcePurchaseId,
|
||||
'source_purchase_item_id' => $sourcePurchaseItemId,
|
||||
'source_catalog_item_id' => $item->getKey(),
|
||||
'source_variant_id' => $variant?->getKey(),
|
||||
'used_at' => null,
|
||||
|
||||
Reference in New Issue
Block a user