def __init__(self, name, age, retireAge, deadAge, incomePA, expensesPM, proportionSaved): self.name = name self.age = age self.retireAge = retireAge self.deadAge = deadAge # Education # Currently does not take user input and is hard coded in the Education Class initialisation... # Loans self.hasLoan = False self.loanDict = {} self.noLoans = 0 self.loanPaymentSum = 0 # Earnings # Income self.hasIncome = False self.incomePA = incomePA self.income = self.incomePA / 12 self.hasIncome = True # Expenses self.expenses = expensesPM # Expenses per month # Savings self.proportionSaved = proportionSaved # Inherit Loan init.. by inheriting this class, we can access it's attributes and methods... Income.__init__(self, self.income) # pass attribute to class # Init Expenses Expenses.__init__(self, self.expenses) # Init Savings Savings.__init__(self, self.proportionSaved) # Init Tax Tax.__init__(self) # Init super Superannuation.__init__(self, 0.095) # Init asset value AssetValue.__init__(self, 0.06) # Init Education Education.__init__(self) # Init Earnings Earnings.__init__(self, self.eduLevel, self.age, self.retireAge)
def withdraw_savings(self, acc_num, amount, name): self.read_file() account = Savings(name) account.acc_bal = self.accounts[acc_num]['Type']['Chequing']['Balance'] if account.withdraw(amount) == True: self.accounts[acc_num]['Type']['Savings']['Balance'] = account.acc_bal one_log = '{} ${} on {}'.format(account.transaction_log[0][0][0], account.transaction_log[0][0][1], account.transaction_log[0][1]) self.accounts[acc_num]['Type']['Savings']['Transaction Log'].append(one_log) self.write_file() return True
class TestSavingsWithOutObserver(TestCase): def setUp(self): super().setUp() self.subject = Savings(savings_observer=None) def test_present_required_earnings(self): observer = Captor() self.subject.present_required_earnings(tax_rate=35, desired_savings=1000.0, observer=observer) self.assertAlmostEqual(observer.required_earnings, 1538.4615384615388)
def main(): c1 = Checking('John', 'Doe', 5000) print(c1.balance) c1.withdraw(200) print(c1.transactions_history) print(c1.balance) s1 = Savings('Test', 'User', 1000) print(s1.balance) s1.withdraw(200) print(s1.transactions_history) print(s1.balance)
class TestSavingsWithObserver(TestCase): def setUp(self): super().setUp() self.observer = SimpleSavingsObserver() self.subject = Savings(savings_observer=self.observer) def test_present_required_earnings_with_start(self): self.subject.start() observer = Captor() self.observer.callables['my_special_function'](tax_rate=35, desired_savings=1000.0, observer=observer) self.assertAlmostEqual(observer.required_earnings, 1538.4615384615388) def test_present_required_earnings_without_start(self): self.assertIsNone( self.observer.callables.get('my_special_function', None))
def __init__(self, first, last, first_deposit): self.first = first self.last = last self.first_deposit = first_deposit self.checkings = Checkings(first_deposit) self.savings = Savings(0) self.balance = first_deposit self.trans_history = ['initial deposit of= ' + str(first_deposit)] Accounts.Account_list.append(self) Accounts.__str__(self)
from savings import Savings from tkinter_savings import TkinterSavings if __name__ == "__main__": observer = TkinterSavings() savings_application = Savings(savings_observer=observer) savings_application.start()
from savings import Savings from current import Current from account import Account def printAccountSlip(account): print("Account Balance: ", account._balance) savings1 = Savings(123, "deval", 1200) print("Number of account holders:", Account.noOfAccountHolders) current1 = Current(456, "vora", 2300) print("Number of account holders:", Account.noOfAccountHolders) printAccountSlip(savings1) printAccountSlip(current1) savings1.withdraw(20) current1.withdraw(35) printAccountSlip(savings1) printAccountSlip(current1)
#!/usr/bin/python3 # -*- coding: utf-8 -*- from savings import Savings from qt_savings import QtSavingsObserver if __name__ == '__main__': qt_savings_observer = QtSavingsObserver() savings = Savings(savings_observer=qt_savings_observer) savings.start()
#!/bin/python2 from parser import * from exchange import ExchangeRates from savings import Savings import string save = Savings() save.create('80000', '2017-03-12', '2018-03-11', '8.5', '12', True) save.create('80000', '2017-08-14', '2018-03-11', '8.5', '12', False) items = save.get_all() for i in items: print i save.get_saves_today() #s.create_table('test_table', ('name', 'text'), ('second', 'text')) #s.insert('test_table', 'some_name1', 'is_second1') #s.insert('test_table', 'some_name2', 'is_second2') #s.insert('test_table', 'some_name3', 'is_second3') #s.insert('test_table', 'some_name3', 'is_second4') #items = s.select_all('test_table') #for i in items: # print i #items = s.select_and('test_table', ('name', 'some_name3'), ('second', 'is_second4')) #for i in items: # print i #print "Enter val:" #val = raw_input() #
def setUp(self): super().setUp() self.observer = SimpleSavingsObserver() self.subject = Savings(savings_observer=self.observer)
def setUp(self): super().setUp() self.subject = Savings(savings_observer=None)
def createAccount(self, ACC_TYPE): if ACC_TYPE == "Savings": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) savings = Savings(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account self.accounts[key].append(savings) else: # key is not already in dictionary so dictionary needs to intialized and then appeneded with the key self.accounts[key] = [] self.accounts[key].append(savings) elif ACC_TYPE == "Adv.Relationship": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) advrelationship = AdvRelationship(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account self.accounts[key].append(advrelationship) else: # key is not already in dictionary so dictionary needs to intialized and then appeneded with the key self.accounts[key] = [] self.accounts[key].append(advrelationship) elif ACC_TYPE == "SafeBalance": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) safebalance = SafeBalance(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account self.accounts[key].append(safebalance) else: # key is not already in dictionary so dictionary needs to intialized and then appeneded with the key self.accounts[key] = [] self.accounts[key].append(safebalance) elif ACC_TYPE == "Adv.Plus": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) advplus = AdvPlus(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account self.accounts[key].append(advplus) else: # key is not already in dictionary so dictionary needs to intialized and then appeneded with the key self.accounts[key] = [] self.accounts[key].append(advplus) else: return "Please enter a valid account type"
def remove(self, ACC_TYPE): """Removes the account from the bank and and returns it, or None if the account does not exist.""" if ACC_TYPE == "Savings": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) savings = Savings(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account getDeleted = False for i in self.accounts[key]: if isinstance(i, Savings): self.accounts[key].remove(i) getDeleted = True # this for loop searches through the dictionary and if it exist it is removed from the dictionary and getDeleted becomes true if getDeleted == False: return "Account not found" else: return "Account deleted" else: return "Error: User not a customer" elif ACC_TYPE == "Adv.Relationship": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) advrelationship = AdvRelationship(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account getDeleted = False for i in self.accounts[key]: if isinstance(i, AdvRelationship): self.accounts[key].remove(i) getDeleted = True if getDeleted == False: return "Account not found" else: return "Account deleted" else: return "Error: User not a customer" elif ACC_TYPE == "SafeBalance": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) safebalance = SafeBalance(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account getDeleted = False for i in self.accounts[key]: if isinstance(i, SafeBalance): self.accounts[key].remove(i) getDeleted = True if getDeleted == False: return "Account not found" else: return "Account deleted" else: return "Error: User not a customer" elif ACC_TYPE == "Adv.Plus": rewards_member = bool( input("Please enter true if you are a rewards_member: ")) name = str(input("Please enter your first name: ")) pin = str(input("Please enter four digit pin: ")) balance = float( input("Please enter the starting balance of your account: ")) student = bool( input( "Please enter true if you are a student of some sort under the age of 24: " )) advplus = AdvPlus(rewards_member, student, name, pin, balance) key = self.makeKey(name, pin) if key in self.accounts: # checks to see if the user already has an account because if their key is already in the dictionary it means they have an account getDeleted = False for i in self.accounts[key]: if isinstance(i, AdvPlus): self.accounts[key].remove(i) getDeleted = True if getDeleted == False: return "Account not found" else: return "Account deleted" else: return "Error: User not a customer" else: return "Please enter a valid account type"