-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfunctions.py
199 lines (172 loc) · 6.38 KB
/
functions.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
__author__ = 'user'
import database
from classes import Customer,Account,Savings,Current,Address
import validate
import login_menu
import admin_menu
import database_admin as db_admin
def sign_up():
customer = Customer()
first_name = input("Enter First Name\n")
last_name = input("Enter Last Name\n")
add_line1 = input("Enter Address Line 1\n")
add_line2 = input("Enter Address Line 2\n")
city = input("Enter City\n")
state = input("Enter State\n")
try:
pincode = int(input("Enter Pincode\n"))
if pincode < 100000 or pincode > 999999:
print("Invalid Pincode")
return
except:
print("Invalid Pincode")
return
password = input("Enter password (min 8 char and max 20 char)\n")
while len(password) < 8 or len(password) > 20:
print("Please Enter password in given range\n")
password = input();
customer.set_first_name(first_name)
customer.set_last_name(last_name)
customer.set_password(password)
customer.set_status("open")
customer.set_login_attempts(3)
addr = Address()
addr.set_line_1(add_line1)
addr.set_line_2(add_line2)
addr.set_city(city)
addr.set_state(state)
addr.set_pincode(pincode)
customer.set_address(addr)
database.sign_up_customer(customer)
def sign_in():
try:
id = int(input("Enter Customer ID\n"))
except:
print("Invalid ID")
return
if db_admin.check_customer_exists(id) is True:
customer = database.get_all_info_customer(id)
if customer.get_status() == "locked":
print("Sorry Your Account has been locked due to 3 unsuccessful login attempts")
return
password = input("Enter Password\n")
res = database.login_customer(id,password)
if res is True:
database.reset_login_attempts(id)
print("Login Successful")
ch = 1
while ch != 0:
print("\n--- Menu ---")
print("1. Address Change")
print("2. Open New Account")
print("3. Money Deposit")
print("4. Money Withdrawal")
print("5. Transfer Money")
print("6. Print Statement")
print("7. Account Closure")
print("8. Avail Loan")
print("0. Logout")
try:
ch = int(input())
except:
print("Invalid Choice")
ch = 1
continue
if ch == 1:
login_menu.change_address(id)
elif ch == 2:
login_menu.open_new_account(id)
elif ch == 3:
login_menu.deposit_money(id)
elif ch == 4:
login_menu.withdraw_money(id)
elif ch == 5:
login_menu.transfer_money(id)
elif ch == 6:
login_menu.print_statement(id)
elif ch == 7:
login_menu.close_account(id)
elif ch == 8:
login_menu.avail_loan(id)
elif ch == 0:
print("Logged Out Successfully")
else:
print("Invalid Choice")
else:
att = customer.get_login_attempts()-1
customer.set_login_attempts(att)
database.update_customer(customer)
print("Incorrect Password")
else:
print("Customer doesn't exist")
def admin_sign_in():
try:
id = input("\nEnter Admin ID : ")
except:
print("Invalid ID")
return
password = input("\nEnter Password : ")
count = 2
res = database.login_admin(id,password)
while count != 0 and res == False:
print("Wrong ID or Password")
print("Attempts Remaining : ",count)
try:
id = int(input("Enter Admin ID\n"))
except:
print("Invalid ID")
return
password = input("Enter Password\n")
res = database.login_admin(id,password)
count = count-1
if res == True:
print("Login Successful")
ch = 1
while ch != 0:
print("\n --- Menu --- ")
print("1. Print Closed Accounts History")
print("2. FD report of a customer")
print("3. FD report of a customer vis-a-vis another customer")
print("4. FD report w.r.t a particular FD amount")
print("5. Loan report of a customer")
print("6. Loan report of a customer vis-a-vis another customer")
print("7. Loan report w.r.t a particular loan amount")
print("8. Loan - FD report of customers")
print("9. Report of customers who are yet to avail a loan")
print("10. Report of customers who are yet to open an FD account")
print("11. Report of customers who neither have a loan nor an FD account with the bank")
print("0. Admin Log Out")
try:
ch = int(input())
except:
print("Invalid Choice")
ch = 1
continue
if ch == 1:
admin_menu.print_closed_acc_history()
elif ch == 2:
admin_menu.print_fd_report()
elif ch == 3:
admin_menu.print_fd_report_vis_customer()
elif ch == 4:
admin_menu.print_fd_report_wrt_amount()
elif ch == 5:
admin_menu.print_loan_report()
elif ch == 6:
admin_menu.print_loan_report_vis_customer()
elif ch == 7:
admin_menu.print_loan_report_wrt_amount()
elif ch == 8:
admin_menu.print_loan_fd_report()
elif ch == 9:
admin_menu.print_report_no_loan()
elif ch == 10:
admin_menu.print_report_no_fd()
elif ch == 11:
admin_menu.print_report_no_fd_loan()
elif ch == 0:
print("Logged Out Successfully")
else:
print("Invalid Choice")
else:
print("Sorry all Attempts Finished")