-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
224 lines (204 loc) · 11 KB
/
main.py
File metadata and controls
224 lines (204 loc) · 11 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
from functions import Functions
from customer import Customer
from transaction import Transaction
import time
def menu():
while True:
print('''
Welcome to the Ansh Bank of India Banking System!
Choose from the Options Below:
1) Customer Login
2) New Customer Registration
3) Employee Login
''')
ch = int(input("Enter your Choice (1/2/3): "))
if ch == 1:
#Customer Login System Created
print("Hello Customer! Please Enter you details.")
cust_id = input("Enter your Customer ID: ")
passwd = input("Enter your password: ")
with open('data/customer.txt','r') as f:
data = f.readlines()
found = False
for i in data:
if f"{cust_id}" in i:
if Functions.VerifyPassword(passwd,"C") and Functions.verify_captcha():
f.close()
found = True
cust_name = i.split()[0].replace("_"," ")
print("Login Successful!")
print(f"Welcome {cust_name}! Hope you are having a nice day!")
print('''
Choose an option from below:
1) Check Balance
2) Make Transaction
3) Exit
''')
nch = int(input("Enter a choice (1/2/3): "))
if nch not in [1,2,3]:
print("Invalid Choice Login Again!")
pass
if nch == 1:
with open('data/accounts.txt','r') as file:
acc_data = file.readlines()
for j in acc_data:
if f"{cust_id}" in j:
d = j.split()
print(f"Account balance for Account Number {Functions.findAccNo(cust_id=cust_id)} associated to {cust_name} is: Rs.{d[1]}")
print("")
print("Would you like to make a transaction(1) or exit(2): ")
cho = int(input("Enter your Choice: "))
if cho not in [1,2]:
print("Invalid choice, try again!")
file.close()
elif cho==1:
nch = 2
file.close()
else:
file.close()
break
if nch == 2:
print("Welcome to the Transaction Page!")
acc = int(input("Enter the Beneficiary Account Number: "))
racc = int(input("Re-Enter/Confirm the Beneficiary Account Number: "))
amount = int(input("Enter amount to Send: "))
if acc != racc:
print("Account Numbers Dont Match! Try Again")
passwd = input("Enter you password: ")
if Functions.VerifyPassword(passwd,"C") and Functions.verify_captcha():
Transaction(Functions.findAccNo(cust_id),acc,amount)
break
else:
print("Wrong Password! Try Again.")
if nch == 3:
f.close()
break
if not found:
print("Customer not Found!")
print("Try Again!")
f.close()
menu()
elif ch == 2:
# New Customer Registeration!
name = input("Enter the Full Name of Customer: ").replace(" ","_").lstrip("_").rstrip("_")
email = input("Enter User Email: ")
type = input("Enter Type of Account (SA/CA): ")
bal = float(input("Enter balance to add according to the Account type: "))
pswd = input("Enter a temporary password for user: ")
if Functions.verify_captcha():
Customer(name,email,type.upper(),bal,pswd)
print("Processing Request...")
time.sleep(4)
print("Customer Created Successfully!")
else:
print("Wrong Captcha! Try Again...")
print("Exiting console...")
time.sleep(5)
break
elif ch == 3:
#Employee Login System
print("Welcome Employee! Please Enter your details.")
emp_id = input("Enter Employee ID: ")
with open('data/employee.txt') as file:
emp_data = file.readlines()
emp_ids = list()
for i in emp_data:
emp_ids.append(i.split(" ")[0])
emp_names = list()
for j in emp_data:
emp_names.append(i.split(" ")[1])
if emp_id in emp_ids:
password = input("Enter your password: ")
temp_captcha = Functions.verify_captcha()
if temp_captcha and Functions.VerifyPassword(password,"E"):
print(f"Welcome {emp_names[emp_ids.index(emp_id)].replace('_'," ")}! Great to have you.")
print('''
Choose from an option below:
1) Make Transaction within Accounts
2) Deposit Money to Account (cheque or cash via/to customer)
3) Withdraw Money from Account (cheque or cash via/to customer)
4) Make new Customer ID and Account
5) Access Transaction Logs (per user only)
6) Exit
''')
cho = int(input("Enter Choice: "))
if cho not in [1,2,3,4,5]:
print("Invalid Choice! Try Aagin...")
time.sleep(3)
elif cho == 1:
#Transaction between Accounts within Bank.
sender_acc = int(input("Enter Senders Account Number: "))
reciever_acc = int(input("Enter recievers Account Number: "))
amount = float(input("Enter the amount to be transferred: "))
if Functions.VerifyPassword() and Functions.verify_captcha():
Transaction(sender_acc,reciever_acc,amount)
time.sleep(6)
break
else:
print("Something went Wrong! Try Again.")
elif cho == 2:
#Deposit Money to Account
acc = int(input("Enter Account Number: "))
with open("data/accounts.txt",'r') as file:
data = file.read()
if str(acc) in data:
bal = float(input("Enter amount to Deposit: "))
pswd = input("Enter your password: ")
if Functions.verify_captcha() and Functions.VerifyPassword(pswd,"E"):
Transaction.updateBalance(acc,bal,"D")
else:
print("Something went Wrong! Try Again Later...")
else:
print("Account Not Found! Try again Later...")
elif cho == 3:
#Withdraw Money from Account.
acc = int(input("Enter Account Number: "))
with open("data/accounts.txt",'r') as file:
data = file.read()
if str(acc) in data:
bal = float(input("Enter amount to Deposit: "))
pswd = input("Enter your password: ")
if Functions.verify_captcha() and Functions.VerifyPassword(pswd,"E"):
Transaction.updateBalance(acc,bal,"W")
else:
print("Something went Wrong! Try Again Later...")
else:
print("Account Not Found! Try again Later...")
...
elif cho == 4:
#Make new Customer and Account.
name = input("Enter the Full Name of Customer: ").replace(" ","_").lstrip("_").rstrip("_")
email = input("Enter User Email: ")
type = input("Enter Type of Account (SA/CA): ")
bal = float(input("Enter balance to add according to the Account type: "))
pswd = input("Enter a temporary password for user: ")
Customer(name,email,type.upper(),bal,pswd)
print("Processing Request...")
time.sleep(4)
print("Customer Created Successfully!")
break
elif cho == 5:
acc = int(input("Enter Account Number: "))
logs = Transaction.getTransactionLog(account=acc)
print("Logs:")
for i in logs:
print(i)
time.sleep(20)
print("Exiting console.")
...
else:
print("Exiting Console.")
time.sleep(6)
break
elif temp_captcha == True:
print("Wrong Password Entered")
else:
print("Wrong Captcha Entered or Something went wrong....")
break
elif emp_id not in emp_ids:
print("Employee not Found. Try Again...")
else:
print("Invalid Choice Start Again!")
pass
print("Thanks for using our Banking System!")
menu()