diff --git a/app/Http/Controllers/Admin/Inventory/RawMaterialStockController.php b/app/Http/Controllers/Admin/Inventory/RawMaterialStockController.php index 492bfbb..6d9ab50 100644 --- a/app/Http/Controllers/Admin/Inventory/RawMaterialStockController.php +++ b/app/Http/Controllers/Admin/Inventory/RawMaterialStockController.php @@ -111,7 +111,11 @@ class RawMaterialStockController extends Controller $minAlert = $ingredient->min_stock_alert !== null ? (float) $ingredient->min_stock_alert : null; $leadDays = $ingredient->delivery_time_days !== null ? (int) $ingredient->delivery_time_days : null; - $lastPriceBySupplier = $this->stockEntryRepository->lastNetPricePerSupplier($ingredient->id); + // Prüfung 08.09.2026 F-11: Einkaufspreise nur für Admins (wie Einkauf/Wareneingang), + // Copyreader (Versand/Produktion) sehen die Rohstoffseite ohne Preise. + $lastPriceBySupplier = auth()->user()->isAdmin() + ? $this->stockEntryRepository->lastNetPricePerSupplier($ingredient->id) + : []; $productStock = $this->productStockService->currentStockByProduct($ingredient->products->pluck('id')->all()); diff --git a/resources/views/admin/inventory/raw-material-stock/show.blade.php b/resources/views/admin/inventory/raw-material-stock/show.blade.php index e62b92a..85cfe2d 100644 --- a/resources/views/admin/inventory/raw-material-stock/show.blade.php +++ b/resources/views/admin/inventory/raw-material-stock/show.blade.php @@ -129,7 +129,9 @@ {{ __('Lieferant') }} {{ __('Lieferzeit') }} - {{ __('Letzter Einkauf (Netto/kg)') }} + @if(Auth::user()->isAdmin()) + {{ __('Letzter Einkauf (Netto/kg)') }} + @endif @@ -153,13 +155,15 @@ @endif {{ $deliveryTime ?: '—' }} - - @if($lastPrice !== null) - {{ \App\Services\Util::formatNumber($lastPrice, 2) }} € - @else - — - @endif - + @if(Auth::user()->isAdmin()) + + @if($lastPrice !== null) + {{ \App\Services\Util::formatNumber($lastPrice, 2) }} € + @else + — + @endif + + @endif @if($orderUrl) {{ __('Zum Shop') }} diff --git a/tests/Feature/RawMaterialStockTest.php b/tests/Feature/RawMaterialStockTest.php index ffcb097..c798f62 100644 --- a/tests/Feature/RawMaterialStockTest.php +++ b/tests/Feature/RawMaterialStockTest.php @@ -463,3 +463,35 @@ test('AP-37: enthalten-in listet ein produkt trotz doppelter rezeptzeilen nur ei expect(substr_count($html, 'AP37-Zaubercreme-Unikat'))->toBe(1); }); + +function f11Setup(): array +{ + $admin = ap10MakeUser(7); + $location = Location::factory()->create(); + $supplier = Supplier::factory()->create(['name' => 'F11-Lieferant']); + $ing = ap10MakeIngredient('F11-Preis'); + $ing->suppliers()->attach($supplier->id, ['preferred' => true]); + ap10MakeStock($ing, $location, $supplier, $admin, ['price_per_kg' => 123.45]); + + return [$admin, $ing]; +} + +test('F-11: copyreader sehen auf der rohstoff-detailseite keine einkaufspreise', function () { + [, $ing] = f11Setup(); + + $this->actingAs(ap10MakeUser(1), 'user') + ->get(route('admin.inventory.raw-material-stock.show', $ing)) + ->assertSuccessful() + ->assertSee('F11-Lieferant') + ->assertDontSee('123,45') + ->assertDontSee('Letzter Einkauf'); +}); + +test('F-11: admins sehen den letzten einkaufspreis weiterhin', function () { + [$admin, $ing] = f11Setup(); + + $this->actingAs($admin, 'user') + ->get(route('admin.inventory.raw-material-stock.show', $ing)) + ->assertSuccessful() + ->assertSee('123,45'); +});