diff --git a/barker/barker/routers/voucher/save.py b/barker/barker/routers/voucher/save.py index bb864f7..88de77b 100644 --- a/barker/barker/routers/voucher/save.py +++ b/barker/barker/routers/voucher/save.py @@ -92,9 +92,12 @@ def do_save( user.id_, ) db.add(item) + for dk in data.kots: + # Filter out nil inventories + dk.inventories = [dki for dki in dk.inventories if round(dki.quantity, 2) != 0] + # Filter out nil kots + data.kots = [k for k in data.kots if len(k.inventories) > 0] for k in data.kots: - if not len(k.inventories): - continue if not happy_hour_items_balanced(k.inventories): raise HTTPException( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,