diff --git a/web/src/pages/CheckIn.jsx b/web/src/pages/CheckIn.jsx index 633e048..4e88dcb 100644 --- a/web/src/pages/CheckIn.jsx +++ b/web/src/pages/CheckIn.jsx @@ -44,7 +44,8 @@ export default function CheckIn() { setResults([]); resetLookup(); const opts = buildUnitOptions(p, units); - setUnit(p.unit_name || (opts[0] && opts[0].value) || ""); + // Gibt es ein Gebinde (Glas, Packung, …), ist das die naheliegende Eingabe. + setUnit(p.package_size ? "package" : (p.unit_name || (opts[0] && opts[0].value) || "")); setLines([emptyLine()]); setLocationId(""); } diff --git a/web/src/pages/CheckOut.jsx b/web/src/pages/CheckOut.jsx index 4799ae0..13f2b26 100644 --- a/web/src/pages/CheckOut.jsx +++ b/web/src/pages/CheckOut.jsx @@ -29,7 +29,8 @@ export default function CheckOut() { setLotId(""); setQuantity(""); const opts = buildUnitOptions(p, units); - setUnit(p.unit_name || (opts[0] && opts[0].value) || ""); + // Gibt es ein Gebinde (Glas, Packung, …), ist das die naheliegende Eingabe. + setUnit(p.package_size ? "package" : (p.unit_name || (opts[0] && opts[0].value) || "")); try { setLots(await api.listLots(p.id)); } catch { setLots([]); } @@ -88,6 +89,14 @@ export default function CheckOut() { const unitOpts = product ? buildUnitOptions(product, units) : []; const selectedLot = lots.find((l) => String(l.id) === String(lotId)) || null; const baseShort = product ? unitShort(product.base_unit) : ""; + const pkgSize = product?.package_size || 0; + const pkgLabel = product?.package_label || "Packung"; + + // Chargenmenge in der Artikeleinheit (Gebinde), sonst in der Produkteinheit. + function lotAmount(q) { + if (pkgSize > 0) return `${fmt(q / pkgSize)} ${pkgLabel}`; + return `${fmt(q / (product?.unit_factor || 1))} ${product?.unit_name || baseShort}`; + } return (
@@ -150,7 +159,7 @@ export default function CheckOut() { {lots.map((l) => ( ))} @@ -160,7 +169,7 @@ export default function CheckOut() { {selectedLot && (
- Gewählte Charge: {fmt(selectedLot.quantity)} {baseShort} + Gewählte Charge: {lotAmount(selectedLot.quantity)} {selectedLot.best_before ? ` · MHD ${selectedLot.best_before}` : " · ohne MHD"} {isExpired(selectedLot.best_before) ? " (abgelaufen)" : ""}
diff --git a/web/src/units.js b/web/src/units.js index c80196f..525978a 100644 --- a/web/src/units.js +++ b/web/src/units.js @@ -76,9 +76,10 @@ export function buildUnitOptions(product, units) { .filter((u) => u.kind === product.kind) .map((u) => ({ value: u.name, label: u.name })); if (product.package_size) { + // Bezeichnung des Gebindes je Artikel (Glas, Tüte, …); Wert bleibt "package". opts.push({ value: "package", - label: `Packung (${fmt(product.package_size)} ${unitShort(product.base_unit)})`, + label: `${product.package_label || "Packung"} (${fmt(product.package_size)} ${unitShort(product.base_unit)})`, }); } return opts;