From c7b28d9053b6c5bf8864e8ad662c9b9501d02ce1 Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Wed, 11 Mar 2026 21:50:26 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20mejorar=20gesti=C3=B3n=20de=20seriales?= =?UTF-8?q?=20en=20entradas,=20salidas=20y=20transferencias=20de=20inventa?= =?UTF-8?q?rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/InventoryMovementService.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Services/InventoryMovementService.php b/app/Services/InventoryMovementService.php index 9edf9fa..429029f 100644 --- a/app/Services/InventoryMovementService.php +++ b/app/Services/InventoryMovementService.php @@ -211,8 +211,11 @@ public function bulkEntry(array $data): array 'invoice_reference' => $data['invoice_reference'], ]); + // Solo crear seriales si el producto los requiere (track_serials Y unidad sin decimales) + $requiresSerials = $inventory->track_serials && ! $inventory->unitOfMeasure?->allows_decimals; + // Crear seriales DESPUÉS (para asignar movement_id) - if (! empty($serialNumbers)) { + if ($requiresSerials && ! empty($serialNumbers)) { $serials = []; foreach ($serialNumbers as $serialNumber) { $serials[] = [ @@ -239,7 +242,7 @@ public function bulkEntry(array $data): array $this->updateWarehouseStock($inventory->id, $warehouse->id, $quantity); } - $movements[] = $movement->load(['inventory', 'warehouseTo']); + $movements[] = $movement->load(['inventory', 'warehouseTo', 'serials']); } return $movements; @@ -351,7 +354,7 @@ public function bulkExit(array $data): array ]); } - $movements[] = $movement->load(['inventory', 'warehouseFrom']); + $movements[] = $movement->load(['inventory', 'warehouseFrom', 'exitedSerials']); } return $movements; @@ -467,7 +470,7 @@ public function bulkTransfer(array $data): array ]); } - $movements[] = $movement->load(['inventory', 'warehouseFrom', 'warehouseTo']); + $movements[] = $movement->load(['inventory', 'warehouseFrom', 'warehouseTo', 'transferredSerials']); } return $movements;