Mindestbestaende: Bestand je Lagerort anzeigen (nicht nur Gesamt)

Per-Lagerort-Zeilen (Produkt und Gruppe) zeigten '-' beim Bestand, weil die Seite
nur den Gesamtbestand kannte. Jetzt liefert LocationMinStockOut.stock den Bestand
AN DEM Ort (inkl. Unterorte) mit - bei Produkten in Basiseinheiten, bei Gruppen in
der Gruppen-Einheit (analog zu ProductOut.stock/GroupOut.stock). Berechnet ueber
location_subtree_stock_base; die Weboberflaeche zeigt ihn wie beim Gesamt-Bestand.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-30 13:57:40 +02:00
parent 4ed33e221f
commit f3bab15362
4 changed files with 22 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ from sqlalchemy.orm import Session
from .models import Barcode, Category, CategoryTracking, Item, Lot, Product, ProductImage
from .schemas import BarcodeOut, LocationMinStockOut, ProductOut
from .services.conversion import KIND_OF_BASE, display_unit_info
from .services.stock import current_stock
from .services.stock import current_stock, location_subtree_stock_base
def product_tracking(db: Session, product: Product) -> str:
@@ -85,6 +85,7 @@ def product_to_out(db: Session, product: Product) -> ProductOut:
location_id=e.location_id,
location_name=e.location.name if e.location else None,
min_stock=e.min_stock,
stock=location_subtree_stock_base(db, product, e.location_id),
)
for e in sorted(product.location_min_stocks, key=lambda x: x.id)
]
@@ -165,6 +166,7 @@ def products_to_out_bulk(db: Session, products: list[Product]) -> list[ProductOu
location_id=e.location_id,
location_name=e.location.name if e.location else None,
min_stock=e.min_stock,
stock=location_subtree_stock_base(db, product, e.location_id),
)
for e in sorted(product.location_min_stocks, key=lambda x: x.id)
]