Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions abcbank/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@

class Account:
def __init__(self, accountType):
self.accountType = accountType
self.transactions = []
self.accountNo = accountNo
self.accountType = accountType
self.balance = 0
self.transactions = []
self.latestWithdrawDate = DateProvider.today()

def deposit(self, amount):
if (amount <= 0):
raise ValueError("amount must be greater than zero")
else:
self.transactions.append(Transaction(amount))
self.balance += amount

def withdraw(self, amount):
if (amount <= 0):
raise ValueError("amount must be greater than zero")
else:
self.transactions.append(Transaction(-amount))
self.balance -= amount
self.latestWithdrawDate = DateProvider.today();

def interestEarned(self):
amount = self.sumTransactions()
Expand All @@ -30,14 +36,20 @@ def interestEarned(self):
else:
return 1 + (amount - 1000) * 0.002
if self.accountType == MAXI_SAVINGS:
if (amount <= 1000):
return amount * 0.02
elif (amount <= 2000):
return 20 + (amount - 1000) * 0.05
else:
return 70 + (amount - 2000) * 0.1
if self.accountType == MAXI_SAVINGS:
today = DateProvider.today()
withdrawPassedDays = today - self.latestWithdrawDate;
listDaysStr = str(withdrawPassedDays).split()
numDays = int(listDaysStr)
if (numDays > 10):
return amount * 0.05
else:
return amount * 0.001
else:
return amount * 0.001

def sumTransactions(self, checkAllTransactions=True):
return sum([t.amount for t in self.transactions])
return sum([t.amount for t in self.transactions])

def getBalance(self):
return self.balance