Fix: Kots with product quantity = 0 were allowed. So blank kots could be added.

This commit is contained in:
2021-07-04 08:32:55 +05:30
parent 38ccaa167c
commit 8c5d941850
2 changed files with 6 additions and 2 deletions

View File

@ -103,7 +103,11 @@ def update_route(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Happy hour products are not balanced.",
)
for k in (k for k in data.kots if k.id_ is None and len(k.inventories) > 0):
for k in (
k
for k in data.kots
if k.id_ is None and len([i for i in k.inventories if round(i.quantity, 2) != 0]) > 0
):
need_to_print_kot = True
code = db.execute(select(func.coalesce(func.max(Kot.code), 0) + 1)).scalar_one()
kot = Kot(item.id, code, item.food_table_id, now, item.user_id)