From 08ef5b42c6dbbe34727c70b5bc283e18d577fe0f Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:37:38 -0400 Subject: [PATCH 1/7] Update account.py --- abcbank/account.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/abcbank/account.py b/abcbank/account.py index e010009..3efc760 100644 --- a/abcbank/account.py +++ b/abcbank/account.py @@ -1,4 +1,5 @@ from abcbank.transaction import Transaction +from datetime import datetime, timedelta CHECKING = 0 SAVINGS = 1 @@ -23,21 +24,22 @@ def withdraw(self, amount): self.transactions.append(Transaction(-amount)) def interestEarned(self): + ##change to include rule for maxi savings where interest is 5% if no withdraw in past 10 days, else 0.1% amount = self.sumTransactions() if self.accountType == SAVINGS: if (amount <= 1000): - return amount * 0.001 + return amount * (0.001/365.25) else: - return 1 + (amount - 1000) * 0.002 + return 1 + (amount - 1000) * 0.002/365.25 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 + todaysDate=datetime.now() + withdrawTransactions=[t.transactionDate for t in self.transactions if t.amount<0] ##get list withdraw transactions as amount < zero. + if len(withdrawTransactions)>0: + if (withdrawTransactions[-1]>(todaysDate-timedelta(days=10))): + return amount * 0.001/365.25 + return amount * 0.05/365.25 else: - return amount * 0.001 + return amount * 0.001/365.25 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]) From 54fb9d55e2fa8b5f9f14a323fadc350fcb3976f2 Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:38:28 -0400 Subject: [PATCH 2/7] Update customer.py --- abcbank/customer.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/abcbank/customer.py b/abcbank/customer.py index 7cfd62a..ee68961 100644 --- a/abcbank/customer.py +++ b/abcbank/customer.py @@ -16,6 +16,16 @@ def numAccs(self): def totalInterestEarned(self): return sum([a.interestEarned() for a in self.accounts]) + def accountTransfer(self, fromAccount, toAccount, amount): + ##create account transfer system where users can withdraw from one account and deposit into another account within the banking system + if fromAccount not in self.accounts: + return 0.0 #only perform transfer if user owns both accounts + if toAccount not in self.accounts: + return 0.0 + fromAccount.withdraw(amount) + toAccount.deposit(amount) + return amount + # This method gets a statement def getStatement(self): # JIRA-123 Change by Joe Bloggs 29/7/1988 start From c5da708ba82ce913f80389edd904f3cac7512d1e Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:39:34 -0400 Subject: [PATCH 3/7] Update bank_tests.py --- tests/bank_tests.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/bank_tests.py b/tests/bank_tests.py index 6de98db..ed3aec2 100644 --- a/tests/bank_tests.py +++ b/tests/bank_tests.py @@ -19,7 +19,7 @@ def test_checking_account(): bill = Customer("Bill").openAccount(checkingAccount) bank.addCustomer(bill) checkingAccount.deposit(100.0) - assert_equals(bank.totalInterestPaid(), 0.1) + assert_equals(bank.totalInterestPaid(), 0.1/365.25) def test_savings_account(): @@ -27,7 +27,7 @@ def test_savings_account(): checkingAccount = Account(SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) checkingAccount.deposit(1500.0) - assert_equals(bank.totalInterestPaid(), 2.0) + assert_equals(bank.totalInterestPaid(), 1 + (1500 - 1000) * 0.002/365.25) def test_maxi_savings_account(): @@ -35,4 +35,29 @@ def test_maxi_savings_account(): checkingAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) checkingAccount.deposit(3000.0) - assert_equals(bank.totalInterestPaid(), 170.0) \ No newline at end of file + assert_equals(bank.totalInterestPaid(), 150.0/365.25) + + +def test_maxi_savings_withdraw(): + bank = Bank() + checkingAccount = Account(MAXI_SAVINGS) + bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) + checkingAccount.deposit(3000.0) + checkingAccount.withdraw(10) + assert_equals(bank.totalInterestPaid(), (3000.0-10.0)*0.001/365.25) + + + +def testAccountTransfer(): + bank = Bank() + checkingAccount = Account(CHECKING) + bill = Customer("Bill").openAccount(checkingAccount) + bank.addCustomer(bill) + checkingAccount.deposit(100.0) + savingAccount = Account(SAVINGS) + bill.openAccount(savingAccount ) + savingAccount.deposit(10000) + bill.accountTransfer(savingAccount, checkingAccount, 500) + assert_equals(checkingAccount.sumTransactions(), 600.0) + + From 184c11c7c33bea37692d4b53910e4ef11c58c170 Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:40:37 -0400 Subject: [PATCH 4/7] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 756dd11..b45df25 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ A dummy application for a bank; should provide various functions of a retail ban ### Additional Features + * A customer can transfer between their accounts + **Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py * Change **Maxi-Savings accounts** to have an interest rate of 5% assuming no withdrawals in the past 10 days otherwise 0.1% -* Interest rates should accrue daily (incl. weekends), rates above are per-annum \ No newline at end of file + **Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py +* Interest rates should accrue daily (incl. weekends), rates above are per-annum + **Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily. From f87836c545bd7dbc44b0c69d2927981804245d3f Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:41:12 -0400 Subject: [PATCH 5/7] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b45df25..898638c 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,12 @@ A dummy application for a bank; should provide various functions of a retail ban * A customer can transfer between their accounts - **Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py + +**Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py * Change **Maxi-Savings accounts** to have an interest rate of 5% assuming no withdrawals in the past 10 days otherwise 0.1% + **Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py -* Interest rates should accrue daily (incl. weekends), rates above are per-annum +* +Interest rates should accrue daily (incl. weekends), rates above are per-annum + **Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily. From 3b5eaa72421272555033f0da49176b19d0a0a8e5 Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:42:06 -0400 Subject: [PATCH 6/7] Update README.md --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 898638c..0c69d3d 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,9 @@ A dummy application for a bank; should provide various functions of a retail ban * A customer can transfer between their accounts - -**Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py + *Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py * Change **Maxi-Savings accounts** to have an interest rate of 5% assuming no withdrawals in the past 10 days otherwise 0.1% - **Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py -* -Interest rates should accrue daily (incl. weekends), rates above are per-annum - - **Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily. + *Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py +* Interest rates should accrue daily (incl. weekends), rates above are per-annum + *Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily. From aec3d015f5c25542338e9a20ae527753519ee544 Mon Sep 17 00:00:00 2001 From: derekawilson72 Date: Fri, 20 May 2016 08:42:48 -0400 Subject: [PATCH 7/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c69d3d..0b1568c 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ A dummy application for a bank; should provide various functions of a retail ban * A customer can transfer between their accounts - *Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py + * Done with accountTransfer function in the customer.py Customer class. Users must own both the from account and to account. Tested with the testAccountTransfer function in bank_tests.py * Change **Maxi-Savings accounts** to have an interest rate of 5% assuming no withdrawals in the past 10 days otherwise 0.1% - *Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py + * Done with the interestEarned function in account.py that tests if the last withdraw(amount <0) transaction occured less than 10 days ago for maxi savings. Tested with the test_maxi_savings_account and test_maxi_savings_withdraw functions within the bank_tests.py * Interest rates should accrue daily (incl. weekends), rates above are per-annum - *Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily. + * Done with the interestEarned function in account.py that will divide the annual interest rate by 365.25. This assuming that the interestEarned function will be executed once daily.