Backend: kombinierter Einkaufslisten-Endpunkt /shopping-list/all
Liefert Produkte, Gruppen und Bedarfe je Lagerort in einem Aufruf - dieselben drei Quellen, die die Oberflaeche ohnehin zusammenfuehrt. Erspart API-Nutzern drei getrennte Requests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ from ..schemas import (
|
||||
LocationNeeds,
|
||||
MovementOut,
|
||||
ShoppingItem,
|
||||
ShoppingListAll,
|
||||
)
|
||||
from ..services.conversion import BASE_OF_KIND, article_unit, display_unit_info
|
||||
from ..services.stock import (
|
||||
@@ -166,6 +167,20 @@ def shopping_list_by_location(
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/shopping-list/all", response_model=ShoppingListAll)
|
||||
def shopping_list_all(
|
||||
db: Session = Depends(get_db), user: User = Depends(get_current_user)
|
||||
) -> ShoppingListAll:
|
||||
"""Komplette Einkaufsliste in einem Aufruf: Produkte, Gruppen und Bedarfe je
|
||||
Lagerort – genau die drei Quellen, die auch die Oberfläche zusammenführt.
|
||||
Erspart drei getrennte Abfragen."""
|
||||
return ShoppingListAll(
|
||||
products=shopping_list(db, user),
|
||||
groups=group_shopping_list(db, user),
|
||||
by_location=shopping_list_by_location(db, user),
|
||||
)
|
||||
|
||||
|
||||
@router.get("/location/{code}", response_model=LocationContents)
|
||||
def location_contents(
|
||||
code: str,
|
||||
|
||||
@@ -693,6 +693,14 @@ class LocationNeeds(BaseModel):
|
||||
groups: list[LocationNeedGroup] = []
|
||||
|
||||
|
||||
class ShoppingListAll(BaseModel):
|
||||
"""Komplette Einkaufsliste in einem Aufruf – dieselben drei Quellen, die auch
|
||||
die Oberfläche zusammenführt."""
|
||||
products: list[ShoppingItem] = []
|
||||
groups: list[GroupShoppingItem] = []
|
||||
by_location: list[LocationNeeds] = []
|
||||
|
||||
|
||||
class LocationContentEntry(BaseModel):
|
||||
"""Ein Artikel mit seinem Bestand an einem Lagerort (in Artikeleinheiten)."""
|
||||
product_id: int
|
||||
|
||||
Reference in New Issue
Block a user