def test_maxi_savings_account_with_withdrawals(): bank = Bank() checkingAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) year_behind = datetime.datetime.now() - datetime.timedelta(365) five_days_behind = datetime.datetime.now() - datetime.timedelta(5) checkingAccount.deposit(3000.0, year_behind) checkingAccount.withdraw(1000.0, five_days_behind) assert_almost_equals(bank.totalInterestPaid(), 147.97, places=2)
def test_withdrawals(): checkingAccount = Account(CHECKING) oscar = Customer("Oscar").openAccount(checkingAccount) checkingAccount.deposit(1000.0, datetime(2016, 4, 12)) checkingAccount.deposit(1000.0, datetime(2016, 4, 15)) checkingAccount.deposit(1000.0, datetime(2016, 4, 17)) assert_almost_equals(oscar.totalInterestEarned(), 0.17, places=2) checkingAccount.withdraw(1000.0, datetime(2016, 4, 19)) assert_almost_equals(oscar.totalInterestEarned(), 0.12, places=2)
def test_statement(): checkingAccount = Account(CHECKING) savingsAccount = Account(SAVINGS) henry = Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount) checkingAccount.deposit(100.0) savingsAccount.deposit(4000.0) savingsAccount.withdraw(200.0) assert_equals(henry.getStatement(), "Statement for Henry" + "\n\nChecking Account\n deposit $100.00\nTotal $100.00" + "\n\nSavings Account\n deposit $4000.00\n withdrawal $200.00\nTotal $3800.00" + "\n\nTotal In All Accounts $3900.00")
def open_account(self, account_type, initial_transaction_amount=0, initial_transaction_date = None): """ :type initial_transaction_amount: float """ account = Account(account_type) self.accounts.append(account) if initial_transaction_amount > 0: account.deposit(initial_transaction_amount, initial_transaction_date) elif initial_transaction_amount < 0: account.withdraw(-initial_transaction_amount, initial_transaction_date) return account