Ein-/Auslagern nutzt die Artikeleinheit (Gebinde) statt fest "Packung"
- buildUnitOptions verwendet product.package_label als Beschriftung der Gebinde-Option (Wert bleibt intern "package"). - Beim Auswaehlen eines Artikels ist das Gebinde vorbelegt, wenn eine Packungsgroesse hinterlegt ist. - Auslagern: Chargen-Dropdown und Hinweis zeigen die Menge in der Artikeleinheit (z.B. "MHD 2026-12-23 - 1 Glas") statt in der Basiseinheit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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("");
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<div>
|
||||
@@ -150,7 +159,7 @@ export default function CheckOut() {
|
||||
<option value="">Automatisch – zuerst ablaufende zuerst (FEFO)</option>
|
||||
{lots.map((l) => (
|
||||
<option key={l.id} value={l.id}>
|
||||
{l.best_before ? `MHD ${l.best_before}` : "ohne MHD"} · {fmt(l.quantity)} {baseShort}
|
||||
{l.best_before ? `MHD ${l.best_before}` : "ohne MHD"} · {lotAmount(l.quantity)}
|
||||
{isExpired(l.best_before) ? " · abgelaufen" : ""}
|
||||
</option>
|
||||
))}
|
||||
@@ -160,7 +169,7 @@ export default function CheckOut() {
|
||||
{selectedLot && (
|
||||
<div className={`alert ${isExpired(selectedLot.best_before) ? "error" : "info"}`}>
|
||||
<Icon name="alert" size={16} />
|
||||
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)" : ""}
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user