def withdraw_cash(acc_no): try: print('How much do you want to withdraw') print('Enter Amount in digit') amount = int(input("Amount to Withdraw \n")) user_balance = confirm_balance(acc_no) if user_balance < amount: print("Insufficient Fund") elif user_balance == amount: print('This amount is all you have in your account') print("Do you want to withdraw all?") response = input("Yes or No \n") if response.lower() == 'yes': user_balance -= amount print('take your cash') user = get_acc_details_from_database(acc_no) user['balance'] = user_balance update_account(acc_no, user) ask_todo_something_else() elif response.lower() == 'no': print('Enter new amount to withdraw') withdraw_cash(acc_no) else: print('Invalid response') exit() else: user_balance -= amount print('take your cash') user = get_acc_details_from_database(acc_no) user['balance'] = user_balance update_account(acc_no, user) ask_todo_something_else() except Exception as e: print("Something went wrong" , e.__class__)
def login(): try: print("*******LOGIN TO MAKE TRANSACTIONS ****************") account_number_input = validate_to_tendigits(input('Enter you account number \n ')) if not account_number_input: login() account_number_input = validate_input_as_number(account_number_input) password = input("What is your password \n ") # user = loop_tru_database(account_number_input) user = get_acc_details_from_database(account_number_input) acc_no = user['account_number'] user_password = user['password'] if acc_no == account_number_input: if user_password == password: print('LOGIN SUCCESSFUL') transaction(acc_no) else: response = input("are you sure you have account with us? YES or No \n") if response.lower() == 'yes': login() elif response.lower() == 'no': register() else: print('Invalid response') exit() else: print('Invalid account number') login() except Exception as e: print('Something went wrong', e.__class__)
def transfer_cash(acc_no): try: user = get_acc_details_from_database(acc_no) print("Enter Amount to transfer in digits") amount = int(input("How much do you want to transfer \n")) amount = validate_input_as_number(amount) print("Enter beneficiary account number in digits") beneficiary = input("Beneficiary account number \n") beneficiary = validate_to_tendigits(beneficiary) beneficiary = validate_input_as_number(beneficiary) user_balance = confirm_balance(acc_no) if user_balance < amount: print("Insufficient Fund") elif user_balance == amount: print('The amount is all you have in your account') print("Do you want to transfer all?") response = input("Yes or No \n") if response.lower() == 'yes': to_who = get_acc_details_from_database(beneficiary) to_who["balance"] += amount update_account(beneficiary, to_who) print('%.2f has been transferred to %' % (amount, beneficiary)) user['balance'] -= amount update_account(acc_no, user) ask_todo_something_else() elif response.lower() == 'no': print('Enter new amount to transfer') transfer_cash(acc_no) else: print('Invalid response') exit() else: to_who = get_acc_details_from_database(beneficiary) to_who["balance"] += amount update_account(beneficiary, to_who) print('%.2f has been transferred to %' % (amount, beneficiary)) user['balance'] -= amount update_account(acc_no, user) ask_todo_something_else() except Exception as e: print("something went wrong", e.__class__)
def account_balance(): account_number = int(input("Enter your Account Number \n")) user = get_acc_details_from_database(account_number) owner = user['account_number'] balance = user['balance'] if owner == account_number: print("Your account balance is: %.2f" % balance) ask_todo_something_else() else: print('Wrong Account Number supplied') account_balance()
def deposit(acc_no): try: print("Enter Deposit Amount in digits") amount = int(input("How much do you want to deposit \n")) user = get_acc_details_from_database(acc_no) balance = user['balance'] balance += amount print('You deposited %.2f' % amount) print("Your Account balance is %.2f" % balance) user['balance'] = balance update_account(acc_no, user) ask_todo_something_else() except Exception as w: print("something went wrong", w.__class__)
def confirm_balance(account_number): user = get_acc_details_from_database(account_number) balance = user['balance'] return balance
def get_balance(account_number): user = get_acc_details_from_database(account_number) balance = user['balance'] print("Your Account balance is %.2f" % balance)