-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank_operations.py
83 lines (66 loc) · 2.81 KB
/
bank_operations.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
import auth
import random
import database
import validation
def services(user):
print("Welcome %s %s " % (user[0], user[1]))
selected_option = int(input("What would you like to do? (1) deposit (2) withdrawal (3) Logout (4) Exit \n"))
if selected_option == 1:
deposit()
elif selected_option == 2:
withdraw()
elif selected_option == 3:
auth.logout()
elif selected_option == 4:
exit()
else:
print("Invalid option selected")
services(user)
def withdraw():
# get current balance
# get amount to withdraw
# check if current balance > withdraw balance
# deduct withdrawn amount form current balance
# display current balance
current_user_account_number = int(input("Enter your account number: \n"))
is_account_valid = validation.account_number_validation(current_user_account_number)
if is_account_valid:
current_user = str.split(database.read(current_user_account_number), ',')
print("Your current account balance is " + "NGN" + current_user[4] + ".00")
withdrawal_amount = int(input("Enter the amount you want to withdraw: \n"))
if withdrawal_amount <= int(current_user[4]):
new_balance = int(current_user[4]) - withdrawal_amount
print("Please take your cash.")
# update user account balance
# database.update(current_user_account_number, 4)
print("Your new account balance is " + "NGN" + str(new_balance) + ".00 \n")
print("Thank you for banking with us \n")
exit()
else:
print("Insufficient account balance. Please try again")
auth.login()
else:
print("Invalid account number. Please try again")
auth.login()
def deposit():
# get current balance
# get amount to deposit
# add deposited amount to current balance
# display current balance
current_user_account_number = int(input("Enter your account number: \n"))
is_account_valid = validation.account_number_validation(current_user_account_number)
if is_account_valid:
current_user = str.split(database.read(current_user_account_number), ',')
print("Your current account balance is " + "NGN" + current_user[4] + ".00")
deposit_amount = int(input("Enter the amount you want to deposit: \n"))
new_balance = int(current_user[4]) + deposit_amount
# update user account balance
# database.update(current_user_account_number, 4)
print("Your new account balance is " + "NGN" + str(new_balance) + ".00 \n")
print("Thank you for banking with us \n")
exit()
else:
print("Invalid account number. Please try again")
auth.login()
def generate_account_number():
return random.randrange(1111111111, 9999999999)