def check_transaction_count(customer): if customer.accountType == accountType.get(1): stmt = "SELECT transcount,dt,renewaldate from transactioncount where accountid = :1" cur.execute(stmt, {'1': customer.accountNumber}) res = cur.fetchall() count = int(res[0][0]) d1 = res[0][1] d2 = res[0][2] d1 = datetime.strptime(str(d1)[0:10], '%Y-%m-%d') d2 = datetime.strptime(str(d2)[0:10], '%Y-%m-%d') today = date.today() today = today.strftime("%d-%m-%Y") today = datetime.strptime(today, '%d-%m-%Y') rdate = date.today() + timedelta(days=30) rdate = rdate.strftime("%d-%m-%Y") if today > d2: stmt = """UPDATE transactioncount set transcount = :1,dt = to_date(:2,'dd-mm-yyyy'), renewaldate = to_date(:3,'dd-mm-yyyy') where accountid = :4""" cur.execute(stmt, { '4': customer.accountNumber, '2': today, '3': rdate, '1': 0 }) con.commit() stmt = "SELECT transcount from transactioncount where accountid= :1" cur.execute(stmt, {'1': customer.accountNumber}) res = cur.fetchall() count = int(res[0][0]) if count > 9: print('*' * 6 + "Sorry you have exhausted this month transaction limit") print("\tYou cannot deposit more, this month return next month") return 0
def check_account_status(id, pwd): stmt = "select blocked from customers where customerid=:1 and password = :2" cur.execute(stmt, {'1': id, '2': pwd}) res = cur.fetchall() if str(res[0][0]) == 'yes': return 0 elif str(res[0][0]) == 'no': return 1
def checkUserId(id): stmt = "select case when exists(select 1 from customers where customerid= :1) then 'Y' else 'N' end as rec_exists from dual" cur.execute(stmt, {'1': id}) result = cur.fetchall() result = str(result[0][0]) if result == 'N': return 0 elif result == 'Y': return 1
def check_account_blocked(id): stmt = "select case when exists(select 1 from accountclosed where accountid= :1) then 'Y' else 'N' end as rec_exists from dual" cur.execute(stmt, {'1': id}) result = cur.fetchall() result = str(result[0][0]) if result == 'Y': return 1 else: return 0
def print_statement(customer): fromDate = enter_date() toDate = enter_date() # Checking toDate is greater than fromDate if toDate > fromDate: stmt = 'select balance,dt,transtype from statementdetails where dt between :1 and :2 and accountid = :3' cur.execute(stmt, { '1': fromDate, '2': toDate, '3': customer.accountNumber }) res = cur.fetchall() if len(res) == 0: print('*' * 8 + "No transactions done") else: print("Balance\t\tDate\tTransType") for r in res: print("{b}\t\t{d}\t{t}".format(b=r[0], d=str(r[1])[0:10], t=r[2])) # For printing statement for Transferred Money stmt = "select toaccount,balance,dt,transtype from transfermoney where dt between :1 and :2 and accountid = :3" cur.execute(stmt, { '1': fromDate, '2': toDate, '3': customer.accountNumber }) res = cur.fetchall() print("Transfer:\n") if len(res) == 0: print('*' * 8 + "No transactions done") else: print("ToAccount\tBalance\tDate\tTransType") for r in res: print("{to}\t{b}\t{d}\t{t}".format(to=r[0], b=r[1], d=str(r[2])[0:10], t=r[3])) print("\n") else: print("*" * 8 + "Dates aren't valid")
def check_user_identity(id, pwd, trigger): if trigger == 0: stmt = "select case when exists(select 1 from customers where customerid= :1 and password= :2) then 'Y' else 'N' end as rec_exists from dual" cur.execute(stmt, {'1': id, '2': pwd}) elif trigger == 1: stmt = "select case when exists(select 1 from customers where customerid= :1) then 'Y' else 'N' end as rec_exists from dual" cur.execute(stmt, {'1': id}) elif trigger == 2: stmt = "select case when exists(select 1 from admins where adminid= :1 and password= :2) then 'Y' else 'N' end as rec_exists from dual" cur.execute(stmt, {'1': id, '2': pwd}) result = cur.fetchall() result = str(result[0][0]) if result == 'N': return 0 elif result == 'Y': return 1
def create_customer(id, pwd): stmt = "SELECT accounttype,fname,lname,address,city,state,pincode FROM customers where customerid= :1 and password = :2" try: cur.execute(stmt, {'1': id, '2': pwd}) res = cur.fetchall() accType = str(res[0][0]) fname = str(res[0][1]) lname = str(res[0][2]) address = str(res[0][3]) city = str(res[0][4]) state = str(res[0][5]) pin = int(res[0][6]) c = RegisteredCustomer(accType, fname, lname, address, city, state, pin, id, pwd) return c except: print("An error occurred") return
def money_withdrawal(customer): # If account type is saving then checking whether the user has exhausted this months's transaction count if customer.accountType == accountType.get(1): transaction_count = check_transaction_count(customer) if transaction_count == 0: return amount = customer.enter_amount() stmt = "SELECT balance from transactions where accountid = :1" cur.execute(stmt, {'1': customer.accountNumber}) res = cur.fetchall() a = float(res[0][0]) # Checking if balance is sufficient or not to withdraw if a >= amount: withdrawalAmount = a - 5000 # For current account holder as user needs to maintain min. 5000 # For 'Saving' account type if customer.accountType == accountType.get(1): amt = customer.money_withdrawal(amount) if amt: print("Successfully Withdrawal: " + str(amt)) # Updating transaction count if customer.accountType == accountType.get(1): stmt = "UPDATE transactioncount set transcount = transcount+1 where accountid = :1" cur.execute(stmt, {'1': customer.accountNumber}) con.commit() # Money withdrawal for Current account type if customer.accountType == accountType.get( 2) and withdrawalAmount >= amount: amt = customer.money_withdrawal(amount) if amt: print("Successfully Withdrawal: " + str(amt)) return else: print( '*' * 6 + "No sufficient funds in your account, please deposit first hello\n" ) return else: print('*' * 6 + "No sufficient funds in your account, please deposit first\n") return