-
Notifications
You must be signed in to change notification settings - Fork 0
/
MedicalShop.py
325 lines (316 loc) · 14.1 KB
/
MedicalShop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import csv
import pandas as pd
def verify(usrid,pwrd): #creating function verify for checking correct userid and password.
a=False
if ((usrid=="panacea123") and (pwrd=="pan@119")):
a=True
return (a)
'''
class cust:
name="" #creating a class named cust to store customer details.
Cnum=""
Cmail=""
'''
#----------------------------------------------------------------------------
print("-"*27,"WELCOME TO PANACEA","-"*27)
ver = False
while (not ver):
uid=input("Enter user id: ") #Taking inputs for user id and password.
pwd=input("Enter password: ")
ver=verify(uid,pwd) # calling of function.
if ver==False:
print("Invalid User name or password") #message printed if either of password or user id is worng.
#while (ver):
class bst: # using the concept of binary search tree to sort the data
def __init__(self,val):
self.val=val
self.lc=None
self.rc=None
def addc(self,val):
if val==self.val:
return
elif val<self.val:
if self.lc!=None:
self.lc.addc(val)
else:
self.lc=bst(val)
else:
if self.rc!=None:
self.rc.addc(val)
else:
self.rc=bst(val)
def order(self): # orders the given data
l=[]
if self.lc!=None:
l+=self.lc.order()
l.append(self.val)
if self.rc!=None:
l+=self.rc.order()
return l
def search(self,x): # searches the required data from the set of data
if self.val==x:
return True
elif x<self.val:
if self.lc!=None:
return self.lc.search(x)
else:
print("Medicine Not Found")
else:
if self.rc!=None:
return self.rc.search(x)
else:
print("Medicine Not Found")
def tree(l):
root=bst(l[0])
for i in range(1,len(l)):
root.addc(l[i])
return root
csvdf=pd.DataFrame()
df1=pd.DataFrame()
t=0
def first_input():
print("\n\nPANACEA Medical Application\n\n")
print("ENTER 1 - FOR NEW ORDER")
print("ENTER 2 - FOR MODIFYING ITEM QUANTITY IN INVENTORY") # creating a function first_input to print menu.
print("ENTER 3 - TO ENTER NEW DATA IN INVENTORY")
print("ENTER 4 - TO DISPLAY ALL MEDICINES FROM THE INVENTORY")
print("ENTER 5 - TO DELETE A DATA FROM INVENTORY")
print("ENTER 6 - FOR EXIT")
c=int(input("Enter choice : ")) #Taking input of choice for the menu displayed.
print("\n\n")
if(c==1): #if entered choice is 1.
global df1 #creating a global dataframe df1.
Cname=input("Enter name:")
Cnum=int(input("Enter phone number:")) #Taking inputs for customer's name,phone number and email.
Cmail=input("Enter mailid:")
df3=pd.DataFrame([[Cname,Cmail,Cnum,None,None,None,None,None]]) #creating dataframe df3
df1=pd.concat([df1,df3],ignore_index=True) #concatinating dataframe df1 and df3.
#SONIA------------------------------------------------------------------
def med():
global csvdf
csvdf=pd.read_csv("C:\Sonia\Cummins Assignments\loop.csv") # import data from csv
medicines=csvdf["0"].tolist()
val=csvdf.values
medicine2=val.tolist()
mt=tree(medicines)
ordered_list=mt.order() # order the data using bst
mt2=tree(medicine2)
ordered_list2=mt2.order()
y=input("Medicine Name : ")
y=y.lower()
z=mt.search(y) # search the data using bst
if z==True:
ind=ordered_list.index(y)
ordernum=csvdf.iloc[ind,5]
print("Medicine available. Quantity =",ordernum) # shows quntity of medicines available
order=int(input("Enter the amount to be ordered : "))
if order>ordernum: # checking if amount of medicines available is more than oredered number of medicines
print("Number of medicines is insufficient!!")
med()
else:
ordernum-=order
mrp_price=order*ordered_list2[ind][3]
totalprice=order*ordered_list2[ind][4]
csvdf.iloc[ind,5]=ordernum
df2=pd.DataFrame([[ordered_list2[ind][0],ordered_list2[ind][1],ordered_list2[ind][2],ordered_list2[ind][3],ordered_list2[ind][4],order,mrp_price,totalprice]])
global df1,t
df1=pd.concat([df1,df2],ignore_index=True)
t+=1
def optsel():
opt=int(input("Enter 1-To order more medicines\n2-To final the order : "))
if opt==1:
med()
elif opt==2:
print("")
else: # Checks if the option selected exists
print("Wrong option selected. Re-enter option\n")
optsel()
optsel()
else:
print("This medicine is not present in the inventory. Re-enter the medicine name")
med()
med()
x1=0
x2=1
final_price=0
discount_price=0
while(x2<=t):
final_price+=df1.iloc[x2,7]
x2+=1
bfinal_price=final_price
if final_price>1000:
final_price=0.9*final_price
sgst=0.18*final_price
cgst=0.09*final_price
final_price=final_price+sgst+cgst
global csvdf
csvdf.to_csv("C:\Sonia\Cummins Assignments\loop.csv",index=False)
#NANDINI-------------------------------------------------------------------
print("-"*85)#printing of E-BILL.
print("\t\t\t E-BILL GENERATED \t\t\t")
print("-"*85)
import datetime as dt
dt_India = dt.datetime.utcnow() + dt.timedelta(hours=5, minutes=30)
Indian_time = dt_India.strftime('%d-%b-%y %H:%M:%S')
max_len = len(max(['Indian Time'], key=len))
print(Indian_time)#printing date and time of purchasing.
print("NAME :",Cname,"\t\t\t PhNo :",Cnum)#printing name,phone number and email of customer.
print("EMAIL ID :",Cmail)
print("-"*85)
df1.rename(columns={0:'| ITEM |',1:1,2:2,3:'| MRP |',4:'| BEST_PRICE |',5:'| QUANTITY |',6:6,7:7},inplace=True)
print(df1.loc[1:,['| ITEM |','| QUANTITY |','| MRP |','| BEST_PRICE |']].to_markdown()) #printing items,quantity,price of the items purchased.
print("-"*85)
print("<","-"*22,"AMOUNT IN INR","-"*20,">")
print("TOTAL AMOUNT : {:.2f}".format(bfinal_price))#printing total price,discount price and final price(by adding sgst and cgst).
if discount_price!=0:
print("DISCOUNT(10%): {:.2f}".format(discount_price))
print("CGST(9%) : {:.2f}".format(cgst))
print("SGST(18%): {:.2f}".format(sgst))
print("FINAL AMOUNT(INCLUDING TAXES): {:.2f}".format(final_price))
print("-"*85)
print("PAYMENT OPTIONS :")# payment options-later or now.
print("ENTER 1 FOR : LATER OPTION")
print("ENTER 2 FOR : NOW OPTION")
ch=int(input("PLEASE ENTER THE ABOVE CHOICE :"))
pay=""
if ch==1 :
print("YOUR AMOUNT WILL BE STORED FOR LATER PAY")
else :
print("PAYMENT OPTIONS")# options for now payment.
print("ENTER\n1 FOR: CASH\n2 FOR: DEBIT/CREDIT CARD\n3 FOR: GOOGLE PAY\PAYTM\PHONE PAY\n4 FOR: ANY OTHER OPTION")
pay=int(input("ENTER YOUR PAYMENT MODE: "))
#print("pay value",pay)
if pay==1:
payment="CASH"
elif pay==2:
payment="DEBIT/CREDIT CARD"
elif pay==3:
payment="GOOGLE PAY\PAYTM\PHONE PAY"
elif pay==4:
payment="ANY OTHER OPTION"
else :
payment="LATER OPTION"
import smtplib
df=df1.loc[1:,['| ITEM |','| QUANTITY |','| MRP |','| BEST_PRICE |']] #sending email to buyer regarding their purchased items and payment status using smtplib library.
s=smtplib.SMTP_SSL("smtp.gmail.com",465)
s.login("[email protected]","loop@3004")
subject="YOUR PANACEA ORDER CONFIRMATION AND PAYMENT DETAILS"
if payment=="LATER OPTION" : #message-if payment option selected is later.
Text="Hello,\nThanks for confirming your order with PANACEA of medicines.\nYour order summary :\n{}\nTotal Payable Amount:{:.2f}\nPAYMENT STATUS :{}\nPlease pay your bill within 30 days ".format(df.to_string(),final_price,payment)
else : #message-if payment option selected is now.
Text="Hello,\nThanks for confirming your order with PANACEA of medicines\nYour order summary\n{}\nTotal Payable Amount:{:.2f}\nPAYMENT STATUS :{}".format(df.to_string(),final_price,payment)
message='Subject: {}\n\n{}'.format(subject,Text)
s.sendmail("[email protected]",Cmail,message)
s.quit()
first_input() #calling of function first_input to diaplay menu and enter choice.
elif (c==2): # if choice entered is 2.
def med_add(): #creating a function med_add to MODIFYING ITEM QUANTITY IN INVENTORY.
csvdf=pd.read_csv("C:\Sonia\Cummins Assignments\loop.csv")
medicines=csvdf["0"].tolist()
val=csvdf.values
medicine2=val.tolist()
mt=tree(medicines)
ordered_list=mt.order()
mt2=tree(medicine2)
ordered_list2=mt2.order()
y=input("Medicine Name : ")
y=y.lower()
z=mt.search(y)
if z==True:
ind=ordered_list.index(y)
ordernum=csvdf.iloc[ind,5]
order=int(input("Enter the amount to be added : "))
ordernum+=order # Adds more medidine in the inventory
csvdf.iloc[ind,5]=ordernum
print("QUANTITY AFTER ADDITION OF MORE MEDICINES IS",ordernum)
csvdf.to_csv("C:\Sonia\Cummins Assignments\loop.csv",index=False)
else:
print("\nNo medicine with such name found")
med_add()
def optsel():
opt=int(input("Enter 1-To add quantity of more medicines\n2-To go to menu : "))
if opt==1:
med_add()
elif opt==2:
first_input()
else:
print("Wrong option selected. Re-enter option\n")
optsel()
optsel()
med_add()
elif c==3: #if choice entered is 3.
def new_item(): #creating a function new_item() to add new medicines in inventory.
med_name=input("New Medicine Name : ")
med_name=med_name.lower()
med_content=input("New Medicine Content : ")
med_e=input("What is the medicine used for : ")
med_mrp=int(input("Medicine mrp : "))
med_bp=int(input("Medicine best price : "))
med_qty=int(input("Medicine quantity : "))
l=[med_name,med_content,med_e,med_mrp,med_bp,med_qty]
csvdf=pd.read_csv("C:\Sonia\Cummins Assignments\loop.csv")
val=csvdf.values
medicine2=val.tolist()
medicine2.append(l)
mt2=tree(medicine2)
ordered_list2=mt2.order()
df=pd.DataFrame(ordered_list2)
df.to_csv("C:\Sonia\Cummins Assignments\loop.csv",index=False)
def optsel():
opt=int(input("Enter 1-To add more medicines\n2-To go to menu : "))
if opt==1:
new_item()
elif opt==2:
first_input()
else:
print("Wrong option selected. Re-enter option\n")
optsel()
optsel()
new_item()
elif c==4: #if choice entered is 4.
csvdf=pd.read_csv("C:\Sonia\Cummins Assignments\loop.csv")
print(csvdf) #printing of mediciens present in inventory.
first_input() #calling of function first_input to diaplay menu and enter choice.
elif c==5: #if choice entered is 5.
def del_item(): # creating function del_item to delete data from inventory.
csvdf=pd.read_csv("C:\Sonia\Cummins Assignments\loop.csv")
medicines=csvdf["0"].tolist()
val=csvdf.values
medicine2=val.tolist()
mt=tree(medicines)
ordered_list=mt.order()
mt2=tree(medicine2)
ordered_list2=mt2.order()
y=input("Medicine Name : ")
y=y.lower()
z=mt.search(y)
if z==True:
n=ordered_list.index(y)
csvdf=csvdf.drop(n)
val=csvdf.values
medicine2=val.tolist()
mt2=tree(medicine2)
ordered_list2=mt2.order()
df11=pd.DataFrame(ordered_list2)
df11.to_csv("C:\Sonia\Cummins Assignments\loop.csv",index=False)
print("\nMedicine data deleted.\n")
else:
print("\nNo medicine with such name found")
del_item()
def optsel():
opt=int(input("Enter 1-To delete more medicines\n2-To go to menu : "))
if opt==1:
del_item()
elif opt==2:
first_input()
else:
print("Wrong option selected. Re-enter option\n")
optsel()
optsel()
del_item()
elif c==6: #if choice entered is 6.
exit #program will get terminated.
else:
print("\nWrong option selected. Re-enter option") # if the enetered choice is invalid it will display this message.
first_input() #calling of function first_input to diaplay menu and enter choice.
first_input()