Ablauf-Warnungen + Packungen-Spalte + Farbcodierung
- Backend: ProductOut.expired_count (Anzahl abgelaufener Chargen je Produkt). - Einlagern: Inline-Warnung pro Charge, wenn MHD in der Vergangenheit liegt. - Produkte-Liste: Badge "N abgelaufen"; neue Spalte "Packungen" (Bestand/Packungsgroesse, bei Stueck-Produkten = Bestand). - Produktdetail: abgelaufene Chargen rot, Warnfrist gelb (Warnfrist aus Settings), Warnbanner bei abgelaufenem Bestand. - Uebersicht: alle Ablaufzeilen gelb, abgelaufene rot; deutlicher Warnbanner. - units.js: daysUntil/isExpired/expiryRowClass/amountText. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,31 @@ export function fmt(n) {
|
||||
return Number(n).toLocaleString("de-DE", { maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
// Tage bis zum MHD (negativ = überfällig, null = kein MHD).
|
||||
export function daysUntil(dateStr) {
|
||||
if (!dateStr) return null;
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const d = new Date(dateStr);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return Math.round((d - today) / 86400000);
|
||||
}
|
||||
|
||||
// Ist ein MHD (YYYY-MM-DD) bereits abgelaufen (vor heute)?
|
||||
export function isExpired(dateStr) {
|
||||
const d = daysUntil(dateStr);
|
||||
return d != null && d < 0;
|
||||
}
|
||||
|
||||
// CSS-Zeilenklasse je MHD: rot wenn abgelaufen, gelb wenn innerhalb der Warnfrist.
|
||||
export function expiryRowClass(dateStr, warnDays = 7) {
|
||||
const d = daysUntil(dateStr);
|
||||
if (d == null) return "";
|
||||
if (d < 0) return "row-danger";
|
||||
if (d <= warnDays) return "row-warn";
|
||||
return "";
|
||||
}
|
||||
|
||||
// Menge lesbar darstellen: bei Packungsprodukten in Packungen (+ Basiseinheit in Klammern).
|
||||
export function amountText(qty, packageSize, baseUnit) {
|
||||
if (packageSize && packageSize > 0) {
|
||||
|
||||
Reference in New Issue
Block a user