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

+10
View File
@@ -14,4 +14,14 @@ class Spice extends Model
->withPivot('amount_in_percent')
->withTimestamps();
}
public function stockMovements()
{
return $this->hasMany(SpiceStockMovement::class);
}
public function recalculateQuantity(): void
{
$this->update(['quantity' => $this->stockMovements()->sum('amount')]);
}
}