Files
SpiceManagementSystem/app/Filament/User/Resources/SpiceResource/RelationManagers/StockMovementsRelationManager.php
T
Malek TellissiandClaude Sonnet 4.6 fb19e9a579
Deploy / deploy (push) Successful in 16s
Introduce spice_stock_movements ledger for traceable stock changes
Every delivery and batch now writes a signed movement entry instead of
directly incrementing/decrementing spice.quantity. The balance is always
the sum of all movements. Existing data is backfilled in the migration.
Rohstoff edit page shows the full movement history (Lagerbewegungen tab).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-12 22:34:10 +02:00

35 lines
1.1 KiB
PHP

<?php
namespace App\Filament\User\Resources\SpiceResource\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
class StockMovementsRelationManager extends RelationManager
{
protected static string $relationship = 'stockMovements';
protected static ?string $title = 'Lagerbewegungen';
public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('created_at')
->label('Datum')
->dateTime('d.m.Y H:i')
->sortable(),
Tables\Columns\TextColumn::make('description')
->label('Beschreibung'),
Tables\Columns\TextColumn::make('amount')
->label('Menge')
->formatStateUsing(fn ($state) => ($state > 0 ? '+' : '') . number_format($state, 2, ',', '.') . 'g')
->color(fn ($state) => $state > 0 ? 'success' : 'danger'),
])
->defaultSort('created_at', 'desc')
->paginated([25, 50]);
}
}