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;