Web: Mindestbestand je Lagerort laesst sich anlegen (mergeLoc ergaenzt neue Orte)

Der Endpunkt ersetzt die komplette Lagerort-Liste; mergeLoc iterierte aber nur
ueber bestehende Eintraege und liess neue Orte weg. Dadurch entstand nie ein
neuer je-Lagerort-Mindestbestand, wenn nur ein Gesamt-Wert (leere Ortsliste)
oder ein Eintrag an einem anderen Ort existierte. Jetzt wird ein fehlender Ort
ergaenzt und der Abgleich per String() unabhaengig vom id-Typ gemacht.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-29 17:04:14 +02:00
parent f29bbced8d
commit bfc52997dc

View File

@@ -93,10 +93,16 @@ export default function MinStock() {
return out; return out;
}, [products, groups, locations]); }, [products, groups, locations]);
// Eine Lagerort-Bedarfsliste mit einem geänderten/entfernten Eintrag neu bauen. // Eine Lagerort-Bedarfsliste mit einem geänderten/neuen/entfernten Eintrag neu
const mergeLoc = (list, locId, num) => (list || []) // bauen. Der Endpunkt ersetzt die komplette Liste neue Lagerorte müssen also
.map((e) => ({ location_id: e.location_id, min_stock: e.location_id === locId ? num : e.min_stock })) // ergänzt (nicht nur bestehende geändert) werden, sonst wird nie einer angelegt.
.filter((e) => e.min_stock != null && e.min_stock > 0); const mergeLoc = (list, locId, num) => {
const out = (list || []).map((e) => ({ location_id: e.location_id, min_stock: e.min_stock }));
const hit = out.find((e) => String(e.location_id) === String(locId));
if (hit) hit.min_stock = num;
else out.push({ location_id: locId, min_stock: num });
return out.filter((e) => e.min_stock != null && e.min_stock > 0);
};
async function saveSoll(row, value) { async function saveSoll(row, value) {
const roh = String(value).trim().replace(",", "."); const roh = String(value).trim().replace(",", ".");