Warenwirtschaft: F-11 — Einkaufspreise auf der Rohstoff-Detailseite nur für Admins

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-09-08 11:04:07 +00:00
parent f93b16c8f7
commit 691f763011
3 changed files with 49 additions and 9 deletions

View file

@ -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());

View file

@ -129,7 +129,9 @@
<tr>
<th>{{ __('Lieferant') }}</th>
<th>{{ __('Lieferzeit') }}</th>
<th class="text-right">{{ __('Letzter Einkauf (Netto/kg)') }}</th>
@if(Auth::user()->isAdmin())
<th class="text-right">{{ __('Letzter Einkauf (Netto/kg)') }}</th>
@endif
<th class="text-right" style="width: 11rem;"></th>
</tr>
</thead>
@ -153,13 +155,15 @@
@endif
</td>
<td>{{ $deliveryTime ?: '—' }}</td>
<td class="text-right">
@if($lastPrice !== null)
{{ \App\Services\Util::formatNumber($lastPrice, 2) }} €
@else
<span class="text-muted">—</span>
@endif
</td>
@if(Auth::user()->isAdmin())
<td class="text-right">
@if($lastPrice !== null)
{{ \App\Services\Util::formatNumber($lastPrice, 2) }} €
@else
<span class="text-muted">—</span>
@endif
</td>
@endif
<td class="text-right">
@if($orderUrl)
<a href="{{ $orderUrl }}" target="_blank" rel="noopener" class="btn btn-sm btn-outline-secondary">{{ __('Zum Shop') }}</a>

View file

@ -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');
});