Warenwirtschaft: F-13 — Produkthistorie zeigt Kappung mit Gesamtzahl und „Alle anzeigen“
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
8c460aa8bf
commit
1e7ebfb77b
3 changed files with 43 additions and 1 deletions
|
|
@ -96,6 +96,8 @@ class ProductStockController extends Controller
|
|||
return redirect()->route('admin.inventory.product-stock.index');
|
||||
}
|
||||
|
||||
private const HISTORY_LIMIT = 500;
|
||||
|
||||
public function history(Request $request): View
|
||||
{
|
||||
$query = ProductStockMovement::query()
|
||||
|
|
@ -124,10 +126,16 @@ class ProductStockController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$movements = $query->limit(500)->get();
|
||||
// Prüfung 08.09.2026 F-13: Kappung sichtbar machen (Gesamtzahl + „Alle anzeigen“),
|
||||
// statt ältere Buchungen still abzuschneiden — wie bei Produktion/Einkauf.
|
||||
$limit = $request->boolean('all') ? null : self::HISTORY_LIMIT;
|
||||
$listTotal = (clone $query)->count();
|
||||
$movements = ($limit !== null ? $query->limit($limit) : $query)->get();
|
||||
|
||||
return view('admin.inventory.product-stock.history', [
|
||||
'movements' => $movements,
|
||||
'listLimit' => $limit,
|
||||
'listTotal' => $listTotal,
|
||||
'products' => Product::query()->orderBy('name')->get(['id', 'name']),
|
||||
'reasonOptions' => ProductStockMovement::query()->distinct()->orderBy('reason')->pluck('reason')->filter()->values(),
|
||||
'filters' => [
|
||||
|
|
|
|||
|
|
@ -126,6 +126,14 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if(($listLimit ?? null) !== null && ($listTotal ?? 0) > $listLimit)
|
||||
<p class="text-muted small px-3 pb-2 mb-0">
|
||||
{{ __('Es werden die neuesten :n von :total Buchungen angezeigt.', ['n' => $listLimit, 'total' => $listTotal]) }}
|
||||
<a href="{{ route('admin.inventory.product-stock.history', array_merge(request()->query(), ['all' => 1])) }}">{{ __('Alle anzeigen') }}</a>
|
||||
</p>
|
||||
@elseif(isset($listTotal))
|
||||
<p class="text-muted small px-3 pb-2 mb-0">{{ __(':total Buchungen', ['total' => $listTotal]) }}</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -285,3 +285,29 @@ test('F-12: verkaufs-gegenbuchungen werden im monatsverbrauch netto verrechnet',
|
|||
|
||||
expect($service->monthlyConsumptionByProduct([$product->id])[$product->id])->toBe(10.0);
|
||||
});
|
||||
|
||||
test('F-13: produkthistorie zeigt die kappung mit gesamtzahl und bietet alle anzeigen', function () {
|
||||
$user = ap11MakeUser(1);
|
||||
$product = ap11MakeProduct('F13-Historie');
|
||||
$service = app(ProductStockService::class);
|
||||
$service->recordMovement($product, 'in', 1, 'Initialbestand', 'manual', 'F13-ERSTE-BUCHUNG');
|
||||
$rows = [];
|
||||
for ($i = 0; $i < 501; $i++) {
|
||||
$rows[] = ['product_id' => $product->id, 'direction' => 'out', 'quantity' => 1, 'reason' => 'Verkauf', 'source' => 'sale', 'created_at' => now()->addSeconds($i), 'updated_at' => now()];
|
||||
}
|
||||
foreach (array_chunk($rows, 100) as $chunk) {
|
||||
ProductStockMovement::query()->insert($chunk);
|
||||
}
|
||||
|
||||
$this->actingAs($user, 'user');
|
||||
$this->get(route('admin.inventory.product-stock.history', ['product_id' => $product->id]))
|
||||
->assertOk()
|
||||
->assertSee('Es werden die neuesten 500 von 502 Buchungen angezeigt.')
|
||||
->assertSee('Alle anzeigen')
|
||||
->assertDontSee('F13-ERSTE-BUCHUNG');
|
||||
|
||||
$this->get(route('admin.inventory.product-stock.history', ['product_id' => $product->id, 'all' => 1]))
|
||||
->assertOk()
|
||||
->assertSee('502 Buchungen')
|
||||
->assertSee('F13-ERSTE-BUCHUNG');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue