import mysql.connector as msc
mycon=msc.connect(host='localhost',user='root',passwd='edward',database='la_mea_khow')
cur=mycon.cursor()
def eat5(amt):
if amt>499:
return int(amt*0.95)
def food10(amt):
if amt>1299:
return int(amt*0.90)
def foodie(amt):
if amt>1799:
return int(amt*0.85)
while True:
print("""
┌────────────────────────────────────────────────────────────────────────────┐
│ LA MEA KHOW │
│ │
│ TABLE ARRANGEMENT │
│ │
│ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │
│ │ │ │ │ │ │ │ │ │ │ │
│ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ │
│ ┌──┐ ┌────────────┐ ┌──┐ ┌──┐ ┌────────────┐ ┌──┐ │
│ │ │ │ [1] │ │ │ │ │ │ [2] │ │ │ │
│ └┼┼┘ └────────────┘ └┼┼┘ └┼┼┘ └────────────┘ └┼┼┘ │
│ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │
│ │ │ │ │ │ │ │ │ │ │ │
│ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ │
│ │
│ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │
│ │ │ │ │ │ │ │ │ │ │ │
│ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ │
│ ┌──┐ ┌────────────┐ ┌──┐ ┌──┐ ┌────────────┐ ┌──┐ │
│ │ │ │ [3] │ │ │ │ │ │ [4] │ │ │ │
│ └┼┼┘ └────────────┘ └┼┼┘ └┼┼┘ └────────────┘ └┼┼┘ │
│ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │
│ │ │ │ │ │ │ │ │ │ │ │
│ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ └┼┼┘ │
│ │
│ ┌────────────┐ │
│ │ [5]. EXIT │ │
│ └────────────┘ │
└────────────────────────────────────────────────────────────────────────────┘""")
tb=int(input("Enter the table no. = "))
if tb==5:
break
elif tb in [1,2,3,4]:
tbn=tb
else:
print("Invalid Operation number entered")
while True:
print("""
┌────────────────────────────────────────┐
│ Welcome │
│ To │
│ LA MEA KHOW │
│ │
│ [1]. MENU │
│ [2]. ORDER │
│ [3]. PAY BILL │
│ [4]. BACK │
└────────────────────────────────────────┘""")
o=int(input("Enter the operation number = "))
if o==4:
break
elif o==1:
cur.execute("select * from menu;")
me=cur.fetchall()
s=0
print("\t\tVEG")
for i in me:
if i[1]=='veg':
s+=1
print(s,end=' ')
print(i[2].title(),':',i[3])
print("MRP :",i[4])
print()
s=0
print("\t\tNON-VEG")
for i in me:
if i[1]=='non-veg':
s+=1
print(s,end=' ')
print(i[2].title(),':',i[3])
print("MRP :",i[4])
print()
elif o==2:
while True:
print("""
┌────────────────────────────────────────┐
│ LA MEA KHOW │
│ │
│ [1]. VEG │
│ [2]. NON-VEG │
│ [3]. BACK │
└────────────────────────────────────────┘""")
op=int(input("Enter the operation number = "))
if op==3:
break
elif op==1:
sno=eval(input("Enter the list of sno. of food = "))
cur.execute("select sno from menu where type='veg';")
vg=cur.fetchall()
for i in sno:
cur.execute('insert into t_%s values(%s)',(tbn,vg[i-1][0]))
mycon.commit()
elif op==2:
sno=eval(input("Enter the list of sno. of food = "))
cur.execute("select sno from menu where type='non-veg';")
nvg=cur.fetchall()
for i in sno:
cur.execute('insert into t_%s values(%s)',(tbn,nvg[i-1][0]))
mycon.commit()
else:
print("Invalid operation number entered")
elif o==3:
cur.execute('select * from t_%s;',(tbn,))
odr=cur.fetchall()
cur.execute('select sno,food_name,cost from menu;')
det=cur.fetchall()
sn=[]
qty=[]
for i in det:
sn.append(i[0])
for i in range(0,len(odr)):
qty.append(sn.count(i))
amt=0
print("""
┌──────────────────────────────────────────────┐
│ LA MEA KHOW │
│ │
│ FOOD ITEM QTY AMOUNT │""")
for i in range(0,len(odr)):
if qty[i]>0:
amt+=det[i][2]*qty[i]
print("│ ",det[i][1]," "*(30-6-len(det[i][1])),qty[i]," "*(5-len(str(qty[i]))),det[i][2]*qty[i],' '*(15-len(str(det[i][2]*qty))),"│")
print("""│ ------ │""")
print("│ CGST(9%) ",int(amt*0.09),' '*(7-len(str(int(amt*0.09)))),"│")
print("│ SGST(9.5%) ",int(amt*0.095),' '*(7-len(str(int(amt*0.095)))),"│")
print("│ Service Charge(10%) ",int(amt*0.10),' '*(7-len(str(int(amt*0.10)))),"│")
print("│ Miscellaneous(2.5%) ",int(amt*0.025),' '*(7-len(str(int(amt*0.025)))),"│")
eat5(amt)
food10(amt)
foodie(amt)
amt=amt+amt*(0.09+0.095+0.10+0.025)
amt=int(amt)
print("│ TOTAL ",amt,' '*(6-len(str(amt))),"│")
print("└─────────────────────────────────────────────┘")
cur.execute('drop table t_%s;',(tbn,))
cur.execute("create table t_%s(item_no int);",(tbn,))
mycon.commit()
else:
print("Invalid operation Entered")
mycon.close()