Chore: Refactor nil inventories and kots checking
This commit is contained in:
parent
88bda14002
commit
1b4c26733d
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user