Lagerorte: Baum-Picker beim Anlegen; Unter-Ort-Bestand zählt zum Bedarf
- Web: der übergeordnete Lagerort wird beim Anlegen jetzt über den aufklappbaren Baum (CategorySelect) gewählt statt über das flache Dropdown. - Backend: Mindestbestand je Lagerort wird jetzt gegen den Bestand INKL. aller Unter-Lagerorte geprueft. Ein Bedarf auf „Hedingen" gilt also als gedeckt, wenn der Vorrat in „Hedingen -> Keller" liegt. Helfer location_subtree_stock_base; 2 neue Tests, Suite 157 gruen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -60,3 +60,39 @@ def test_gedeckter_ort_erscheint_nicht(db, user):
|
||||
|
||||
# Bestand (5) >= Mindestbestand (3) -> kein Bedarf, kein Eintrag.
|
||||
assert shopping_list_by_location(db=db, _=user) == []
|
||||
|
||||
|
||||
def test_bestand_in_unterlagerort_zaehlt_zum_oberort(db, user):
|
||||
p = Product(name="Konserve", base_unit=BaseUnit.gram, package_size=1)
|
||||
db.add(p)
|
||||
db.flush()
|
||||
haus = Location(name="Hedingen")
|
||||
db.add(haus)
|
||||
db.flush()
|
||||
keller = Location(name="Keller", parent_id=haus.id)
|
||||
db.add(keller)
|
||||
db.flush()
|
||||
# Vorrat liegt im Unter-Lagerort; Mindestbestand ist auf dem Ober-Lagerort.
|
||||
db.add(Lot(product_id=p.id, quantity=5, location_id=keller.id))
|
||||
db.add(ProductLocationMinStock(product_id=p.id, location_id=haus.id, min_stock=3))
|
||||
db.commit()
|
||||
# 5 (im Keller) deckt die 3 auf Hedingen -> kein Bedarf.
|
||||
assert shopping_list_by_location(db=db, _=user) == []
|
||||
|
||||
|
||||
def test_unterlagerort_reicht_nicht_zeigt_restbedarf(db, user):
|
||||
p = Product(name="Konserve", base_unit=BaseUnit.gram, package_size=1)
|
||||
db.add(p)
|
||||
db.flush()
|
||||
haus = Location(name="Hedingen")
|
||||
db.add(haus)
|
||||
db.flush()
|
||||
keller = Location(name="Keller", parent_id=haus.id)
|
||||
db.add(keller)
|
||||
db.flush()
|
||||
db.add(Lot(product_id=p.id, quantity=2, location_id=keller.id))
|
||||
db.add(ProductLocationMinStock(product_id=p.id, location_id=haus.id, min_stock=5))
|
||||
db.commit()
|
||||
needs = shopping_list_by_location(db=db, _=user)
|
||||
assert needs[0].location_name == "Hedingen"
|
||||
assert needs[0].products[0].deficit == 3 # 5 - 2
|
||||
|
||||
Reference in New Issue
Block a user