├── README.md ├── accounts.json ├── LICENSE └── main.py /README.md: -------------------------------------------------------------------------------- 1 | # Bank Management System 2 | 3 | A simple implementation of Bank management System in Python programming lanaguage completed as a mini project. 4 | 5 | ## Usage 6 | 7 | ```powershell 8 | python main.py 9 | ``` 10 | 11 | ## Features 12 | 13 | - Create, read, update and delete records (CRUD) 14 | 15 | - Transaction (balance enquiry, cash deposit, cash withdrawl, fund transfer) 16 | 17 | ## Team 18 | 19 | 20 | 21 | ## License 22 | 23 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details 24 | -------------------------------------------------------------------------------- /accounts.json: -------------------------------------------------------------------------------- 1 | { 2 | "people": [ 3 | { 4 | "name": "Elon Musk", 5 | "PIN": 2272, 6 | "acc_number": 1, 7 | "acc_balance": 1960000 8 | }, 9 | { 10 | "name": "Surya Basnet", 11 | "PIN": 7001, 12 | "acc_number": 2, 13 | "acc_balance": 600700 14 | }, 15 | { 16 | "name": "Prajwol Kafle", 17 | "PIN": 2001, 18 | "acc_number": 3, 19 | "acc_balance": 0 20 | }, 21 | { 22 | "name": "Piyush Osti", 23 | "PIN": 1999, 24 | "acc_number": 4, 25 | "acc_balance": 400300 26 | }, 27 | { 28 | "name": "Grusha Bhattarai", 29 | "PIN": 1301, 30 | "acc_number": 5, 31 | "acc_balance": 146690 32 | }, 33 | { 34 | "name": "Aman Khadka", 35 | "PIN": 1100, 36 | "acc_number": 6, 37 | "acc_balance": 0 38 | } 39 | ] 40 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Aman Khadka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import subprocess as sp 3 | from time import sleep, time 4 | with open('accounts.json') as f: 5 | data = json.load(f) 6 | 7 | 8 | def clear(): 9 | tmp = sp.call('cls', shell=True) 10 | 11 | 12 | def new_user(): 13 | # Taking the new users name 14 | new_data = {} 15 | name = "" 16 | checker_name = 0 17 | while checker_name != 1: 18 | first_name = input("Enter your First name: ") 19 | middile_name = input("Enter your Middle name(Leave empty if none): ") 20 | last_name = input("Enter your Last name: ") 21 | if len(middile_name) == 0: 22 | name = first_name+" "+last_name 23 | else: 24 | name = first_name+" "+middile_name+" "+last_name 25 | name_checker = list(name) 26 | for i in range(len(name_checker)): 27 | asci_val = ord(name_checker[i]) 28 | if (asci_val <= 90 and asci_val >= 65) or (asci_val <= 122 and asci_val >= 97) or asci_val == 32: 29 | checker_name = 1 30 | else: 31 | checker_name = 0 32 | print("Invalid Input!! Enter Your name again: \n") 33 | break 34 | if checker_name == 1: 35 | new_data['name'] = name 36 | print(f"Welcome {name} to the Bank of TBC\n") 37 | # taking the new users pin 38 | checker_PIN = 0 39 | account_PIN_enter = 0000 40 | while checker_PIN != 1: 41 | account_PIN_enter = int(input("Enter you 4 digit PIN: ")) 42 | account_PIN_checker = int(input("Re-enter you 4 digit PIN: ")) 43 | if account_PIN_enter == account_PIN_checker: 44 | if account_PIN_enter > 999 and account_PIN_enter < 10000: 45 | checker_PIN = 1 46 | else: 47 | checker_PIN = 0 48 | print( 49 | "PIN must be 4 Digit and cannot start with 0! Enter the Pin again: \n") 50 | else: 51 | checker_PIN = 0 52 | print("Entered PIN does not match! Enter the Pin again: \n") 53 | if checker_PIN == 1: 54 | new_data['PIN'] = account_PIN_enter 55 | 56 | # creating the acc number 57 | account_number = len(data['people'])+1 58 | new_data['acc_number'] = account_number 59 | print(f"\nYour account number is: {account_number}") 60 | 61 | # setting the default accont balance at 0 62 | account_balance = 0 63 | new_data['acc_balance'] = account_balance 64 | print(f"\nYour account balance is: {account_balance}") 65 | sleep(5) 66 | # entering the data to the json file 67 | data['people'].append(new_data) 68 | with open('accounts.json', 'w') as f: 69 | json.dump(data, f, indent=2) 70 | 71 | 72 | def existing_user(): 73 | if len(data['people']) > 0: 74 | num = 0 75 | while True: 76 | check_acc_num = int(input("Please enter your Account Number: ")) 77 | for i in range(len(data['people'])): 78 | if check_acc_num == data['people'][i]['acc_number']: 79 | num = i 80 | break 81 | if i == len(data['people']) and check_acc_num != data['people'][i-1]['acc_number']: 82 | print("Invalid Account Number!!") 83 | if check_acc_num == data['people'][num]['acc_number']: 84 | break 85 | 86 | accountdetails = data['people'][num] 87 | name = accountdetails['name'] 88 | print(f"Welcome {name}\n") 89 | 90 | while True: 91 | check_PIN_1 = int(input("Enter Your PIN : ")) 92 | if check_PIN_1 == accountdetails['PIN']: 93 | check_PIN_2 = int(input("Re-enter Your PIN : ")) 94 | if check_PIN_2 == check_PIN_1: 95 | print("PIN is correct!") 96 | break 97 | else: 98 | print("The PINs do not match!") 99 | else: 100 | print("Incorrect PIN!") 101 | 102 | while True: 103 | clear() 104 | print(f"Welcome {name} to the Bank of TBC\n") 105 | choice2 = int(input( 106 | "\n1. View Balance\n2. Deposit\n3. Withdraw\n4. Transfer\n5. Profile\n6. Logout\n")) 107 | if choice2 == 1: 108 | clear() 109 | balance = accountdetails['acc_balance'] 110 | print(f"Your Account Balance is: {balance}") 111 | sleep(4) 112 | 113 | elif choice2 == 2: 114 | clear() 115 | enter_amount = int( 116 | input("Enter the amount you want to deposit: ")) 117 | new_balance = accountdetails['acc_balance']+enter_amount 118 | data['people'][num]['acc_balance'] = new_balance 119 | with open('accounts.json', 'w') as f: 120 | json.dump(data, f, indent=2) 121 | print( 122 | f"Amount of Rs. {enter_amount} has been credited to your account!") 123 | print(f"Your Balance is: {new_balance}") 124 | sleep(3) 125 | 126 | elif choice2 == 3: 127 | while True: 128 | clear() 129 | enter_amount = int( 130 | input("Enter the amount you want to withdraw: ")) 131 | if enter_amount > accountdetails['acc_balance']: 132 | print("You do not have this ammount of money!") 133 | else: 134 | new_balance = accountdetails['acc_balance'] - \ 135 | enter_amount 136 | data['people'][num]['acc_balance'] = new_balance 137 | with open('accounts.json', 'w') as f: 138 | json.dump(data, f, indent=2) 139 | print( 140 | f"Amount of Rs. {enter_amount} has been debited from your account!") 141 | print(f"Your Balance is: {new_balance}") 142 | sleep(3) 143 | break 144 | 145 | elif choice2 == 4: 146 | new_num = 0 147 | while True: 148 | clear() 149 | enter_acc_num = int( 150 | input("Enter the Account number of the account you want to transfer: ")) 151 | if enter_amount > accountdetails['acc_balance']: 152 | print("You do not have this ammount of money!") 153 | for i in range(len(data['people'])): 154 | if enter_acc_num == data['people'][i]['acc_number']: 155 | new_num = i 156 | break 157 | if i == len(data['people']) and enter_acc_num != data['people'][i-1]['acc_number']: 158 | print("Invalid Account Number!!") 159 | if enter_acc_num == data['people'][new_num]['acc_number']: 160 | newaccountdetails = data['people'][new_num] 161 | new_name = newaccountdetails['name'] 162 | check_if_name_ok = input( 163 | f"Do you want to transfer to {new_name}? (Y/N)") 164 | while True: 165 | if check_if_name_ok == 'Y' or check_if_name_ok == 'y': 166 | amount = int( 167 | input("Enter the amount that you want to transfer: ")) 168 | other_person_new_balance = newaccountdetails['acc_balance']+amount 169 | own_new_balance = accountdetails['acc_balance']-amount 170 | data['people'][num]['acc_balance'] = own_new_balance 171 | data['people'][new_num]['acc_balance'] = other_person_new_balance 172 | with open('accounts.json', 'w') as f: 173 | json.dump(data, f, indent=2) 174 | print("Transfer Complete") 175 | sleep(3) 176 | break 177 | elif check_if_name_ok == 'N' or check_if_name_ok == 'n': 178 | break 179 | else: 180 | print("Invalid Input Enter 'Y' or 'N'") 181 | break 182 | elif choice2 == 6: 183 | break 184 | 185 | elif choice2 == 5: 186 | while True: 187 | clear() 188 | name = accountdetails['name'] 189 | pin = accountdetails['PIN'] 190 | balance = accountdetails['acc_balance'] 191 | acc_num = accountdetails['acc_number'] 192 | print( 193 | f"Account Holder Name: {name}\nAccount Number: {acc_num}\nPIN: {pin}\nAccount Balance: {balance}\n") 194 | choice3 = int( 195 | input("\n\n1. Change PIN\n2. Go back to Account Menu\n3. Delete Account\n")) 196 | if choice3 == 2: 197 | break 198 | elif choice3 == 1: 199 | while True: 200 | clear() 201 | curr_PIN = int(input("Enter your Current PIN: ")) 202 | if curr_PIN == accountdetails['PIN']: 203 | new_PIN = int(input("Enter your New PIN: ")) 204 | if new_PIN > 999 and new_PIN < 10000: 205 | data['people'][num]['PIN'] = new_PIN 206 | with open('accounts.json', 'w') as f: 207 | json.dump(data, f, indent=2) 208 | print( 209 | f"PIN changed Sucessfully!\nYour new PIN is: {new_PIN}") 210 | sleep(3) 211 | break 212 | else: 213 | print( 214 | "PIN must be 4 Digit and cannot start with 0!\n") 215 | else: 216 | print("Incorrect PIN!") 217 | elif choice3 == 3: 218 | confirm = input( 219 | "Are you sure you want to delete your account!!(Y/N)? ") 220 | if confirm == 'Y' or confirm == 'y': 221 | while True: 222 | check_PIN_1 = int(input("Enter Your PIN : ")) 223 | if check_PIN_1 == accountdetails['PIN']: 224 | check_PIN_2 = int( 225 | input("Re-enter Your PIN : ")) 226 | if check_PIN_2 == check_PIN_1: 227 | data['people'].pop(num) 228 | with open('accounts.json', 'w') as f: 229 | json.dump(data, f, indent=2) 230 | print( 231 | "Account Sucessfully Deleted! and your money is gone forever!!") 232 | sleep(3) 233 | break 234 | else: 235 | print("The PINs do not match!") 236 | else: 237 | print("Incorrect PIN!") 238 | break 239 | 240 | else: 241 | print("There are no accounts in this bank!") 242 | 243 | 244 | def about(): 245 | print('''\n==========ABOUT US========== 246 | This project has been created by Aman Khadka. 247 | It is a basic Python Project for my 1st Semester.''') 248 | 249 | 250 | def developer_mode(): 251 | print(data) 252 | sleep(10) 253 | 254 | 255 | # main 256 | while True: 257 | print("Welcome to the Bank of TBC\n") 258 | choice1 = int(input("1. Sign up\n2. Login\n3. About\n4. Exit\n")) 259 | if choice1 == 1: 260 | clear() 261 | new_user() 262 | elif choice1 == 2: 263 | clear() 264 | existing_user() 265 | elif choice1 == 3: 266 | about() 267 | elif choice1 == 5: 268 | clear() 269 | developer_mode() 270 | elif choice1 == 4: 271 | break 272 | --------------------------------------------------------------------------------