Warenwirtschaft: R-02 — leerer historischer Verpackungs-Snapshot gilt in der Vorschau

Ob der Snapshot gilt, entscheidet der Buchungsstatus (nicht die Zeilenzahl);
ohne Verpackung gebuchte Produktionen zeigen „Kein Verpackungsverbrauch gebucht“.
Tests R-01/R-02.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-09-09 07:28:06 +00:00
parent fda37d5599
commit bdaac3b8fb
4 changed files with 110 additions and 3 deletions

View file

@ -199,7 +199,7 @@
<div class="col-sm-1"></div>
</div>
<div id="production-outputs" data-initial='@json($initialOutputs)' data-packaging-bom='@json(($packagingBom ?? []) === [] ? (object) [] : $packagingBom)'
data-packaging-snapshot='@json($packagingSnapshot ?? [])' data-initial-output-totals='@json(($initialOutputTotals ?? []) === [] ? (object) [] : $initialOutputTotals)'></div>
data-packaging-snapshot='@json($packagingSnapshot ?? [])' data-packaging-snapshot-applies='{{ ! empty($packagingSnapshotApplies) ? 1 : 0 }}' data-initial-output-totals='@json(($initialOutputTotals ?? []) === [] ? (object) [] : $initialOutputTotals)'></div>
<button type="button" class="btn btn-sm btn-outline-secondary mb-3" id="btn-add-output">{{ __('+ weitere Ergebniszeile') }}</button>
<script type="text/template" id="output-row-template">

View file

@ -368,6 +368,9 @@
var packagingBom = $('#production-outputs').data('packaging-bom') || {};
// N-04: gespeicherter Snapshot einer gebuchten Produktion + Ergebnissummen beim Öffnen.
var packagingSnapshot = $('#production-outputs').data('packaging-snapshot') || [];
// R-02: Ob ein historischer Snapshot gilt, entscheidet der Buchungsstatus — nicht die Zeilenzahl
// (eine ohne Verpackung gebuchte Produktion hat einen gültigen leeren Snapshot).
var packagingSnapshotApplies = String($('#production-outputs').data('packaging-snapshot-applies')) === '1';
var initialOutputTotals = $('#production-outputs').data('initial-output-totals') || {};
function currentOutputTotals() {
@ -394,17 +397,20 @@
function renderPackagingPreview() {
var $hint = $('#recipe-packaging-hint');
if (packagingSnapshot.length > 0 && sameTotals(currentOutputTotals(), initialOutputTotals)) {
if (packagingSnapshotApplies && sameTotals(currentOutputTotals(), initialOutputTotals)) {
var $snap = $('#recipe-packaging-preview').empty();
packagingSnapshot.forEach(function (pk) {
$snap.append($('<tr></tr>')
.append($('<td></td>').text(pk.name))
.append($('<td></td>').text(pk.pieces)));
});
if (!packagingSnapshot.length) {
$snap.append('<tr><td colspan="2" class="text-muted">{{ __('Kein Verpackungsverbrauch gebucht.') }}</td></tr>');
}
$hint.text('{{ __('Gespeicherter Verpackungsverbrauch dieser Produktion — bleibt erhalten, solange Ergebnisprodukte und Stückzahlen unverändert sind.') }}');
return;
}
$hint.text(packagingSnapshot.length > 0
$hint.text(packagingSnapshotApplies
? '{{ __('Ergebnis geändert — Verpackungsverbrauch wird beim Speichern mit der aktuellen Stückliste neu berechnet.') }}'
: '');