@@ -10,26 +10,31 @@ def __init__(self, balance=0, interest_rate=0.001):
10
10
def check_balance (self ):
11
11
"""Returns the account balance."""
12
12
self .transactions .append ({'Date' : datetime .now ().strftime (
13
- "%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'Checked Balance ' , 'balance' : self .balance })
13
+ "%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'checked balance ' , 'balance' : self .balance })
14
14
return self .balance
15
15
16
16
def deposit (self , amount ):
17
17
"""Deposits the given amount in the account."""
18
18
previous_balance = self .balance
19
19
self .balance += amount
20
- self .transactions .append ({'Date' : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'Deposit ' ,
20
+ self .transactions .append ({'Date' : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'deposit ' ,
21
21
'amount' : amount , 'previous_balance' : previous_balance , 'new_balance' : self .balance })
22
22
return self .balance
23
23
24
24
def check_withdrawal (self , amount ):
25
25
"""Returns true if the withdrawn amount won't put the account in the negative"""
26
- return self .balance - amount >= 0
26
+ if self .balance - amount >= 0 :
27
+ return True
28
+ else :
29
+ self .transactions .append ({'date' : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'Withdrawal' , 'result' : 'insufficient funds' ,
30
+ 'amount' : amount , 'balance' : self .balance })
31
+ return False
27
32
28
33
def withdraw (self , amount ):
29
34
"""Withdraws the amount from the account and returns it."""
30
35
previous_balance = self .balance
31
36
self .balance -= amount
32
- self .transactions .append ({'Date ' : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'Withdrawal' ,
37
+ self .transactions .append ({'date ' : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), 'transaction_type' : 'Withdrawal' ,
33
38
'amount' : amount , 'previous_balance' : previous_balance , 'new_balance' : self .balance })
34
39
return self .balance
35
40
0 commit comments