def send_money(user): money=float(input("Enter the amount to be sent--->")) user1=Wallet.select().where(Wallet.customer_id==user).get() comments=input("Enter comments\n--------------------------------------\n") bal=user1.balance if money>bal : print("YOU'RE BROKE!! ") print("*"*30,"\n") else: receiver_username=input("Enter the user name of the receiver--->") receive_user=User.select().where(User.user_name==receiver_username).get() user2=Wallet.select().where(Wallet.customer_id==receive_user).get() bal1=user1.balance-money bal2=user2.balance+money query1 = Wallet.update(balance=bal1).where(Wallet.customer_id==user) n1 = query1.execute() query2 = Wallet.update(balance=bal2).where(Wallet.customer_id==receive_user) n2 = query2.execute() entry=Transaction(customer_id=user,transaction_amount=money,type_transaction="Withdraw",timestamp=datetime.now(),comments=comments) entry.save() entry=Transaction(customer_id=receive_user,transaction_amount=money,type_transaction="Deposit",timestamp=datetime.now(),comments=comments) entry.save() print("*"*30,"\n")
def login(): print("*"*30,"\n") user_name=input("Enter username---> ") password=input("Enter password----> ") try: user=User.select().where(User.user_name==user_name).get() if user.password==password: print("Logged in successfully.\n") print("*"*30,"\n") return user else: print("Incorrect password.\n") return 0 except: print("Incorrect Credentials") return 0
from my_functions import * from Model import User while True: print("-_-" * 15) print( "Choose an option\n----------------------\n1.Login\n2.Register\n3.View Balance\n4.Add Money\n5.Withdraw\n6.Send Money\n7.Show Transactions" ) print("-_-" * 15) choice = int(input("--> ")) if choice == 1: user = login() elif choice == 2: while True: print("*" * 30, "\n") username = input("Enter user name \n--->") user = User.select().where(User.user_name == username) if len(user) == 0: fullname = input("Enter full name \n---> ") password = input("Enter password \n--->") register(fullname, username, password) print("*" * 30, "\n") break else: print("User_name exists!!") elif choice == 3: user = login() if user == 0: print("login failed") continue