Web: Mindestbestand je Lagerort im Formular in echter Einheit
Der je-Lagerort-Editor (foodLike) zeigt und speichert jetzt in der Anzeigeeinheit (Gramm/Milliliter/Stueck) statt in Packungen - konsistent zur Mindestbestaende- Seite. Umrechnung Artikeleinheit<->Anzeigeeinheit an der Formular-Grenze. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,13 @@ const CANONICAL_NAME = { piece: "Stück", gram: "Gramm", milliliter: "Milliliter
|
||||
const KIND_LABEL = { count: "Anzahl", weight: "Gewicht", volume: "Volumen" };
|
||||
const KIND_ORDER = ["count", "weight", "volume"];
|
||||
|
||||
// Faktor Artikeleinheit → Anzeigeeinheit: die je-Lagerort-Mindestbestände sind in
|
||||
// Artikeleinheiten (Packungen) gespeichert, angezeigt wird aber die echte Einheit
|
||||
// (Gramm/Milliliter/Stück), damit „Packung" nicht nichtssagend dasteht.
|
||||
const artToDisp = (p) => (
|
||||
(p.package_size > 0 ? p.package_size : (p.unit_factor || 1)) / (p.unit_factor || 1)
|
||||
);
|
||||
|
||||
// Foto vor dem Hochladen verkleinern: kleiner in der DB, schneller im Upload und
|
||||
// zuverlässig unter dem Server-Limit. Bei Problemen fällt es aufs Original zurück.
|
||||
function verkleinereBild(datei, maxDim = 1600, quality = 0.85) {
|
||||
@@ -812,16 +819,19 @@ export default function ProductForm() {
|
||||
</div>
|
||||
<p className="muted small mt-0">
|
||||
Zusätzlich zum Gesamt-Mindestbestand: eigener Bedarf je Lagerort (z.B.
|
||||
Ferienhaus, Zuhause). Menge in {product.package_label || product.unit_name || "Stück"}.
|
||||
Ferienhaus, Zuhause). Menge in {product.unit_name || "Stück"}.
|
||||
Wird separat gespeichert.
|
||||
</p>
|
||||
<LocationMinStock
|
||||
locations={locations}
|
||||
initial={product.location_min_stocks || []}
|
||||
unitLabel={product.package_label || product.unit_name || "Stück"}
|
||||
initial={(product.location_min_stocks || []).map(
|
||||
(e) => ({ ...e, min_stock: e.min_stock * artToDisp(product) }))}
|
||||
unitLabel={product.unit_name || "Stück"}
|
||||
onError={(m) => toast(m, "warn")}
|
||||
onSave={async (list) => {
|
||||
const updated = await api.setProductLocationMinStock(product.id, list);
|
||||
const f = artToDisp(product);
|
||||
const artList = list.map((e) => ({ ...e, min_stock: e.min_stock / f }));
|
||||
const updated = await api.setProductLocationMinStock(product.id, artList);
|
||||
setProduct(updated);
|
||||
toast("Bedarfe je Lagerort gespeichert.");
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user