Beispiel #1
0
def populate_database():
    """Populate the database."""
    emp = Employees(123456, 'Sammy', 'Retail Applications', 'IT Analyst')
    emp1 = Employees(5678, 'Nancy', 'Capital Market', 'Teller')
    emp.create_employees()
    emp1.create_employees()

    cust = Customer(123, 'John', '*****@*****.**', '1-233-2234')
    cust1 = Customer(5678, 'Katherine', '*****@*****.**', '1-456-4578')
    cust2 = Customer(6788, 'Vijay', '*****@*****.**', '1-678-5555')
    cust.create_customer()
    cust1.create_customer()
    cust2.create_customer()

    bank_Acc = BankAccount(1234444, 123, 'Chequing', 100)
    bank_Acc.create_Bank_Account()

    bank_Acc1 = BankAccount(567888, 5678, 'Saving', 200)
    bank_Acc1.create_Bank_Account()

    bank_Acc2 = BankAccount(1677777, 6788, 'Chequing', 400)
    bank_Acc2.create_Bank_Account()

    creditCard = CreditCard('Ms', 'Nancy', 'Smith', '15 Bloor St, Toronto',
                            14566666, 'May', 2023, '677', 'Visa', 'CAD')
    creditCard.create_Credit_Account()
    creditCard1 = CreditCard('Mr', 'Sam', 'Rogers', '15 Upland St, Toronto',
                             8999666, 'Aug', 2021, '127', 'Visa', 'CAD')
    creditCard1.create_Credit_Account()
Beispiel #2
0
    def test_deposit(self):
        dep_1 = BankAccount("gigi").deposit(2000)
        dep_2 = BankAccount("gigi").deposit(3000)
        dep_3 = BankAccount("gigi").deposit(-6000)

        self.assertEqual(dep_1, "The amount you want to deposit is $2000.00")
        self.assertEqual(dep_2, "The amount you want to deposit is $3000.00")
        self.assertEqual(dep_3, "The amount you entered is incorrect!")
Beispiel #3
0
 def test_withdraw(self):
     widraw_1 = BankAccount("gigi").withdraw(1000)
     widraw_2 = BankAccount("gigi").withdraw(3000)
     self.assertEqual(
         widraw_1,
         "The amount of $1000.00 had been withdrawed from your account! \n"
         "Your Balance is $1000.00")
     self.assertEqual(widraw_2,
                      "The amount you entered is grater than the balance!")
     with self.assertRaises(ValueError):
         BankAccount("gigi").withdraw(-6000)
Beispiel #4
0
 def parse_text_file(self, text_file):
     bank_account = BankAccount()
     for row_index, row in enumerate(text_file):
         if (row_index + 1) % 4 == 0:
             self.accounts.append(bank_account)
             bank_account = BankAccount()
         else:
             strip_row = row.rstrip()
             for digit_index, index in enumerate(range(
                     0, len(strip_row), 3)):
                 value = list(strip_row[index:index + 3])
                 if len(value) < 3:
                     value.append(' ')
                 bank_account.set_row(digit_index=digit_index,
                                      row_index=row_index % 4,
                                      value=value)
Beispiel #5
0
    def load_records(database_file):
        """\
        Opens the specified local database file with the bank account records and store the
        records in-memory for usage with the aid of the dictionary data structure.

        Checks that the argument 'database_file' passed in is of type 'str' else an 'Exception' is raised.

        If the specified database file doesn't exist an 'Exception' is raised.

        :param database_file: Name of the database file to load records from
        :return: Dictionary data structure with the bank account records
        """
        if type(database_file) != str:
            raise Exception(
                "Invalid argument: database_file of type {} should be: <class 'str'>"
                .format(type(database_file)))
        database = DatabaseConnection(database_file)
        records = dict()
        result_set = database.sql_statement(database.READ,
                                            "SELECT * FROM accounts")
        for record in result_set:  # grab each record from the result-set
            records[record[4]] = BankAccount(record[0], record[1], record[2],
                                             record[3])
        database.close()
        return records
Beispiel #6
0
def create_account():
    b = {'b': "Bank Account",
         'l': "Loan Account",
         'c': "Credit Card",
         'e': "Expense Account",
         'i': "Insurance Account" }
    print("Creating Account", b)
    key = readchar.readkey()
    acnt = None

    if key == 'b':
        acnt = BankAccount()
        acnt.populate()
    elif key == 'l':
        acnt = LoanAccount()
        acnt.populate()
    elif key == 'c':
        acnt = CreditCard()
        acnt.populate()
    elif key == 'e':
        acnt = ExpenseAccount()
        acnt.populate()
    elif key == 'i':
        acnt = Insurance()
        acnt.populate()
    else:
        return

    acnt.save()
Beispiel #7
0
 def createBankAccount(self, name, acctType, balance=0):
     accountNum = self.__getNextAccountNum()
     if accountNum in self.__bankAccounts:
         return DUPLICATE_NUMBER
     newBankAccount = BankAccount(accountNum, name, acctType, name)
     self.__bankAccounts[accountNum] = newBankAccount
     return accountNum
Beispiel #8
0
 def create_account(self, first_name: str, last_name: str,
                    initial_deposit: float, preferred_tz) -> BankAccount:
     self._last_account_number += 1
     new_account = BankAccount(first_name, last_name,
                               self._last_account_number, initial_deposit,
                               preferred_tz)
     self._active_accounts.append(new_account)
     return new_account
Beispiel #9
0
 def setUp(self):
     self.name = "Rado"
     self.amount = 0
     self.currency = '$'
     self.my_account = BankAccount(self.name, self.amount, self.currency)
     self.deposited_money = 1000
     self.deposited_money_negative = -1000
     self.withdrawed_money_true = 500
     self.withdrawed_money_false = 1000
     self.transfered_money_true = 500
     self.transfered_money_false = 2000
Beispiel #10
0
def bankAccountCreate(bankAccount):
    b = bankAccount
    dbAcnt = BankAccount(name=b['name'],
                         description=b['description'],
                         bankName=b['bankName'],
                         ifscCode=b['ifscCode'],
                         accountNumber=b['accountNumber'],
                         interestRate=b['interestRate'],
                         mab=b['mab']).save()

    print("BankAccount", colored(dbAcnt.name), "created")
Beispiel #11
0
def main():
    populate_database()
    while True:
        try:
            # To Test please use 123,5678 or 6788
            customer_id = input(
                "Please enter customer ID, Use Cust_id=123 or 5678 or 6788: ")
            if not customer_id:
                break
            choice = int(input("Please enter 1-Deposit or 2-Withdraw: "))
            if choice == 1:
                b = BankAccount(cust_id=customer_id)
                amt = int(input("Please enter the amount to deposit: "))
                b.deposit(cust_id=customer_id, amount=amt)

            elif choice == 2:
                b = BankAccount(cust_id=customer_id)
                amt = int(input("Please enter the amount to withdraw: "))
                b.withdraw(cust_id=customer_id, amount=amt)
        except ValueError:
            print("Oops!  Invalid values  Try again...")
Beispiel #12
0
 def __init__(self,db_file):
     ''' (Bank,str)-> NoneType
     initialize the Bank database from a file given as argument
     '''
     self._database = set()
     handle = open(db_file,"r")
     lines = handle.readlines()
     for line in lines:
         data = line.split(",")
         p = Person(data[0],data[1],data[2])
         a = BankAccount(p)
         a.credit(int(data[3]))
         self._database.add(a)
Beispiel #13
0
def create_account(user_name, initial_deposit, password):
    """
    :param user_name: User name to create a Bank Account for
    :param initial_deposit: The initial amount user wants to deposit into account
    :return: None
    """
    bank_acc = BankAccount(user_name, initial_deposit, password)
    accounts[user_name] = bank_acc

    print("\nThank you! Here is your Bank info: ")
    print("Name: {}".format(bank_acc.name.title()))
    print("Acccount Number: {}".format(bank_acc.accnum))
    print("Balance: ${:.2f}\n\n".format(int(bank_acc.balance)))
Beispiel #14
0
 def test_history(self):
     # Account Creation
     self.assertEqual(self.my_account.history()[0], 'Account was created')
     # Deposit
     self.my_account.deposit(1000)
     trueString = 'Deposited 1000' + self.my_account.currency
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Balance
     self.my_account.balance()
     trueString = 'Balance check -> ' + \
         str(self.my_account.balance()) + self.my_account.currency
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Int transformation
     trueString = '__int__ check -> ' + \
         str(self.my_account.balance()) + self.my_account.currency
     int(self.my_account)
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Successfull withdraw
     self.my_account.withdraw(500)
     trueString = '500' + self.my_account.currency + \
         ' was withdrawed'
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Failed withdraw
     self.my_account.withdraw(1000)
     trueString = 'Withdraw for {}{} failed.'.format(
         1000, self.my_account.currency)
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Transfer
     ivo = BankAccount("Ivo", 0, "$")
     self.my_account = BankAccount("Rado", 1000, "$")
     self.my_account.transfer_to(ivo, 500)
     trueString_Rado = 'Transfer to {} for {}{}'.format(
         ivo.name, 500, self.my_account.currency)
     trueString_Ivo = 'Transer from {} for {}{}'.format(
         self.my_account.name, 500, ivo.currency)
     self.assertEqual(self.my_account.history()[-1], trueString_Rado)
     self.assertEqual(ivo.history()[-1], trueString_Ivo)
Beispiel #15
0
 def test_transfer_to(self):
     self.my_account.amount = 1000
     # CHECK CURRENCY
     ivo = BankAccount("Ivo", 0, "BGN")
     self.assertFalse(self.my_account.transfer_to(ivo, 600))
     ivo.currency = '$'
     # CHECK IF MONEY IS ENOUGH
     self.assertFalse(
         self.my_account.transfer_to(ivo, self.transfered_money_false))
     self.assertTrue(
         self.my_account.transfer_to(ivo, self.transfered_money_true))
     # CHECK IF MONEY HAS CHANGED, TRANSFERED
     ivo.amount = 0
     self.my_account.amount = 1000
     self.my_account.transfer_to(ivo, 200)
     self.assertEqual(self.my_account.balance(), 800)
     self.assertEqual(ivo.balance(), 200)
Beispiel #16
0
def _account_selection(account_names, accounts):
    choice = raw_input('Welcome to the Family Banking App. Who is this?')
    if choice not in account_names:
        print(
            'This person does not have an account. The people with accounts are: '
            + ', '.join(account_names) + '.')
        new_account = _request_user_input(
            'Do you wish to make an account for ' + choice + '? (Y/N)',
            ['Y', 'N'], 'Invalid response. Try again.')
        if new_account == 'Y':
            amount_to_deposit = raw_input(
                'How much would you like to deposit in this (' + choice +
                '\'s) account?')
            accounts.append(BankAccount(choice, float(amount_to_deposit)))
            account_names.append(choice)
            return choice
        else:
            print('Try again, then. Who is this?')
            choice = _account_selection(account_names, accounts)
        return choice
    return choice
from BankEmpire import BankEmpire
from Bank import Bank
from Customer import Customer
from HighNetWorthCustomer import HighNetWorthCustomer
from BankAccount import BankAccount
from datetime import datetime as dt

ianbotzEmpire = BankEmpire('The Ianbotz Bank Empire')
'''''' '''''' '''''' '''''' '''''' '''''' ''''''
iBank1 = Bank('Lavender Side Bank')

georgeCustomer = Customer('George Curious', 23, 60_000,
                          BankAccount(balance=130))
stevenCustomer = HighNetWorthCustomer('Steven Hillborough', 78, 3_200_000,
                                      BankAccount(balance=36_000_000),
                                      'Exchange Traded Funds', dt(1942, 3, 26))

iBank1.addCustomer(georgeCustomer)
iBank1.addCustomer(stevenCustomer)

ianbotzEmpire.addBank(iBank1)
'''''' '''''' '''''' '''''' '''''' '''''' ''''''
iBank2 = Bank('Mason Hill Bank')

williamCustomer = Customer('William Blake', 18, 40_000,
                           BankAccount(balance=200))
joshCustomer = Customer('Josh Maven', 35, 80_000, BankAccount(balance=30_000))
ronaldCustomer = HighNetWorthCustomer('Ronald McDonald', 68, 128_200_000,
                                      BankAccount(balance=1_200_000_000),
                                      'Foreign Exchange Market',
                                      dt(1950, 8, 2))
 def __init__(self, name, email):
     self.name = name
     self.email = email
     self.account = BankAccount()
Beispiel #19
0
        else:
            print('out of stock')

    @property
    def price(self):
        return self._price

    @price.setter
    def price(self, x):
        if 50 < x < 1000:
            self._price = x
        else:
            raise ValueError('asdasd')


a = BankAccount('fayed', 200)
a.display()
book1 = Book('957-4-36-547417-1', 'Learn Physics', 'Stephen', 'CBC', 350, 200,
             10)
book2 = Book('652-6-86-748413-3', 'Learn Chemistry', 'Jack', 'CBC', 400, 220,
             20)
book3 = Book('957-7-39-347216-2', 'Learn Maths', 'John', 'XYZ', 500, 300, 5)
book4 = Book('957-7-39-347216-2', 'Learn Biology', 'Jack', 'XYZ', 400, 200, 6)
book1.display()
book1.sell()
books = [book1, book2, book3, book4]
for i in range(4):
    books[i].display()
book_title_list = [books[i].title for i in range(4)]
print(book_title_list)
a = Fraction(-2)
Beispiel #20
0
Datei: ATM.py Projekt: idobsh/ATM
            if amount is 0:
                break
            if self.account.withdraw(amount):
                print "Success"
                break
            else:
                pass


def checkForInt(message):
    while True:
        choice = raw_input(message)
        if choice.isdigit():
            break
        else:
            print "The input you entered is not valid, Numbers only please!"

    return choice


if __name__ == "__main__":
    a = Bank()
    b = BankAccount("Ido", "1111")
    c = BankAccount("Arbel", "2222")

    a.addAccount(b)
    a.addAccount(c)

    d = ATM(a)
    d.startMenu()
Beispiel #21
0
 def setUp(self):  # test fixture
     # print('setup called')
     self.ing = BankAccount('mila', 500)
     self.bnp = BankAccount('alex', 2000)
from BankAccount import BankAccount
from random import randint

path = 'bank_accounts.txt'

Dom = BankAccount('Dom', randint(-1000, 1000))
Lex = BankAccount('Lex', randint(-1000, 1000))
Dan = BankAccount('Dan', randint(-1000, 1000))
Henry = BankAccount('Henry', randint(-1000, 1000))
Bill = BankAccount('Bill', randint(-1000, 1000))

with open(path, 'w') as f:
    for person in [Dom, Lex, Dan, Henry, Bill]:
        f.write('%s: %d \n' % (person.get_name(), person.get_balance()))
    f.close()

Beispiel #23
0
from BankAccount import BankAccount

# Create a new instance of BankAccount
newAccount = BankAccount()
# open a new file
bankFile = open("AccountSummary_AlanVenneman.txt", "w")
bankFile.write("### Welcome to Acme Bank ###\n")
# Ask user for initial deposit
newAccount.setBalance(eval(input("Enter opening balance: ")))
bankFile.write("Opening balance for February: ${:.2f}\n".format(
    newAccount.getBalance()))
# Ask user for additional deposits
deposits = 0.0
print("Enter deposits first, type the number 0 after final entry.")
while (deposits != -1):
    deposits = newAccount.setDeposit(float(input("Enter deposit: ")))
    if (deposits != -1):
        bankFile.write(str(deposits) + '\n')
    else:
        bankFile.write("Your Deposits: ${:.2f}\n".format(
            newAccount.getDeposit()))
# Ask user for a withdrawal
withdrawals = 0
print("Enter withdrawals second, type the number 0 after final entry.")
while withdrawals > -1:
    withdrawals = newAccount.setWithdraw(float(input("Enter withdrawal: ")))
    if withdrawals != -1:
        bankFile.write("Your Withdrawals: ${:.2f}\n".format(
            newAccount.getWithdraw()))
# Print closing Amount
bankFile.write("Your final balance today is: ${:.2f}\n".format(
Beispiel #24
0
 def setUp(self):
     self.my_account = BankAccount(90)
Beispiel #25
0
# Class: 1321L
# Sec: 02
# Lab: Python
# Term: Fall 2018
# Instructor: Malcolm
# Name: Ly Pham

from BankAccount import BankAccount

myObject = BankAccount()
myObject.setID(123456)
myObject.setbalance(10000)
myObject.withdraw(3500)
myObject.deposit(500)
myObject.setannualInterestRate(2.50)
print(myObject.toString())

Beispiel #26
0
from BankAccount import BankAccount
# ||===========================================||
# ||             Main Function                 ||
# ||===========================================||

# user input of their current balance
currentBalance = float(input('Enter your current Balance:'))

# initializing the bank account with the courrent balance
my_account = BankAccount(currentBalance)

# if the initial balance is nonzero
if float(my_account.balance) > 0.00:

    # Option for user to select what they want to do
    print(' OPTIONS:\n'
          '1. Check Balance \n'
          '2. Deposit \n'
          '3. Withdraw \n'
          '4. Spend \n')
    choice = input("what is your choice from the above options: ")
    print("you chose OPTION #: ", choice)

    # User chooses to view balance
    if choice is '1':

        # prints the current balance of the Account
        print("You have: $", my_account.balance, "in your bank Account")

        # end the transaction or keep going
        keepGo = input("Are you done with your transaction?:\n"
Beispiel #27
0
from AccountException import AccountException
from Bank import Bank
from BankAccount import BankAccount
from BankAccount_INT import BankAccount_INT
from BankAccount_COVID19 import BankAccount_COVID19
from BankAccount_COVID19_company import BankAccount_COVID19_company

bank = Bank()
pl_01 = BankAccount('PL_01', 10000)
int_01 = BankAccount_INT('INT_01', 10000)
covid_01 = BankAccount_COVID19('COVID_01', 10000)
company_01 = BankAccount_COVID19_company('COMPANY_01', 10000)

for account in [pl_01, int_01, covid_01, company_01]:
  bank.add(account)
 
print(bank)

# BankAccount
print()
pl_01.deposit(200)
pl_01.withdraw(300)
print(pl_01)

try:
  pl_01.withdraw(50000)
except AccountException as e:
  print('Error:', e)

print()
print(pl_01)
Beispiel #28
0
from BankAccount import BankAccount
from AccountManager import AccountManager

account1 = BankAccount("Giovanni", "1", 1000)
account1.accountInfo()

account2 = BankAccount("Marco", "2", 500)
account2.accountInfo()

res = AccountManager.bankTransfer(account1, account2, 100)
print(str(res))

account1.accountInfo()
account2.accountInfo()


 def add_account(self, customer_id, name, init_balance):
     self.account_list.append(BankAccount(customer_id, name, init_balance))
Beispiel #30
0
    def test_show_balance(self):
        show_1 = BankAccount("gigi").show_balance()

        self.assertEqual(show_1, "Your Balance is $2000.00")