Web: Zweiteinheit erfassen und anzeigen

Im Artikel-Formular eine Zeile "3 [Stk] ≙ 250 [Gramm]" mit ausgerechneter
Kontrolle darunter ("1 Stk ≈ 83,33 g"). Links steht die Basiseinheit des
Artikels fest, rechts stehen nur die anderen Arten zur Wahl - eine Bruecke auf
die eigene Art haette nichts umzurechnen. Nur vollstaendig ausgefuellt wird sie
gespeichert; Gegenstaende ohne Charge tragen keine.

buildUnitOptions laesst bei hinterlegter Bruecke auch die Einheiten der Gegenart
zu - damit erben Ein- und Auslagern die Faehigkeit ohne eigene Logik. Beim
Auslagern steht der Bestand jetzt in beiden Lesarten ("6 Stueck · 500 g").

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-08-16 00:40:33 +02:00
parent 9f3225113e
commit 788ef2caf2
3 changed files with 103 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import Icon from "../components/Icon";
import { ProduktThumb } from "../components/ProduktBild";
import { useToast } from "../toast";
import { useSettings } from "../settings";
import { buildUnitOptions, fmt, gebinde, isExpired, unitShort } from "../units";
import { buildUnitOptions, fmt, gebinde, isExpired, unitShort, zweitText } from "../units";
export default function CheckOut() {
const { formatBestBefore } = useSettings();
@@ -149,6 +149,10 @@ export default function CheckOut() {
<div className="title">{product.name}</div>
<div className="muted small">
Verfügbar: {fmt(product.stock / (product.unit_factor || 1))} {product.unit_name}
{/* Zweite Lesart, wenn eine Zweiteinheit hinterlegt ist. */}
{zweitText(product.stock || 0, product) && (
<> · {zweitText(product.stock || 0, product)}</>
)}
</div>
</div>
<button type="button" className="btn ghost" onClick={() => setProduct(null)}>Ändern</button>