diff --git a/abcbank/account.py b/abcbank/account.py index e010009..f2bd871 100644 --- a/abcbank/account.py +++ b/abcbank/account.py @@ -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() @@ -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]) \ No newline at end of file + return sum([t.amount for t in self.transactions]) + + def getBalance(self): + return self.balance