Warenwirtschaft: N-06 — Dichte-Snapshot der ml-Bestellung gilt auch im Bearbeiten

Formular, Update-Validierung und Repository nutzen bei unverändertem Rohstoff den
Snapshot als Rückfall; bei Rohstoffwechsel wird keine fremde Dichte übernommen.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-09-08 11:48:02 +00:00
parent 9acb05380a
commit 5d82875d2f
4 changed files with 73 additions and 1 deletions

View file

@ -30,6 +30,13 @@ class StockEntryRepository
{
if (array_key_exists('entry_type', $data)) {
$data['unit'] = ($data['entry_type'] ?? '') === 'ingredient' ? 'gram' : 'piece';
// N-06: Dichte-Snapshot nur bei unverändertem Rohstoff als Rückfall mitgeben —
// eine fremde alte Dichte darf bei Rohstoffwechsel nicht übernommen werden.
if (($data['ordered_unit'] ?? null) === 'ml'
&& (int) ($data['ingredient_id'] ?? 0) === (int) $stockEntry->ingredient_id
&& (float) $stockEntry->density_used > 0) {
$data['density_used'] = (float) $stockEntry->density_used;
}
$data = $this->applyPurchaseUnit($data);
}