Stock API
Bestand auflisten
GET /stock
| Parameter | Typ | Beschreibung |
|---|---|---|
product_id | UUID | Nach Produkt filtern |
location_id | UUID | Nach Lagerort filtern |
expiring_days | int | Items die innerhalb von N Tagen ablaufen |
Bestand hinzufügen
POST /stock
{
"product_id": "550e8400-...",
"location_id": "660e8400-...",
"amount": 3,
"price": 1.49,
"best_before_date": "2026-04-15",
"note": "Angebot bei Edeka"
}
| Feld | Pflicht | Validierung |
|---|---|---|
product_id | ✅ | Existierende UUID |
location_id | ✅ | Existierende UUID |
amount | ✅ | > 0, ≤ 1.000.000 |
price | ❌ | ≥ 0, ≤ 1.000.000 |
best_before_date | ❌ | ISO 8601 Datum |
purchased_date | ❌ | ISO 8601 Datum |
note | ❌ | Max. 2000 Zeichen |
Bestand verbrauchen
POST /stock/consume
{
"stock_entry_id": "770e8400-...",
"amount": 1,
"spoiled": false,
"note": "Zum Kochen verwendet"
}
Wenn amount ≥ aktuellem Bestand: Eintrag wird komplett gelöscht (Response null).
Bestand umlagern
POST /stock/transfer
{
"stock_entry_id": "770e8400-...",
"target_location_id": "880e8400-...",
"amount": 2
}
Wenn amount nicht angegeben: gesamter Eintrag wird verschoben.
Bald ablaufend
GET /stock/expiring?days=7
Gibt alle Einträge zurück die innerhalb von N Tagen ablaufen.
Preisdurchschnitt
GET /stock/avg-price/{product_id}
{
"product_id": "550e8400-...",
"avg_price": 1.89
}
Gewichteter Durchschnitt (nach Menge). Einträge ohne Preis werden ignoriert.
Verlauf / Audit Log
GET /stock/log
| Parameter | Typ | Beschreibung |
|---|---|---|
product_id | UUID | Nach Produkt filtern |
limit | int | Max. Einträge (default: 50, max: 500) |
Aktionen: add, consume, spoiled, transfer.