Mindestbestand in jeder angelegten Einheit erfassbar (und gemerkt)

- Produktformular: Auswahl aller verwalteten Einheiten passender Art (plus
  Packungen), inkl. Umrechnung beim Wechsel.
- Die gewaehlte Erfassungseinheit wird gespeichert (products.min_stock_unit_id /
  min_stock_in_packages) und exakt so wieder angezeigt - vorher wurde sie aus der
  Produkteinheit abgeleitet.
- ProductOut liefert min_stock_display + min_stock_unit_label; Produkttabelle
  zeigt den Mindestbestand damit in der erfassten Einheit mit Einheit dahinter.
- Migration: ADD COLUMN IF NOT EXISTS fuer die zwei neuen Spalten.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-22 12:54:47 +02:00
parent 44e7c2ef90
commit 0d55d1f8d9
7 changed files with 70 additions and 28 deletions

View File

@@ -30,6 +30,18 @@ def product_to_out(db: Session, product: Product) -> ProductOut:
name, factor = display_unit_info(product)
out.unit_name = name
out.unit_factor = factor
# Mindestbestand in der Einheit anzeigen, in der er erfasst wurde.
if product.min_stock is not None:
if product.min_stock_in_packages and product.package_size:
out.min_stock_display = product.min_stock / product.package_size
out.min_stock_unit_label = "Pkg"
elif product.min_stock_unit is not None:
out.min_stock_display = product.min_stock / product.min_stock_unit.factor
out.min_stock_unit_label = product.min_stock_unit.name
else:
out.min_stock_display = product.min_stock / factor
out.min_stock_unit_label = name
return out