Deploy / deploy (push) Successful in 16s
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>
35 lines
1.1 KiB
PHP
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]);
|
|
}
|
|
}
|