Files
Vorrania/web/src/locationPath.js
Scarriffle c8c1686395 Amazon-Kaufdatum erkennen; Preis-Vorschlaege beim Anlegen; Lagerort-Dropdowns mit Pfad
1) Beleganalyse erkennt Datumsangaben mit Monatsnamen (DE+EN, z.B. Amazon 'Bestelldatum 29 April 2026'), nicht nur 29.04.2026 - so wird das Kaufdatum solcher Rechnungen gefunden. 2) Beim direkten Anlegen eines Einzelstuecks mit Beleg werden jetzt alle erkannten Preise als Vorschlag angeboten (Dropdown), statt stillschweigend nur den wahrscheinlichsten zu nehmen. 3) Alle Lagerort-Dropdowns zeigen den vollen Pfad (Hedingen -> Keller -> Schublade 1) statt nur den Namen, damit gleichnamige Orte unterscheidbar sind.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 13:24:08 +02:00

37 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Lagerorte sind verschachtelbar (Hedingen → Keller → Schublade 1). Gleichnamige
// Orte ("Schublade 1" an mehreren Stellen) sind nur am Pfad unterscheidbar
// deshalb zeigen die Auswahlfelder den ganzen Pfad statt nur den Namen.
/** Pfad eines Lagerorts als "Hedingen → Keller → Schublade 1". */
export function locationPath(loc, all) {
if (!loc) return "";
const byId = new Map(all.map((l) => [l.id, l]));
const teile = [loc.name];
const gesehen = new Set([loc.id]);
let pid = loc.parent_id;
while (pid != null && byId.has(pid) && !gesehen.has(pid)) {
const p = byId.get(pid);
teile.unshift(p.name);
gesehen.add(pid);
pid = p.parent_id;
}
return teile.join(" → ");
}
/** Pfad zu einer Lagerort-ID (oder "" wenn unbekannt/leer). */
export function locationPathById(id, all) {
if (id == null || id === "") return "";
const loc = all.find((l) => l.id === id);
return loc ? locationPath(loc, all) : "";
}
/**
* Optionen fürs <select>: {id, label} mit vollem Pfad, nach Pfad sortiert
* so stehen Geschwister und Unterorte beieinander.
*/
export function locationOptions(all) {
return (all || [])
.map((l) => ({ id: l.id, label: locationPath(l, all) }))
.sort((a, b) => a.label.localeCompare(b.label, "de"));
}