Introduce spice_stock_movements ledger for traceable stock changes
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>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 22:34:10 +02:00
1 parent 7545aed494
commit fb19e9a579
9 files changed
+179 -43

No files matched your search

@@ -0,0 +1,34 @@
<?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]);
}
}