Fix: Removed that when there was nothign in order no commit add woud be done.

This commit is contained in:
Tim Berchtold 2025-07-20 15:56:43 +02:00
parent 35f20e4f63
commit 321923b056
2 changed files with 15 additions and 9 deletions

View file

@ -39,17 +39,21 @@ class compare:
OUT: True, False if succeded adding to db
'''
if compare.verifie_order(ordered_list):
#products = Product()
order = Order(desk)
session.add(order)
session.commit()
order = Order(desk)
if compare.verifie_order(ordered_list):
is_emtpy = True #check if nothing in prouduct if True dont commit.
for product in ordered_list:
if int(product[0]) > 0: #dont add not ordered to list
if is_emtpy: #first time enter in loop
session.add(order)
session.commit()
productDB = Product(quantity=int(product[0]),name=product[1],order_id = order.id)
session.add(productDB)
session.add(productDB)
is_emtpy = False
if is_emtpy:
return False
session.commit()
logger.success("Order at desk "+ str(desk) +" resived")
# add a new ordered_list to the database