-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonline_banking_system.py
More file actions
309 lines (288 loc) · 10.2 KB
/
Copy pathonline_banking_system.py
File metadata and controls
309 lines (288 loc) · 10.2 KB
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
import pickle
import os
import pathlib
from twilio.rest import Client
Admin="Admin12345" #Admin Password
class Account :
accNo = 0
name = ""
deposit=0
type = ""
def createAccount(self):
self.accNo= int(input("Enter the account no : "))
self.password=input("Create a password : ")
self.name = input("Enter the account holder name : ")
self.mob=input("Enter your phone Number : ")
self.type = input("Enter the type of account [C/S] : ")
self.deposit = int(input("Enter The Initial amount(>=500 for Saving and >=1000 for current : "))
sms(self.accNo,1,self.name,self.mob)
print("\n\n\nAccount Created")
def showAccount(self):
print("Account Number : ",self.accNo)
print('Account Password : ',self.password)
print("Account Holder Name : ", self.name)
print("Mobile : ",self.mob)
print("Type of Account",self.type)
print("Balance : ",self.deposit)
def modifyAccount(self):
print("Account Number : ",self.accNo)
self.name = input("Modify Account Holder Name :")
self.type = input("Modify type of Account :")
self.deposit = int(input("Modify Balance :"))
def depositAmount(self,amount):
self.deposit += amount
def withdrawAmount(self,amount):
self.deposit -= amount
def report(self):
print(self.accNo," ",self.password, " ",self.name ," ",self.type," ", self.deposit)
def getAccountNo(self):
return self.accNo
def getPassword(self):
return self.password
def getAcccountHolderName(self):
return self.name
def getMobile(self):
return self.mob
def getAccountType(self):
return self.type
def getDeposit(self):
return self.deposit
def intro():
print("\t\t\t\t**********************")
print('\t\t\t\t Welcome to R&K BANK')
print('\t\t\t\t**********************')
print('\t\t\t\tBrought To You By:')
print('\t\t\t\tRavi Raushan and Kshtij Raj')
def writeAccount():
account=Account()
account.createAccount()
createAccountFile(account)
def createAccountFile(account):
file=pathlib.Path("accounts.data")
if file.exists():
inFile=open('accounts.data','rb')
outFile=pickle.load(inFile)
outFile.append(account)
inFile.close()
os.remove("accounts.data")
inFile=open('accounts.data','wb')
pickle.dump(outFile,inFile)
inFile.close()
else:
oldlist = [account]
outFile = open("accounts.data","wb")
pickle.dump(oldlist, outFile)
outFile.close()
os.rename("accounts.data", "accounts.data")
def checkPassword(pword):
file=pathlib.Path("accounts.data")
if file.exists ():
infile = open('accounts.data','rb')
mylist = pickle.load(infile)
infile.close()
allow=False
for item in mylist :
if item.password==pword:
allow=True
return allow
else:
print("No data found\n")
def depositAndWithdraw(num1, num2):
file=pathlib.Path("accounts.data")
if file.exists ():
infile = open('accounts.data','rb')
mylist = pickle.load(infile)
infile.close()
for item in mylist :
if item.accNo==num1:
if num2 == 1 :
os.remove("accounts.data")
amount = int(input("Enter the amount to deposit : "))
item.deposit+=amount
outfile = open("accounts.data","wb")
pickle.dump(mylist, outfile)
outfile.close()
os.rename("accounts.data", "accounts.data")
print("Your account is updted\n")
break
elif num2 == 2 :
amount = int(input("Enter the amount to withdraw : "))
if amount <= item.deposit :
os.remove("accounts.data")
item.deposit -=amount
outfile = open("accounts.data","wb")
pickle.dump(mylist, outfile)
outfile.close()
os.rename("accounts.data", "accounts.data")
print("Your account is updted\n")
break
else :
print("You cannot withdraw larger amount\n")
def displayBalance(num):
file=pathlib.Path("accounts.data")
if file.exists():
inFile=open('accounts.data','rb')
mylist=pickle.load(inFile)
inFile.close()
found = False
for item in mylist :
if item.accNo == num :
print("Your account Balance is = ",item.deposit,"\n")
found = True
break
if not found :
print("No existing record with this number\n")
def displayAll():
file = pathlib.Path("accounts.data")
if file.exists ():
infile = open("accounts.data",'rb')
mylist = pickle.load(infile)
for item in mylist :
print(item.accNo," ",item.password," ", item.name, " ",item.type, " ",item.deposit )
infile.close()
else :
print("No records to display\n")
def deleteAccount(num):
file = pathlib.Path("accounts.data")
if file.exists ():
infile = open("accounts.data","rb")
oldlist = pickle.load(infile)
infile.close()
newlist = []
for item in oldlist :
if item.accNo != num :
newlist.append(item)
else:
sms(num,6,item.name,item.mob)
os.remove("accounts.data")
outfile = open("accounts.data","wb")
pickle.dump(newlist, outfile)
outfile.close()
os.rename("accounts.data", "accounts.data")
print("Your account is closed\n")
def modifyAccount(num):
file = pathlib.Path("accounts.data")
if file.exists ():
infile = open("accounts.data","rb")
oldlist = pickle.load(infile)
infile.close()
os.remove("accounts.data")
for item in oldlist :
if item.accNo == num :
item.name = input("Enter the account holder name : ")
item.password=input("Create new password : ")
item.type = input("Enter the account Type : ")
item.mob=int(input("Enter the mobile number : "))
sms(num,7,item.name,item.mob)
outfile = open("accounts.data","wb")
pickle.dump(oldlist, outfile)
outfile.close()
os.rename("accounts.data", "accounts.data")
print("Data Updated\n")
def sms(acc,opt,name,mob):
account_sid="api key" #Enter your api
auth_token='auth_token' #Enter your key
my_phone_number='[+country code][phone number]' #Enter your registered phone Number
client=Client(account_sid, auth_token)
if opt==1:
message=client.messages.create(
body=f'''\nNew Account created
User Name : {name}
Account Number : {acc}
Mobile Number : {mob}''',
from_='given phone number', #Enter your given phone number
to=my_phone_number
)
print(message.body)
os.system('cls')
elif opt==6:
message=client.messages.create(
body=f'''\nAccount Closed
Account Number : {acc}
User Name : {name}
Mobile Number : {mob}''',
from_='given phone number', #Enter your given phone number
to=my_phone_number
)
print(message.body)
os.system('cls')
elif opt==7:
message=client.messages.create(
body=f'''\nAccount Updated
Account Number : {acc}
User Name : {name}
Mobile Number : {mob}''',
from_='given phone number', #Enter your given phone number
to=my_phone_number
)
print(message.body)
os.system('cls')
ch=""
num=0
intro()
while ch != 8:
print("\tMAIN MENU")
print("\t1. NEW ACCOUNT")
print("\t2. DEPOSIT AMOUNT")
print("\t3. WITHDRAW AMOUNT")
print("\t4. BALANCE ENQUIRY")
print("\t5. ALL ACCOUNT HOLDER LIST")
print("\t6. CLOSE AN ACCOUNT")
print("\t7. MODIFY AN ACCOUNT")
print("\t8. EXIT")
print("\tSelect Your Option (1-8) ")
ch = input()
os.system("cls");
if ch == "1":
writeAccount()
elif ch =="2":
num = int(input("\tEnter The account No. : "))
pword=input("Enter your password : ")
allow=checkPassword(pword)
if allow==True:
depositAndWithdraw(num, 1)
else:
print("Invalid Password\n")
elif ch == "3":
num = int(input("\tEnter The account No. : "))
pword=input("Enter your password : ")
allow=checkPassword(pword)
if allow==True:
depositAndWithdraw(num, 2)
else:
print("Invalid Password\n")
elif ch == "4":
num = int(input("\tEnter The account No. : "))
pword=input("Enter your password : ")
allow=checkPassword(pword)
if allow==True:
displayBalance(num)
else:
print("Invalid Password\n")
elif ch == "5":
pword=input("Enter Admin password : ")
if pword==Admin:
displayAll()
else:
print("Invalid Password\n")
elif ch == "6":
num =int(input("\tEnter The account No. : "))
pword=input("Enter your password : ")
allow=checkPassword(pword)
if allow==True:
deleteAccount(num)
else:
print("Invalid Password\n")
elif ch == "7":
num = int(input("\tEnter The account No. : "))
pword=input("Enter your password : ")
allow=checkPassword(pword)
if allow==True:
modifyAccount(num)
else:
print("Invalid Password\n")
elif ch == "8":
print("\tThanks for using bank management system\n")
break
else :
print("Invalid choice\n")