Chargen: festgelegte Produkteinheit ist massgeblich (nicht die Packung)
Korrektur zum vorigen Commit: Anzeige und Bearbeitung der Chargen richten sich nach der im Produkt eingestellten Einheit. Als Untermenge stehen darunter die Basiseinheit (falls abweichend) und die Packungen (falls Packungsgroesse gesetzt). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -205,10 +205,8 @@ export default function ProductForm() {
|
||||
<h1>{isNew ? "Neues Produkt" : form.name || "Produkt"}</h1>
|
||||
{!isNew && product && (
|
||||
<div className="sub">
|
||||
Bestand:{" "}
|
||||
{product.package_size
|
||||
? `${fmt(product.stock / product.package_size)} Pkg · ${fmt(product.stock / (product.unit_factor || 1))} ${product.unit_name}`
|
||||
: `${fmt(product.stock / (product.unit_factor || 1))} ${product.unit_name}`}
|
||||
Bestand: {fmt(product.stock / (product.unit_factor || 1))} {product.unit_name}
|
||||
{product.package_size ? ` · ${fmt(product.stock / product.package_size)} Pkg` : ""}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -317,14 +315,16 @@ function LotsCard({ product, lots, baseShort, warnDays, isAdmin, imageUrl, onCha
|
||||
const unitName = product?.unit_name || baseShort;
|
||||
const pkgSize = product?.package_size || 0;
|
||||
|
||||
// Maßgebliche Einheit: Packung, sobald eine Packungsgröße hinterlegt ist –
|
||||
// sonst die Produkteinheit. Die Basiseinheit ist nur die Untermenge.
|
||||
const primaryFactor = pkgSize > 0 ? pkgSize : unitFactor;
|
||||
const primaryLabel = pkgSize > 0 ? "Pkg" : unitName;
|
||||
// Maßgeblich ist die im Produkt festgelegte Einheit.
|
||||
const primaryFactor = unitFactor;
|
||||
const primaryLabel = unitName;
|
||||
|
||||
// Untermenge: Menge in der Basiseinheit (nur wenn sie sich unterscheidet).
|
||||
// Untermengen: Basiseinheit (falls abweichend) und Packungen (falls hinterlegt).
|
||||
function secondary(qty) {
|
||||
return primaryFactor !== 1 ? `${fmt(qty)} ${baseShort}` : "";
|
||||
const parts = [];
|
||||
if (unitFactor !== 1) parts.push(`${fmt(qty)} ${baseShort}`);
|
||||
if (pkgSize > 0) parts.push(`${fmt(qty / pkgSize)} Pkg`);
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
function startEdit(l) {
|
||||
@@ -432,7 +432,7 @@ function LotsCard({ product, lots, baseShort, warnDays, isAdmin, imageUrl, onCha
|
||||
</table>
|
||||
</div>
|
||||
<p className="muted small">
|
||||
Mengen in {pkgSize > 0 ? "Packungen" : unitName}
|
||||
Mengen in {unitName}
|
||||
{pkgSize > 0 ? ` (1 Packung = ${fmt(pkgSize)} ${baseShort})` : ""}.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user