Data.Account
index
/home/flempriere/personal_projects/Languages/Python/BeginToCodeWithPython/03_UsefulPython/13_PythonAndGraphicalUserInterfaces/Exercises/03_GraphicalBankingApplication/Data/Account.py

Exercise 13.3a Account
 
Provides implementations for representing an individual account
 
Classes
-------
Account
    abstract base class for a bank account
SavingsAccount
    class representing a simple savings account in which money can be deposited or withdrawn and interest is accrued monthly
CreditAccount
    class representing a simple credit account in which loans can be withdrawn or paid off and interest is accrued monthly
LongTermSavingsAccount
    class representing a long-term deposit in which additional monthly interest is accrued in exchange for restrictions
    on withdrawals
 
Variables
---------
account_dictionary : dict[str, Account]
    dictionary mapping a human readable string of account types to the class

 
Modules
       
abc
datetime

 
Classes
       
abc.ABC(builtins.object)
Account
CreditAccount
SavingsAccount
LongTermSavingsAccount

 
class Account(abc.ABC)
    Account(account_number, account_holder, interest_rate)
 
Abstract class representing a single account
 
Subclasses are expected to overwrite the `deposit`,
`withdraw` and `apply_interest` abstract methods
 
Attributes:
-----------
account_holder : str
    name of the account owner
interest_rate : int | float
    monthly interest rate applied to the account
 
Class Attributes
----------------
account_type : str
    human readable string encoding the account type, should be
    overwritten by subclasses
 
 
Method resolution order:
Account
abc.ABC
builtins.object

Methods defined here:
__init__(self, account_number, account_holder, interest_rate)
Creates a new `Account` instance
 
`Account` is abstract and should never be called directly
 
Parameters
----------
account_number : str
    Unique account number
account_holder : str
    Name of the account holder
interest_rate : int | float
    monthly interest rate applied to the account
__str__(self)
Return str(self).
apply_interest(self)
Apply the interest rate to the account and update the balance
 
Returns
-------
None
deposit(self, amount)
Deposit money in an account
 
Parameters
----------
amount : int | float
    amount in dollars to deposit in the account
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` cannot be deposited
withdraw(self, amount)
Withdraw money from an account
 
Parameters
----------
amount : int | float
    amount to withdraw from the account in dollars
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` cannot be withdrawn

Readonly properties defined here:
account_number
account_number : str
    Unique account number
balance
balance: int | float
    account balance in dollars

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Data and other attributes defined here:
__abstractmethods__ = frozenset({'apply_interest', 'deposit', 'withdraw'})
account_type = 'Account'

 
class CreditAccount(Account)
    CreditAccount(account_number, account_holder, interest_rate, max_withdrawal_limit)
 
Represents a basic credit account
 
Savings accounts must have non-positive balances, and
charge interest on their debts
 
See Also
--------
Account : Parent Class
 
 
Method resolution order:
CreditAccount
Account
abc.ABC
builtins.object

Methods defined here:
__init__(self, account_number, account_holder, interest_rate, max_withdrawal_limit)
Creates a new `CreditAccount` instance
 
Parameters
----------
account_number : str
    Unique account number
account_holder : str
    Name of the account holder
interest_rate : int | float
    interest rate applied to the account
max_withdrawal_limit : int | float
    maximum account that can be loaned out at once
__str__(self)
Return str(self).
apply_interest(self)
Applies interest to any loans
 
Returns
-------
None
deposit(self, amount)
Pay off a Credit loan
 
Parameters
----------
amount : int | float
    amount to pay off in dollars
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` is not a positive integer
ValueError
    Raised if deposit is greater than the current debt
withdraw(self, amount)
Take out a loan of credit
 
Parameters
----------
amount : int | float
    amount to loan from the account in dollars
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` is non-negative or the greater than
    the account balance

Readonly properties defined here:
maximum_withdrawal_limit
maximum_withdrawal_limit : int | float
    maximum amount that can be withdrawn in dollars

Data and other attributes defined here:
__abstractmethods__ = frozenset()
account_type = 'Credit Account'

Readonly properties inherited from Account:
account_number
account_number : str
    Unique account number
balance
balance: int | float
    account balance in dollars

Data descriptors inherited from Account:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class LongTermSavingsAccount(SavingsAccount)
    LongTermSavingsAccount(account_number, account_holder, interest_rate, term_period_in_weeks)
 
Represents a long term savings account
 
An account in which money cannot be withdrawn before the term limit expires.
After the term limit has expired a reduced interest rate is applied.
 
Class Attributes
----------------
min_term_limit: int
    minimum term limit in weeks
max_term_limit: int
    maximum term limit in weeks
 
See Also
--------
SavingsAccount : Parent class
 
 
Method resolution order:
LongTermSavingsAccount
SavingsAccount
Account
abc.ABC
builtins.object

Methods defined here:
__init__(self, account_number, account_holder, interest_rate, term_period_in_weeks)
Creates a new `LongTermSavingsAccount` instance
 
Parameters
----------
account_number : str
    Unique account number
account_holder : str
    Name of the account holder
interest_rate : int | float
    interest rate applied to the account
term_period_in_weeks : int
    length of the high yield savings term in weeks
__str__(self)
Return str(self).
apply_interest(self)
Apply interest to a Long Term Savings Account
 
The applied interest for a Long Term Savings account is quartered
if the account has matured
 
Returns
-------
None
has_matured(self)
Indicates if an account has matured
 
Returns
-------
`True` if the account has matured else, `False`
manage_account(self, transfer_account=None)
Manage a matured long term savings account
 
A mature long term savings account can be closed
by providing an alternate account to transfer the
balance into. Alternately if no account is provided
the account is reinvested and a new term starts.
 
The owner of the long term savings account and the
account to transfer into must be the same
 
Parameters
----------
transfer_account : Account, optional
    account to transfer into, pass None to reinvest instead, by default None
 
Returns
-------
None
 
Raises
------
ValueError
    Raised in attempting to manage an immature account
ValueError:
    Could not transfer to the new account
withdraw(self, amount)
Withdraw money from a Long Term Savings Account
 
Money cannot be withdrawn unless the account has matured
 
Parameters
----------
amount : int | float
    amount to withdraw from the account in dollars
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` is non-negative or the greater than
    the account balance.
ValueError
    Raised if the account has not
    yet matured

Static methods defined here:
validate_term_limit(term_limit)
Validates a proposed term limit
 
Parameters
----------
term_limit : int
    proposed term limit in weeks
 
Returns
-------
bool
    `True` if the proposed term limit is valid, else `False`

Readonly properties defined here:
maturation_date
maturation_date : datetime.date
    date the account matures
start_date
start_date : datetime.date
    date the current term period started
term_period
term_period : int
    length of the term in weeks

Data and other attributes defined here:
__abstractmethods__ = frozenset()
account_type = 'Long Term Savings Account'
max_term_limit = 156
min_term_limit = 12

Methods inherited from SavingsAccount:
deposit(self, amount)
Deposit money into an account
 
Parameters
----------
amount : int | float
    amount to deposit into the account in dollars
 
Raises
------
ValueError
    raised if the deposit amount is not a positive number

Readonly properties inherited from Account:
account_number
account_number : str
    Unique account number
balance
balance: int | float
    account balance in dollars

Data descriptors inherited from Account:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SavingsAccount(Account)
    SavingsAccount(account_number, account_holder, interest_rate)
 
Represents a standard savings account
 
Savings accounts must have non-negative balances, and
have interest paid on their balances
 
See Also
--------
Account : Parent Class
 
 
Method resolution order:
SavingsAccount
Account
abc.ABC
builtins.object

Methods defined here:
__init__(self, account_number, account_holder, interest_rate)
Creates a new `SavingsAccount` instance
 
Parameters
----------
account_number : str
    Unique account number
account_holder : str
    Name of the account holder
interest_rate : int | float
    interest rate applied to the account
__str__(self)
Return str(self).
apply_interest(self)
Apply the interest rate to the account and update the balance
 
Returns
-------
None
deposit(self, amount)
Deposit money into an account
 
Parameters
----------
amount : int | float
    amount to deposit into the account in dollars
 
Raises
------
ValueError
    raised if the deposit amount is not a positive number
withdraw(self, amount)
Withdraw money from an account
 
Parameters
----------
amount : int | float
    amount to withdraw from the account in dollars
 
Returns
-------
None
 
Raises
------
ValueError
    Raised if `amount` cannot be withdrawn

Data and other attributes defined here:
__abstractmethods__ = frozenset()
account_type = 'Savings Account'

Readonly properties inherited from Account:
account_number
account_number : str
    Unique account number
balance
balance: int | float
    account balance in dollars

Data descriptors inherited from Account:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
Data
        account_dictionary = {'Credit Account': <class 'Data.Account.CreditAccount'>, 'Long Term Savings Account': <class 'Data.Account.LongTermSavingsAccount'>, 'Savings Account': <class 'Data.Account.SavingsAccount'>}